The Rise of JavaScript

8/8/2012
In .NET

JavaScript is going to be the most important programming language of the next 5 years. There, I wrote it, even though the emotional side of my brain is having a hard time accepting such a logical conclusion.

There’s no question the modern computing environment is moving away from a homogenous, PC-based devices. Tablets! Smartphones! The Cloud! The modern business is serving quite a diverse mix of computing platforms, glued together by the the internet with the browser as the common client.

Diverse clients, however, demand a common, cross-platform UI, hence the rise of the HTML5 standard. Software publishers are moving away from proprietary plugins like Adobe’s Flash and Microsoft’s Silverlight to add capabilities to web-based software, instead choosing to enhance the HTML standard to deliver rich user experiences natively. As proof, IE 10 in Metro mode will not allow plugins (although a version of Adobe’s Flash is built in by default). Similarly, Apple’s Safari browser will not allow the Silverlight plugin to be installed on the iPad and iPhone.

Software manufacturers are throwing their weight behind the HTML5 specification, enhancing it to allow browsers to deliver rich user interfaces with integrated video and enhanced UI controls without the need for plugins. JavaScript is, of course, the programming language used to interact with all of these enhanced capabilities.

The HTML5 specification, of course, still does not meet every need. Even though it enhances JavaScript to enable it to support capabilities like drag and drop natively, there are other capabilities that are still lacking. The community has stepped up to fill those gaps in an impressive way, however, as evidenced by the rise of JavaScript libraries like Knockout. This JavaScript library provides data binding capability which is conceptually (but not semantically) similar to the data binding model in WPF and Silverlight. Indeed, there are whole web development frameworks (witness AngularJS) written in JavaScript.

Not only is JavaScript important in browser-based applications, Microsoft is supporting it as a native development language for Metro applications. So its use as a client UI language is growing.

If JavaScript is having so much success on the various clients, what about server side development? Well,node is a platform for writing server-side services written entirely in JavaScript. And Microsoft is working on an integration piece allowing node applications to be hosted by IIS. You can read more about how itworks. Microsoft is even supporting node applications on their Azure Cloud Platform.

So what’s the big attraction with JavaScript? Obviously, the fact that it is almost universally available in any modern browser is a huge plus. But even with that benefit, JavaScript itself is just plain odd. It has object oriented capabilities without having classes. It’s an untyped language – variables are untyped, but the data referenced by the variables is typed. There is no native namespace support. Even the name is odd – the only thing it shares with Java is the use of curly braces to set off code blocks. A more idiosyncratic language implementation would be difficult to find.

One powerful benefit of JavaScript is the asynchronous programming pattern. JavaScript excels in the ability to run code on a background thread of execution, whether that is a browser-based application fetching data from a server, or a server-based application performing file I/O. Instead of running multiple threads of execution, JavaScript kicks off operations that may take some time, and waits for an event to fire to signal the operation is complete. Between the time the operation is invoked and the completion event fires, the main thread of execution is free to perform other work. So a JavaScript based application can scale up, while using less resources, than a competing application doing synchronous operations on multiple threads of execution. This single threaded asynchronous pattern avoids the difficult challenge of coordinating access to shared data with multiple threads of execution.

Traditionally, JavaScript performance has been quite slow compared to other languages. Most implementations of the JavaScript engine have been strictly interpreted, not compiled. However, most browser developers have been spending significant efforts improving their JavaScript engine implementations, so that performance is now much faster than even a couple of years ago.

Until recently, Microsoft has not had a course focused on JavaScript. Those of us who teach have had to rely on other courseware vendors to fill that gap. However, Microsoft recently released the HTML5 Programming course, which among other things has the best coverage of the JavaScript programming language that I have seen. It’s an outstanding course, which is good because I can tell I am going to be teaching it a lot over the next several years.

If you haven’t taken the opportunity to dig into JavaScript yet, I strongly encourage you to do so. You may find yourself holding your nose at times as you learn how it works, but I encourage you to be patient with it and allow yourself time to get used to its idiosyncracies. It will be time well spent to advance your career in the next few years.