3 ms·
Node is too often conflated with JavaScript. This is understandable, considering JavaScript is the interface between the developer and the platform. But as craz
by curun1r 11y ago
Node is too often conflated with JavaScript. This is understandable, considering JavaScript is the interface between the developer and the platform. But as crazy as this might sound, JavaScript is an implementation detail of the Node platform, not a defining characteristic. For instance, there's a project [1] that replaces JavaScript in Node with Lua.
But if you go back to the origin story of Node, it's all about libev (though it now uses libuv for the same purpose) and that pervasively-asynchronous mindset. JavaScript was chosen as the developer interface because it met the need to support that asynchronous philosophy. The result is that everything in the Node world is asynchronous and asynchronous is the path of least resistance for the developer. Other platforms that weren't conceived with this mindset often force developers to fight to be asynchronous.
> It seems like whether you're aiming for ease/speed of prototyping, pure performance, a good concurrency model...
It's a mistake to look at JavaScript as a fit for all of this. Instead, you should consider how the Node platform fills the need. For easy of prototyping, it's not JavaScript that makes Node excel, it's npm. The only package management system I've found that I prefer to npm is Rust's Cargo. And npm is still well ahead of Cargo in the richness of the package ecosystem. For pure performance, you can always write a native Node addon [2]. And, as mentioned, while JavaScript isn't concurrent at all, the Node platform provides the concurrency model in a way that has proven to be scalable but without most of the pain that comes with writing concurrent code. Writing concurrent code is hard...that's not news. The Node framework make writing concurrent code significantly easier by creating abstractions that hide the the fact that code is concurrent.
I know it's bizarre to look at it this way, since you would be writing most of your application logic in JavaScript, but try to look at it as an implementation detail and consider the advantages of the Node platform and the ecosystem that surrounds it. When you take this perspective, Node becomes a lot more attractive than the JavaScript language is on its own.
[1] https://luvit.io/ https://luvit.io/
[2] https://nodejs.org/api/addons.html https://nodejs.org/api/addons.html