4 ms·
>>I'm suggesting that the factors contributing to a languages widespread adoption are varied and complex. Yup, thats true, and being performance oriented isn't
by prahladyeri 12y ago
>>I'm suggesting that the factors contributing to a languages widespread adoption are varied and complex.
Yup, thats true, and being performance oriented isn't the only selling-point for node.js. The fact that all node apps are single-threaded (and thus conserve cpu capacity), combined with the functional-programming approach of javascript (which makes things like async I/O easier, don't hurt either.
- sportanova 12y agoI wouldn't say that single-threaded is a good thing, or that JavaScript is a functional language
- prahladyeri 12y ago@sportanova - If callbacks are available for everything, then what is th need for multi-threading. You can handle everything in your own thread. When required, runtime will give you a callback. JavaScript indeed has functional programming features. See: https://en.wikipedia.org/wiki/Javascript https://en.wikipedia.org/wiki/Javascript
- sportanova 12y ago1) While it's possible to take advantage of multiple cores with Node, it's easier to do it with a system that supports multi-threading out of the box. Node's event loop model (and interface, in the form of callbacks) works well for IO intensive purposes, but hardly obviates the use of multi-threading (especially when some CPU intensive processing comes into play). 2) I think functional programming languages are best viewed on a spectrum, and Javascript falls pretty low on the spectrum. Higher than Java, but far behind Scala and way, way behind Haskell. It has closures and higher order functions, but so does Java 8, and I wouldn't call Java a functional language. Off the top of my head it's missing immutability, referential transparency, pattern matching, lazy evaluation, tail recursion, and monadic structures. Just because a language has or is missing a few of these doesn't mean it is / isn't functional, but relatively speaking, Javascript is pretty low on the spectrum.