3 ms·
It's not that simple. My impression - I'm not very knowledgeable about this - is that JS and others started getting around as fast (in best conditions and a lot
by klibertp 9y ago
It's not that simple. My impression - I'm not very knowledgeable about this - is that JS and others started getting around as fast (in best conditions and a lot of voodoo) as unmanaged C code, but they are still behind in terms of memory footprint. For embedded applications, where you may be forced to count every KB of memory and every CPU cycle, the JITted systems are simply not a good fit right now.
You certainly can write a JavaScript implementation which would work in an embedded environment (just found one: http://www.espruino.com/ http://www.espruino.com/ - it actually looks pretty nice! I wonder how it compares with Arduino?), but, when coughing JavaScript, it most often means "JavaScript as currently implemented in the four most popular implementations" or similar.
So, while it's true that you can write JS code that's 1000s of times more efficient than some bad JavaScript, it's also true that even the good JS is not going to be fast enough for some domains.
This (among others) is where AOT-compiled, GC-less (or with special implementations of those) come in. And even then, there are applications where even the cheap, mostly-compile-time abstractions of such languages prove to be too clunky and you need to drop down to assembly (bootloaders, demos, parts of OSes or language implementations).
So, while you can write efficient JS code, it's not going to be efficient enough for many cases.
- rf15 9y agoYour assessment is definitely sufficiently true, although I would argue that, looking at how v8 essentially increases speed down to just twice the time of a comparable C program (as opposed to a magnitude or two) it is worth the convenience it brings to the table for devs (though c++ 11 and later catch up quite a bit)