3 ms·
Ocaml has no concurrency options worth mentioning (need to look to PolyML/SML or F# for that). Finding and teaching Haskell devs simply isn't feasible. C++ is w
by hajile 8y ago
Ocaml has no concurrency options worth mentioning (need to look to PolyML/SML or F# for that). Finding and teaching Haskell devs simply isn't feasible. C++ is way too low-level for most of the work that someone choosing node would be doing.
It turns out that most of the reasons a server needs threads is IO. With node, any IO is moved to a new thread, so you get most of the threading benefits, but are completely safe (provided libuv is safe).
Another consideration is JS being dynamic. It's very easy to create extremely flexible APIs and you can move very fast adding features without breaking things. While That SML or F# app will provide much better type guarantees (and somewhat better performance), those benefits simply don't pay off for a lot of projects.
There's also something to be said for functional vs OOP styles. You will never see a JS dev writing enterprise fizzbuzz. Even in very large projects, those layers of boilerplate abstraction simply won't exist. Part of that is being dynamic and part is being functional.
- pjmlp 8y ago> Ocaml has no concurrency options worth mentioning LWT is a thing. As for being dynamic, my experience has shown that beyond prototyping, most dynamic languages don't scale with the teams. You apparently never seen enterprise JavaScript, specially in projects with multiple consultancy companies being part of the mix.
- frutiger 8y ago> With node, any IO is moved to a new thread Not quite (or somewhat): the IO is done asynchronously. You tell the kernel to notify you when any of a set of FDs are ready for reading/writing, and it resumes you when that is so.
- hajile 8y agoMy understanding is that libuv creates a threadpool that it uses for IO operations and these inform the main thread when an IO event is ready. Is there something wrong with my understanding?
- frutiger 8y agoYes there is something wrong with your understanding. I recommend reading epoll(1) or kqueue(1).
- spiralx 8y agoYou're both right, although you more than the other guy being a dick. libuv uses a thread pool for asynchronous I/O for everything but network requests, which are handled on the main thread - presumably because they're already asynchronous by nature. http://docs.libuv.org/en/v1.x/design.html http://docs.libuv.org/en/v1.x/design.html