paulbellamy.com

Node vs Go

28 January, 2012

Note: This comparison is quite out of date, and once Go 1.1 is released, I’m planning to revisit this comparison and cover what has changed.

I’ve done a bit of Google Go, and done a bit of Node.js, and I thought it was time to do a bit of a comparison between them.

I’d like to preface this with a few disclaimers. This comparison is completely subjective, and you are welcome to disagree.

Most of the problems I work on solving are networking-centric, Internet-based, and heavy on I/O. As a result, I’ll be evaluating the languages from that perspective.

Google Go

For those that haven’t done any Go yet, it’s “a fast, statically typed, compiled language that feels like a dynamically typed, interpreted language”. It is backed by Google, and is used at Google, Heroku, and other places.

Advantages

Disadvantages

Impressions

Go is a pleasure to develop in. Writing Go is the first time I have really enjoyed writing in a C-style systems language. The speed of the compiler, while it seems like it wouldn’t be a big thing, goes a long way to making the language fun to develop in. It enables tools like gorun, which is a simple script to compile and run a Go program on-the-fly. Furthermore, the core libraries are complete and generally pretty good. However, due to the poor support for (and selection of) third-party libraries once you start getting into things not included in the core libraries your experience becomes much more DIY.

In general, Go really shines for applications which are easily parallelizable, and require lots of CPU. Go is a great choice when you need C’s speed and control, but don’t want the maintenance headaches, garbage collection, and coding overhead of developing in C. For example, Tinkercad use a cluster of Go servers for performing heavy backend calculations.

In short, Go feels like it is what C would be like if it were developed today.

Node.js

For those that haven’t done any Node.js before, it is “a platform for easily building fast, scalable network applications”. With event-driven non-blocking I/O, it forces an asynchronous ‘callback-passing’ style of development. As a Javascript engine it doesn’t require you to learn any new language or syntax (assuming you already know Javascript).

Advantages

Disadvantages

Impressions

While the language of Node.js is nothing special (it’s just Javascript after all), the thing that impresses me most about Node.js is its community. They are absolutely rabid about the language, and are some of the most pragmatically focused developers I have ever seen.

Ryan Dahl’s post about ‘I hate almost all software’ really drives home the Node community’s focus on user experience, and getting stuff done.

Conclusions

It would be hard to go wrong with either of these languages. The choice really depends on your needs and development style.

Both Go and Node are very pragmatic, and concerned with ‘just getting stuff done’.

Both have excellent hosting solutions. Go has AppEngine, while Node has JoyentCloud and Nodejitsu. Also, both can be deployed to Heroku’s Cedar stack.

However, there are a few key differences. Node.js has a rabid, and rapidly growing community, tons of third-party libraries, and an extremely pragmatic focus. Google Go has a large, complete set of core libraries, an easy path to high concurrency, and is blazingly fast.

Go also has a focus on the ‘correctness’ of the solution (evidenced by it’s type-safety) and it’s community prizes uniformity, emphasizing doing things the idiomatic way. The Node community tends to be more focused on the functionality, and are more tolerant of doing things in different and unique ways (e.g. Javascript vs Coffeescript).