There are many programming languages out there. Why should you use JavaScript?
- Is it an elegant programming language?
- Is it useful in practice?
- Does it have good tools, especially good integrated development environments (IDEs)?
- Is it fast enough for what you want to do?
- Is it widely used?
- Does it have a future?
Is JavaScript Freely Available?
JavaScript is
Is JavaScript Elegant?
Yes and no. I’ve written fair
Language compatibility between JavaScript engines used to be a problem, but isn’t anymore, partly thanks to the test262 suite that checks engines for conformance to the ECMAScript specification. In contrast, browser and DOM differences are still a challenge. That’s why it is normally best to rely on frameworks for hiding those differences.
In the area this section, I use the term HTML5 for “the browser platform” (HTML, CSS, and browser JavaScript APIs). HTML5 is deployed widely and making constant progress. It is slowly becoming a complete layer for writing full-featured, cross-platform applications; PhoneGap, , and TideSDK.
Additionally, several platforms have web apps as native apps or let you install them natively—for example, Chrome OS, Firefox OS, and Android.
Other Technologies Complementing JavaScript
There are more technologies than just HTML5 that complement JavaScript and make the language more useful:
- Libraries
- JavaScript has an abundance of libraries, which enable you to complete tasks ranging from parsing JavaScript (via ) to processing and displaying PDF files (via PDF.js).
- The Node.js platform lets you write server-side code and shell scripts (build tools, test runners, etc.).
- JSON is a data format rooted in JavaScript that has become popular for exchanging data on the Web (e.g., the results of web services).
- NoSQL databases (such as CouchDB and )
- These databases tightly integrate JSON and JavaScript.
Does JavaScript Have Good Tools?
JavaScript is getting Grunt) and test tools (e.g., ). Node.js makes it possible to run these kinds of tools via a shell (and not only in the browser). One risk in this area is fragmentation, as we are progressively getting too many of these tools.
Additionally, browsers are becoming increasingly capable development environments. Chrome, in particular, has made impressive progress recently. It will be interesting to see how much more IDEs and browsers will be integrated in the future.
Is JavaScript Fast Enough?
JavaScript engines have made
- asm.js is a (very static) subset of JavaScript that runs fast on current engines, approximately 70% as fast as compiled C++. It can, for example, be used to implement performance-critical algorithmic parts of web applications. It has also been used to port C++-based games to the web platform.
- parallelizes JavaScript code that uses the new array methods ,
filterPar
, and (parallelizable versions of the existing array methodsmap
, , andreduce
). In order for parallelization to work, callbacks must be written in a special style; the main restriction is that you can’t mutate data that hasn’t been created inside the callbacks.
JavaScript is widely used and reaps both of the aforementioned benefits:
- These days, documentation and support for JavaScript comes in all shapes and sizes: books, podcasts, blog posts, email newsletters, forums, and more. points you toward important resources.
- JavaScript developers are in great demand, but their ranks are also constantly increasing.
Does JavaScript Have a Future?
- The language is evolving steadily; ECMAScript 6 looks good.
- There is much JavaScript-related innovation (e.g., the aforementioned asm.js and ParallelJS, Microsoft’s TypeScript, etc.).
- The web platform of which JavaScript is an integral part is maturing rapidly.
Conclusion
Considering the preceding list of what makes a language attractive, JavaScript is doing remarkably well. It certainly is not perfect, but at the moment, it is hard to beat—and things are only getting better.