was created by Brendan Eich
. It stared life as Netscape
" in 1994, became Sun
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.
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.
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:
else if ((Browser_is_NS) && (version > 4))
do something else
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.
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'."
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:
The future, part 2
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.