Wednesday, 22 June 2011

Why is JavaScript 2.0 the Next Big Language?!

2007 forecast is turning into reality.

Why JavaScript ?

Everything below is my personal opinion and experience (I am just a researcher at university,
no company interests involved :)). You are free to agree or disagree.

It is already big thing. It is in every browser, on every mobile, in palm's WebOS you can run it natively. There is a lot of work around "JavaScript outside the browser" going on (CommonJS, Node.js, Rhino on Rails). If you know JavaScript, you can code browsers, Web servers, mobile, 2D and 3D graphics, anything!

Some people say: "It's not serious language". Well this language is used to build Google Maps for you, Google Docs, Facebook. If that's not a serious projects, maybe Google should concentrate on some other serious stuff?

Most of JavaScript code is open source. It's running in browser and it's an interpreted language you can easily get the code and run it yourself.

If someone does web development, he has to know javascript. That's THE language to be used on the client (you just don't have a choice). On the server side - well that's up to you! You can choose Java, Ruby, PHP, Python, Scala, whatever. But think, that's one more language to learn.

I personally use now (due to the project requirement) Ruby and Java on the server (before it was also PHP). That's OK for me (cause I've already done it), but it's a pain when new student comes and ... I tell him: "here are four languages you have to learn now - Ruby, Java, PHP, JavaScript". That's a lot for one single student. Of course, one could say - "if you know one language, it is ok to learn another one". Well, that's true but in addition to a language you need to learn a framework for it. And even simply few languages is a lot for a person. It's much easier to say: "Learn JavaScript and you are done", right?

Write code only once
I've been coding for Web for quite some time now. I do heavy client side applications and unfortunately sometimes I need the same functionality both on the client and on the server. Well for now I have to implement a thing in Ruby and then re-implement it in JavaScript or vice-versa. That's a real pain! With JavaScript everywhere, I don't need it any more - I write every function only once!

JavaScript is an interpreted language. Which means that it is supposed to be much slower, than compiled languages (C, Java), and get into category of Ruby/Python/PHP.

JS is around 3-10 times slower than Java while Ruby is 10-30. See this benchmark study:
This is due to special optimizations done by Google and other browsers. The constant rivalry between browsers makes the JavaScript engines faster and faster every day.

There are discussions (and implementations!) about introducing static types to javascript, that would make its performance the same as compiled languages.

Actually JavaScript is a very nice language. Many people used to see it as a hacky not-reliable language, but many things have changed since its first introduction in Netscape. I (and many will agree with me) find it as a nice, elegant language. If you disagree, get a good book and start reading it :)

It is so easy to start. Just run the Chrome browser. Right click -> Inspect Element -> Console tab. You got it! Just type the code 8+5-7 and hit the Enter. You'll see 6 as a result. It was easy, right?

Google behind and others
Google is a big pusher for JavaScript. Having a big company behind the language is almost often language success (Java, as example). There are many others to help Google here (Joyent, Mozilla, Opera, etc.)

JavaScript is THE language for Web development

Some people claim Scala to be the Next Big Language. Well, I doubt it. I find it very cool and I would definitely prefer Scala to Java. Maybe it will get accepted in some areas, but I don't think in Web development. I personally do not want to learn an additional language. I am fine with only one. I do not want to rewrite my code for both Scala and JavaScript. Remember - I have to do it for JavaScript, no choice here :)

If you are creating a web application, very often language speed does not matter that much. The most important thing is the memory management and JavaScript has a super-cool thing here called Node.js It is an event-driven server-side JavaScript based on fastest V8 JavaScript engine from Google. This is THE WAY to go today and this is one more big PLUS for JavaScript.

If you are to learn a programming language and you have a slightest feeling you might need to do some work for the browser, pick up JavaScript!


  1. This post is unbelievably useful. It's somewhat of a basic guide, but I know dozens of beginners who could really use it. I'll spread it on and try to keep up with your blog on a weekly basis. Thanks!

  2. Ofcourse javascript has many advanced tools that were really a great help for making many applications.Its good to know about the Java 2.0