Introduction to programming

Welcome to a APC's JavaScript tutorial. This tutorial will focus on learning JavaScript, but the concepts presented here will be useful in other programming languages as well. Not only does JavaScript share a lot of features with other popular languages, it's easy to use JavaScript in your HTML files from the beginning, without a great deal of investment in expensive compilers. If you can view JavaScript, you can write JavaScript.

HTML - and the Web in general - has revolutionised the way we use computers. Anyone familiar with the Internet knows of the vast amount of information available through HTML and the Internet protocols. However, HTML's benefits extend much further than the Web. In fact, you need look no further than APC's cover CD for proof.

Why JavaScript? JavaScript is easy to learn and enjoyable to use. Languages like C initially limit you to text-based input/output. JavaScript begins with a richer palette -- HTML. From the beginning, JavaScript allows you to add interactivity to Web pages, generating text, graphics and even sound. However, the single greatest reason to learn to program, in any language, is to make the computer do what you want it to do.

With all the talk of Java, it's important to understand the differences between the two languages. Java is a complete programming language, designed to create complex, standalone programs. Java is unique in that it is a cross-platform language. With traditional programming languages like C++, program code has to be modified to run on different platforms. Java applets are 'write-once, run anywhere', and give developers the power to embed complex programs into HTML documents.

JavaScript, on the other hand, is a scripting language that adds simple interactive content to HTML. Whereas Java programs (and Java applets) are compiled into a byte-code before being distributed, the Web browser interprets JavaScript as HTML documents are loaded. Like HTML, JavaScript is transferred as plain text and is usually placed in the HTML document itself. JavaScript's syntax is loosely based on the Java syntax, which is in turn based upon C++. JavaScript, however, is a much more forgiving language than either C++ or Java, and much easier to construct.

The only assumed knowledge in this feature is a very basic understanding of HTML. If you've never created a Web page before, a good first reference is Lee Borkman's HyperText column. Another way to learn more about HTML is to choose the View Source option found in most Web browsers. Viewing the source file allows you to see the HTML that produced the Web page, as well as any JavaScript that was included. And for assistance in creating pages, there are a number of good WYSIWYG HTML editors that help simplify the process of creating HTML (see the November 1996 cover CD for a selection of shareware HTML editors).