--- title: JavaScript's popularity tags: dbc, javascript image: js.png published: false

Why is JavaScript popular?

This is not a question I had considered before so the first thing I do is to search the web. I came across several reasons which aren't really convincing. For instance: "JavaScript works in all browsers." This is not an answer, but a relation. Is JS popular because it runs in all browsers or do all browsers support it because it is popular?

To find out we need to consider if JavaScript gathered a large support base or did we gravitate towards it as the default due to lack of better or known alternatives?

LiveScript

Netscape Communications Corporation released LiveScript as part of their browser, Netscape Navigator. Someone in marketing decided to rename it to JavaScript with the intention to piggyback on the success of Java. It has nothing to do with Java and now we are stuck with a confusing name. That's marketing for you. I remember reading this once: Java is to JavaScript what Car is to Carpet.

When Microsoft released Internet Explorer they had to support JavaScript in order to compete with Netscape, even though they tried to push their own with Visual Basic Script. By then it was too late and JavaScript was relied upon by many websites.

I could leave it here, but there must be more to JavaScript for it still being in use today. If that was the only reason it would have been replaced by now. So here are some of the reasons it's alive and kicking:

JavaScript is flexible

It is not as rigid as other programming languages. Normally a specified function will take only the defined number of parameters. If you fail to deliver them, or you provide too many, the function will not run. In JavaScript the function will be executed regardless. This does sometimes give unexpected results, but it does make it more flexible and can allow for shorter code. You won't have to write out every possible fallback scenario anymore. So that's an argument for saying it's easy to learn.

JavaScript is fast

This is related to the previous property. Because it is flexible, and it allows for fewer lines of code to process, it is lighter on memory and faster to process. A very important aspect when running in a browser on the client side. The longer you have to wait for the page to respond, the more likely you will leave that website. And right you are.

The right tool for the job

Over time JavaScript has been proven to be adaptable enough to provide what was needed by web developers, again and again. This isn't because it was the only tool in the box, but it is useful in many situations because of its flexibility and reliability.

TL;DR

  • JavaScript is easy to learn.
  • JavaScript is flexible.
  • JavaScript is forgiving.
  • JavaScript is widely implemented and there is no reason for it to be replaced.
  • It has Java in the name?
Thanks for reading. If you have any comments I'd be happy to hear from you.

References:
Programmers StackExchange
A wonderful explanation of JavaScript by Douglad Crockford.