Why is JavaScript designed the way it is?


JavaScript is the programing language that makes the Web alive by integrating the HTML pages with client-side JavaScript code. Considering all the Web, I would expect that it contains billions of lines of JavaScript code. In addition, billions of people browse the Web every day. Therefore, designing and maintaining this language is an extremely critical undertaking. It pretty much determines the amount of effort and money required to develop dynamic Web pages. I was surprised to know that the first version of the language was designed and implemented within a short period of time. Apparently,  the first prototype was implemented in 10 days in 1995. It’s not clear to me whether it was designed on the fly within that period or it was already designed. At that time, there were already many different kinds of programming languages. The need for a dynamic Web is obvious. But why coming up with a new language? Why didn’t we use one of the existing languages? Why does it look the way it does today?

Sun Microsystems (acquired by Oracle) developed the Java language and released it in 1995. It had the same vision in that the Web should be dynamic. To that end, it developed something called Java applets, which are Java programs that can be served with HTML pages and run by the browser. This of course requires browser support for the Java runtime to run the applets. These programs can then change the HTML page and potentially access system services.

A company called Netscape (acquired by Verizon Communications) had a very successful Web browser called Netscape Navigator. Sun wanted that browser to have built-in support for Java applets. They pressured Netscape to close a deal as soon as possible to prop up marketing Java. Netscape needed to develop its language for the future Web urgently. But they didn’t want for that language to have an existential competition with Java applets. Instead, they wanted to have a language that it would make sense to exist side-by-side with Java applets. This helps in making a profitable deal with Sun while at the same time, be part of the dynamic Web revolution.

The original name of JavaScript was Mocha. It had the following design goals:

  • Its syntax must be similar to Java. This benefits both companies because those who learn one language will be able to quickly learn the other.
  • It must be a simple language so that it’s easy to learn by HTML and CSS designers, but powerful enough to support sophisticated use cases. So it has to be dynamically typed and follow the functional style. The semantics of the language are similar to Scheme and Self.

I think that due to time constraints, it was decided that JavaScript code would be served to the browser in source form rather than in some compact binary form. In this way, there would be no need to work on a binary file format. On the over hand, Java applets were released in binary form. Mocha was renamed to JavaScript as part of the deal with Sun. For a detailed history of the language and its similarities with Java, Self, and Scheme, refer to this great article. All in all, JavaScript turned out to be very successful.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s