JavaScript Intro

NEW 23 May 2006
Google site search

You need the Tcl Plugin to read this page. If this spot  is not green (v2) or cyan (v3)you may want to download the latest Tcl Plugin.

JavaScript is the de facto language used by webbrowsers to do fancy things. Unfortunately Javascript is a language in the more negative sense of the word, in that it consists of a mass of dialects with lots of exceptions. This is due to the genesis of the language.

As the WWW was being created in the early 1990's, computer manufacturers saw a need for a browser scripting language. They spent much money in research and development to produce a scripting language which would give them a share in the browser market. Javascript emerged as an early contender and in order to stay in the market other computer manufacturuers emulated/copied Javascript but with variations which would enable them to avoid copyright issues. MicroSoft called their entry JScript and for some time it lagged one version behind the JavaScript used by Netscape Navigator.

Now that Microsoft has effectively won the Browser War (for the moment) there is some rationisation taking place. But standardisation is causing more problems as the process of defining a standard is sidetracked by companies still jockeying for position in the market. The latest major entrant is the Firefox browser available on most Linux installations and also now available on Windows.

Javascript is more of a language than Tcl. Tcl is not much more than a set of simple replacements rules. JavaScript has more than features of a language with syntax rules. This makes a little more difficult to learn and does not allow creative flexability.

Tcl could not be used as a de facto browser scripting language because it is open source and freely available to all computer companies to use - so noone can use it to get an exclusive advantage. Also Tcl is too easy to add new features to - anyone can do it because of Tcl's simple primitves. For instance, to create a new loop construct.

In addition to these issues, JavaScript does not have good error reporting, debugging is a nightmare. You need special programs just to see what your script is doing. Add to this the tendancy to compress JavaScript scripts so they download faster. You are often confronted with impenetrable code.

It is this complexity of the language, the clumsiness built into its syntax and its proliferation of differing dialects, poor debugging support and often unreadable code that makes programming in JavaScript a Black Art. So what should be a fundamental part of using the net is a topic for the Advanced Section of WEBSCOOL.

As a consequence of this JavaScript is normally used as a cookbook of recipes to achieve certain webpage effects. You look through the cookbook and select the scripts that give you the effects you like. These scripts do date as new versions of browsers come out with their special dialects and new features.

The problem with writing your own JavaScript is that your code may woprk on the browsers you have available but may not work or work differently on other browsers. If you are writing webpages for an application where the company uses a standard browser everywhere you can be sure your webpages will be seen properly. If you are writing for the open market this is problematic. It is probably better to use solutions that have been proven already.

As a result of all these negatives, JavaScript is used almost exclusively for the purpose of writing scripts for webpages. If webbrowsers all had the Tcl Plugin bundled, what a different world the web would be. The Macromedia Flash Plugin has achieved at least a 90% penetration of the browser market, but this is because it is used for different purposes to JavaScript, mainly for streaming movies and sound.

A good book for tackling JavaScript is JavaScript Bible by Danny Goodman and Michael Morrison, Wiley. It has over 1100 pages in quite small print, but this is only two thrids of the whole book of 1700+ pages which comes on the accomanying CD in .pdf format. It does cover the details and exceptions of the dialects so that with care you can produce scripts that will work on most browsers. The examples are also available in seperate files on the CD, about 3.5 Mb of quality code.

1   Invoking Javascript        

©2000 - 2006 WEBSCOOL This page last updated 25 May 2006. All rights reserved - including copying or distribution of any portion of this document in any form or on any medium without authorisation. For more regarding the copyright.