There are a few claimed benefits to Node.js that I typically hear. Some (many?) I agree with. There is one that I completely do not understand, which is the one language argument: “You can now use one language on both the client side and the server side.”
This does not make sense to me on many levels:
- most people already know more than one language, and learning a second is anyway not that big of a deal.
- JavaScript is not that great of a language; if people had any choice they’d probably choose something else on the client side, but they’re locked in.
- the beauty of the server side is you can choose ANY language (so it makes sense to choose the best, most capable language, with the least baggage).
The only reasonable argument I’ve heard is “if I’m using backbone I can re-use my models”. Since I haven’t used backbone myself I’m not sure how much that actually amounts too however.
Can someone shed some light?
11
Let’s start with your points:
-
Most people don’t want to work in several languages in the same day.
-
Javascript works. It may not be the pinnacle of language design, but it is incredibly flexible. The perceived quality of the language rests a lot on the programmer, which is pretty unique.
- There are some bad parts, but every language has those
- The bad parts are very well documented and can be easily avoided
- It’s actually quite fun to write in. I can’t say that for any OO language.
-
Some people choose Javascript for the server, and Node.js’s popularity highlights that. In fact, a lot of the Node.js community came from Ruby, which is considered a very fun language to write in.
Now for my points:
- Fantastic community with incredible energy
- Massive portability (includes code reuse)
- Decent package manager
I find Javascript a fun language to write in. When I’m working in other languages, I often miss features that they done have, such as first-order functions, Array methods, stupid-simple closures, and prototypal inheritance (it’s fun when you get to know it).
Javascript is not my favorite language, but it’s definitely not the worst. I’ve since left the Node.js bandwagon, but I still keep it in my toolbox. It’s a lot more interesting than languages like Java or C++.
8
“You can now use one language on both the client side and the server side” doesn’t require that said language be JavaScript. There are a number of other languages which can be compiled into JavaScript, avoiding some of its pitfalls. Some are designed specifically for the purpose (e.g. CoffeeScript), and others have a large pool of experienced programmers (e.g. Java).
On the one hand it might seem crazy to compile Java to JavaScript and run it with Node instead of compiling it to a war and using a J2EE application server. On the other hand, compiling whichever source language you use to JS for both the client and the server avoids issues which could potentially arise due to translation gotchas.
3