JavaScript Could have been Much, Much Worse
There are many JavaScript misconceptions floating around. I have long hesitated to get into the discussion, but I think its time to start. I have been programming in JavaScript for many years now, and have gotten to know the language quite well.
JavaScript has flaws. Besides its flaws, it contains some strange ideas that seem very bizarre to many programmers from the common C/Java background. I get that.
However, Most of those idiosynracies (e.g. parseInt, lack of a rich standard library) don’t cause problems in practice. JavaScript has a large ecosystem of libraries that get around these flaws.
Unfamiliar is not the same as bad. The unfamiliar components to JavaScript (e.g. closures and prototypes) actually come from a very interesting theoretical background. They are very useful and powerful, if you take the time to learn the concepts.
Really, how I personally feel about JavaScript doesn’t matter. Web developers must know JavaScript. It is the programming language of the web. Love it or hate it, you must use it.
I think this is the reason many programmers hate JavaScript. Most of the time, developers don’t set out to “learn JavaScript”. They want to make their website do something interesting. Nobody likes to be forced to do anything. So, when they come across these unfamiliar things, they get frustrated, and the language seems unnessarily bad.
The fact is, though, that JavaScript’s rise to importance language is an historical accident. Almost any programming language designed for the web could have had similar success. The fact that JavaScript is a pretty nice language had little to do with its success. Web developers commonly go through great lengths to make their websites work where they need to. We make do with whatever the browsers give us.
A number of years ago, Microsoft was pushing its own competitor to JavaScript named VBScript. Based on Visual Basic syntax, it was familiar to the many Microsoft programmers who already know Visual basic. In the days before C#, this was actually a large percentage of programmers. For a short time, VBScript was fairly popular. Some pundits wondered if Microsoft was going to succeed in displacing JavaScript with VBScript. After all, at the time, most new websites were being built for Internet Explorer.
Fortunately, VBScript did not catch on in any significant way. I don’t know why it didn’t. In the days of IE6, Internet Explorer was essentially the only browser on the internet, and Microsoft had great power over the web. My guess is that Microsoft didn’t see VBScript as being essential to its success, and so it did not push the matter. If things had worked out differently, today we would be creating languages that compile to VBScript, not JavaScript.
Personally, I am happy with JavaScript. There are things I would change about it, but it is pretty great, all things considered. JavaScript could have been much, much worse.