History

JavaScript was created by Brendan Eich. It stared life as Netscape's "Livescript" in 1994, became Sun's JavaScript in a partnership deal, and is now a standard, the European Computer Machinery Association (ECMA)'s ECMAScript

Language

JavaScript is an object-oriented scripting language. It is weakly typed. It is case sensitive and variables do not have to be declared before they are used. Though it is not in fact a form of Java, its syntax is similar to Java (and other languages in the C family).

Unlike Java, the language is not purely OO - procedural code is supported - i.e. you can have functions that are not attached to any object.

The object model and execution environment is quite unlike that of Java. Due to Javascript being interpreted, it is a highly dynamic language. Strings can be executed with eval, and methods and properties can be attached to classes and objects at runtime.

In Javascript, the class of an object is in fact also an object, a prototype for instances. The Mozilla site calls this "prototype based object construction" Like Python or PHP, but unlike Java or C++, the class declaration is in fact a statement that is executed at runtime, creating a class object.

Fortunately, code which is never reached does not have to be correct.

These factors of weak typing, no variable declarations, no checking of syntactic correctness until the code is reached, evaluation of strings and the ability to attach new methods on the fly lead some more traditional programmers (like myself) to view the language as a fast-and-loose scripting language that does not encourage well-structured code and early detection of bugs. Others like the language for these reasons.

Uses

JavaScript is generally used in web pages as a client-side scripting language, to perform whatever tasks need a little embedded code. In the past, this has been a bit of flashy image manipulation or animation, and is now used for popup widows, menus and timeouts, but it has a serious role in e-commerce sites to validate form data on the client side, and to generally make a web page seem more like an interactive program and less like a document.

JavaScript is supported by most browsers as it is very useful. Sure you can turn it off in your browser, but you will find that many complex and useful sites just won't work without it.

JavaScript is a glue language. Generally it is not used to perform large isolated computing tasks like computing Fibonacci numbers. Despite Mentifex's pet project which he punts at every possible opportunity, there is little or no serious academic interest in JavaScript as a good language for AI. I look forward to him proving me wrong, but I am not holding my breath for it.

JavaScript code mostly interacts with the browser and the HTML document, and is often attached to event handlers on elements on that page. Almost all the work done by JavaScript on web pages is manipulation of APIs to the rest of the page.

The horror

Here lies the problem: Standardisation of the APIs, Document Object Models and classes that javscript glues together is badly lacking. Making a script work across several of the most popular browsers is time-consuming, and often ends up with each procedure being a case statement:


if (Browser_is_IE) 
 do this; 
else if ((Browser_is_NS) && (version > 4))
  do something else
else ...

The other alternative is to make several different versions of the same JavaScript file, and serve the appropriate one depending on what the client agent claims to be. Neither of these options are appealing - both involve extra work, lots of testing, duplication of code, parallel maintenance, and neither give any guarantee that your code works on all browsers, only those that you have tested. Don't assume that you have tested Microsoft Internet Explorer, therefore it works in Internet Explorer. You may have tested on IE 5.0 with high encryption pack on Windows 2000. The script working in other versions and platforms of IE is likely but not certain. Write Once, Debug Everywhere.

JavaScript is a technology that promises much but delivers little. JavaScript in practice is an inelegant technology that Balkanises the web. How could a decent little cross-platform standard client-side scripting language with a lot of potential, could be the cause of so much chaos, pandemonium, lack of standardisation, forced upgrades, vendor lock-in, duplication of effort and cut-and-paste coding? It is the living hell of the keep it on the client side philosophy.

It is ironic that Netscape 4, the browser that brought JavaScript to a wide audience, is now one of the biggest impediments to JavaScript's progress and standardisation. The other being Microsoft Internet Explorer.

Note for instance, that mentifex's project is not for JavaScript, it is ""jsaiMind for Internet Explorer with JavaScript enabled"

The future

I wrote this in late 2001. The situation may change. Mozilla promises to be the most standards-compliant browser ever, and the Mozilla project is committed to open standards. The good thing about Mozilla's free, open technology is that it is popping up all over the place. Maybe Mozilla and its offspring (Galleon, Netscape 6, etc) will become popular, and maybe the standards will be extended and tightened.

"There is a Web Standards pressure group that is trying to get some groundswell of public opinion going to make Microsoft and Netscape toe the line and at least support the W3C and other published standards. They are at http://www.webstandards.org/ and are called 'The Web Standards Project'."

"Netscape's JavaScript is a superset of the ECMA-262 Revision 3 (ECMAScript) standard scripting language, with only mild differences from the published standard."

Maybe MS IE will also become more standards-compliant, out of desire to keep up with Mozilla and to track the best practice. Maybe the current situation where IE's installed base and de-facto standard looms large (but not large enough to make it the only one that a web developer can afford to care about) will change. Maybe Vendor lock-in will cease to be large software companies' goal. Maybe.

This write-up was put together using additional information sourced from various parts of the web. The opinions are mostly my own.


In 2005, Themanwho notes that:
1) It is now almost never necessary to write separate code for separate browsers (e2 annotation tool is about 500 lines of .js and has only two pieces of code which need to be tailored to the browser).
2) Better than if (isInternetExplorer()) is to test for features like:

if (document.getElementById)
  {document.getElementById("id")}

The future, part 2

In 2006 the latest thing on the web is a set of technologies called AJAX. Vendors from Google to Microsoft are producing AJAX toolkits. Most of them generate JavaScript on the server side, and will emit different JavaScript aimed at a range of popular browsers.

The other new thing is Microsoft's is actively developing Internet Explorer again. The latest version, IE7, promises to be the most standards-compliant version ever (that's not saying a lot). This development is due in no small part to the erosion of IE's market share to Mozilla and its spin-off, Firefox. Though this will bring some relief to web designers, these is still a long way to go.


http://wp.netscape.com/comprod/columns/techvision/innovators_be.html
http://en.wikipedia.org/wiki/JavaScript