3 ms·
I think in this case there are a few reasons: 1) Node.js has a huge ecosystem and it's easy to use 2) JavaScript is known by many 3) JavaScript may not even
by egeozcan 13y ago
I think in this case there are a few reasons:
1) Node.js has a huge ecosystem and it's easy to use
2) JavaScript is known by many
3) JavaScript may not even come close to being a proper language for hardware programming but it is good enough for these kind of devices
- drdaeman 13y ago> Node.js has a huge ecosystem So do many other platforms. > JavaScript is known by many So are many other languages. > JavaScript [...] is good enough for these kind of devices So are many other languages. The question, as I got it, was "why JavaScript is chosen among many possibly alternatives?". Your comment does not answer it, I believe.
- egeozcan 13y agoEven if you used the same argument for all my points, the intersection of the result sets seems to be empty. To be more clear, AFAIK, no other platform accomplishes those three goals as good as JavaScript. Maybe Python? GitHub language stats used to say otherwise (until they removed them). I also have the impression that as far as dynamically typed languages go, JavaScript is one of the most optimized ones. Well, Lua and some others beat it on speed but they are not as popular and/or provide what node.js provides.
- reustle 13y agoAlso, the event loop seems work well with these fun hardware projects
- drdaeman 13y agoYou can have event loop in any language that has enough access to underlying OS facilities (select/poll/epoll/kqueue) out there. Can't name a non-esoteric language where you can't off the top of my head.
- cliffbean 13y agoIt's not just a theoretical question about whether a particular language is capable of supporting an efficient event loop. It's also a significantly practical question about whether there are a large number of libraries and community experience built up around programs organized this way. This is also one of the big reasons why the people who wrote node.js picked JavaScript in the first place [0]. [0] http://s3.amazonaws.com/four.livejournal/20091117/jsconf.pdf http://s3.amazonaws.com/four.livejournal/20091117/jsconf.pdf
- drdaeman 13y agoAny reason large number of libraries should even know about they're using evented/async IO? I believe most of them consist of purely sequential actions (say, "connect then send then receive then process then return") and gain no benefit from non-blocking (function-wise, not program-wise) IO. If the core is smart enough to run them as coroutines (for example see Python's gevent.monkey) that yield back to event loop on waiting for IO, they'll automagically do the right thing without being infested with CPS callback ladder hell.