Newsletter "Behind the Scenes" Newsletter

February 2016The monthly newsletter by Felgall Pty Ltd

My Word

Two Languages - Both Called JavaScript

The differences between how JavaScript was written back in the days of Netscape 3 compared to how it can be written now are so totally different as to be completely different languages. Certainly the basics are still the same but that is shared with a number of other languages anyway. Once you move beyond the most basic commands though things are so different that they are effectively two different languages.

If the JavaScript code that had to be written to use with Netscape 3 had actually died out when that browser died and everyone had upgraded to using the newer ways of writing JavaScript and had continued to update their scripts to work with the latest versions as they were introduced since then the differences would not be an issue. Other languages have undergone similar changes over the years and everyone using those languages has updated their code each time to support the new version. While some companies might have continued running an old version for a bit longer than other companies, eventually the old version would be dropped and everyone would be using the new version.

The difference with JavaScript is that where the code is run is not under the control of who wrote it but is instead dependent on the browser visitors are using to run it. This removes the clearcut boundary line between versions. That programmers have with almost all other languages. It also means that browsers need to continue to support the old versions of JavaScript as they have no way of knowing which authors have or haven't upgraded their script to use the latest version of the code.

Because prehistoric versions of JavaScript still (sort of) work, the people with those sites have no incentive to rewrite their code to use more modern code. As a result many sites that have been around for a long time continue to use the same prehistoric JavaScript they did when the site began. This is quite reasonable given the way the web works.

Where things break down is that many of the people who have been teaching JavaScript either learnt JavaScript back in the days of Netscape 3 or were taught JavaScript by someone who learnt it back then. As a result these people are still teaching JavaScript the way that it used to be written for Netscape 3 and many brand new sites are implementing JavaScript that is written for Netscape 3. For people wanting to learn JavaScript, there is nothing to distinguish these JavaScript classes from those that teach modern JavaScript the way it needs to be written for modern browsers.

Right at the start of this article I commented that the difference between JavaScript for Netscape 3 and JavaScript for modern browsers make them effectively two completely different languages and yet both types of classes generally have the same name. Students wanting to learn JavaScript properly to use with current browsers end up in a class teaching JavaScript for Netscape 3 and don't find out until they are part way through the course and need to ask for help on a forum where if they are lucky someone who knows the difference between JavaScript and JavaScript will tell them which version they are being taught.

Perhaps modern JavaScript ought to be given a different name and the name JavaScript only retained for the old versions that people shouldn't be writing any more. Of course this would only work if we could make sure that only those actually using the modern language refer to the language by that new name. Unfortunately that would be unlikely to happen as the problem is that many people referring to JavaScript think that there is only one version and that any name change would apply to their Netscape 3 code and the classes they are teaching and not realise that the name change is only intended to apply to the other language currently called JavaScript that they don't even know exists.

The only way to effectively rename modern JavaScript to avoid confusion with the prehistoric language of the same name would be to have browsers enforce it. The modern JavaScript language would need a new MIME type different from the one that the historic JavaScript uses and should only run modern JavaScript when that MIME type is present. We could do away with the 'use strict' command as the new MIME type could always run in that mode. We could also have the new MIME type completely disregard obsolete commands as they would no longer be a part of the language. Even if only alert, confirm, prompt and document.write were removed from the language it would ensure that most historic JavaScript would not run using the new name for modern JavaScript.

Of course in ten years time the language will be completely different again. This doesn't mean that the same problem would arise again though if what is currently modern JavaScript were to be given a new name. Those teaching JavaScript (historical) would probably continue teaching it. Those writing it would either continue writing it or would suddenly realise that what they are writing is antiquated and would switch to writing JavaScript (modern) . Those learning JavaScript (modern) can be taught that the language changes over time - and shown JavaScript (historic) as an example of past changes. Anyway, future changes will be minor compared to the changes that occurred when the Document Object Model was added to JavaScript (the biggest past difference) and so there shouldn't be anywhere near the difference between 2026 JavaScript and 2016 JavaScript as there is between 2011 JavaScript and 2001 JavaScript.

Of course the name change will probably never happen and people will continue to confuse these two very different languages that unfortunately share the same name.

On Site

I had several people asked me this month if I accept guest articles. Strangely after I replied that I do I didn't hear anything more from them. Several more articles on mySQL this month comparing the two different interfaces PHP provides. Still a few more articles to come in that series.

What's New

The following links will take you to all of the various pages that have been added to the site or undergone major changes in the last month.

Main Links

Ask Felgall
Past Newsletters
Sign Up/Unsubscribe
Question Forum


Interactive Web
PC Software
Comms Software
Word Processing
Book Reviews

Other Links

My Javascript Site
My Blog