4 ms·
The important part in Node.js is not "js" it's "node". The design pattern encouraged is a network of micro-utilities nodes. Ryan Dahl (node.js creator) did not
by floby 15y ago
The important part in Node.js is not "js" it's "node". The design pattern encouraged is a network of micro-utilities nodes.
Ryan Dahl (node.js creator) did not choose javascript because it was cool but because the language was the most suited to its needs. In fact we started several project based on the same principles in different languages (C, lua, and others). Javascript is a good fit because it has no previous history on how to do I/O (which is the main focus in node.js design) except AJAX. It sure has been very helpful in making it popular. But the point is that there could have been Node.whatever. [1]
Now if you choose to use Node.js because it's cool, that's fine, but you're missing the important points :
1 - It is easy to write. Yes it is. Not only because it's javascript (or coffeescript) but also because the API is very well designed. Because of the agreed on convention of coding, it's also very easy to use modules even when these are not as much documented as node itself. It also would not be as easy to write if it were C or Java. In this netty example [2] you need 4 different classes to write an echo client/server which sums up to approx. 120 lines of code without comments and imports. The node version is 15 lines long at best [3] and clearer.
2 - It is efficient. Sure, in raw calculation, lots of other languages are faster. What makes node efficient is asynchronous I/O. You can do async I/O in any other programming language. It's just not that easy and most importantly you don't have to if you are lazy. The fastest language to write async I/O in is probably C. And you can do just that using libuv, the C library behind node.js which is incredibly faster without the Javascript layer.
3 - It works at the session/presentation level. Of course it's not as convenient as writing your php file, but it's necessary to ensure that the async model is respected (which is what makes it efficient, which is the reason why you came here in the first place). If you want cool javascript to replace php/JEEE/asp, you can use Jaxer.
Of course there are other important points that I'm missing here both because they don't come to mind at the moment and because you should experiment by yourself.
[1] http://www.youtube.com/watch?v=L_JKb61EalQ http://www.youtube.com/watch?v=L_JKb61EalQ
[2] http://docs.jboss.org/netty/3.2/xref/org/jboss/netty/example/echo/package-summary.html http://docs.jboss.org/netty/3.2/xref/org/jboss/netty/example...
[3] http://nodejs.org/ http://nodejs.org/