All the cool kids seem to be playing with Node.js, but why is Microsoft so interested?
Scott Hanselman is doing it.
Steve Marx is doing it.
Microsoft is even funding it.
Building web applications with JavaScript on the server has a nice symmetry with JavaScript on the client, but JavaScript has a reputation as an odd language. What's going on?
I think it's because Node.js will become a great way of building modern cloud applications. Perhaps it will even become de facto.
JavaScript is not so bad. It has all the interesting traits of a dynamic language whilst still having a familiar looking block structured syntax. Programmers don't freak out in the same way as they do when they first see Lisp or even Ruby. Some people even think that JavaScript is an acceptable Lisp. (It might have a REPL, JSON is almost homoiconic, but it would need a macro system to pass the Lisp test for me).
In the cloud, horizontal scale out matters. If you really want cloud economics, then it's better to have a large number of small virtual machines than a small number of large virtual machines; you can start small and scale more granularly. Ideally you want to run those VMs hot to get best value for money.
On Windows Azure, a small VM is a single 1.6 Ghz CPU with 1.75 GB of RAM. That's less than a crappy Netbook from PC World. The point is that small is beautiful if you can architect your software to make use of it.
We've all been told that Moore's law is coming to an end; that we won't be getting faster processors, but we will be getting more processors; that functional programming is the only way to cope with multithreading. Building multithreaded applications is hard, but if you're on a single CPU, maybe you don't need to bother? Perhaps there's a better way to keep that CPU busy, and that's where I think that Node comes in.
Node is inherently single threaded. Node gives you great performance by making the I/O asynchronous. If you aren't blocking on I/O then you have a much better chance of maximising CPU load.
The Node runtime is small and highly efficient, being based on the Google V8 JavaScript Engine. It compiles JavaScript to native code. There's still a way to go before we get a stable port for Windows, but the early signs are encouraging.
It turns out that cloud applications are typically I/O bound. A Web Role is waiting for web requests and a Worker Role is often shuffling data in and out of storage. These are ideal candidates for Node, which should give us better throughput on modest hardware. Node gives us a way to build small, fast, efficient, cost-effective, scalable cloud components.
I think it's a safe bet that we'll be seeing more of Node.js on Windows Azure. Watch this space.
In the meantime, feel free to check out node-azure.
*The opinions expressed on this site are my own and do not necessarily represent those of Two10degrees or Active Web Solutions Ltd.