In a channel I frequent someone asked the following question:
This company thats trying to hire me is doing vanilla javascript and jquery. No react, or any other frameworks. JQuery is know for being the hackiest shit and isn't it weird that in 2020 they're still not using anything better? Would you pick up such offer? [1]
This got me thinking: surely, if a company is doing anything in vanilla, it has a good reason for that and it's pretty popular to shove javascript into places that do not make sense to run it. Point of Sale systems, embedded systems, they don't have many resources to spare. As a result you cut every corner possible to get more performance out of the chip you're trying to use. Such thought reminded me of the time when Mark Zuckerberg said that "Facebook wasted too much time trying to implement mobile applications in javascript and HTML5 instead of native" [2]. I can't seem to find the source, but I did hear some rumors that he was promptly proven wrong by some company which knew ins and outs of how javascript works on mobile devices. And that thought caused me to start pondering about the following:
The last question is more of a rhetorical one. But I will appreciate any input.
V8 developer here. As commenters have pointed out, this question is a bit too vague to have a solid answer (and is probably also not really on topic here), but I can offer a few thoughts.
V8 has certain hard requirements, eg:
Aside from that, it's just a question of how fast you want things to be. Platform compatibility requirements aside, almost any software runs on almost any hardware, if you're willing to wait long enough. Ever seen a Raspberry Pi boot a regular Linux distro, or Windows XP on a Pentium-133? It works, but it's slow; There's a reason people spend lots of money on faster hardware ;-)
A few more considerations in this regard:
Speaking of C/C++ vs JavaScript: it's hard to compare. The short answer is that C is faster, but it depends. You can craft microbenchmarks where dynamically compiled code is at an advantage, so JavaScript will be faster. Usually, language features like automatic garbage collection cost a few percent of performance compared to manual memory management. Mitigating the slowness of dynamic languages by JIT-compiling them similarly costs a bit of time, just because it's extra work that the CPU has to do. On sufficiently fast hardware, all these overheads are typically small enough not to matter, but when you're running against the limits of what your hardware can do at all (while still meeting user expectations about performance), then that assessment might change.
This is too many questions in one for a complete answer but.
No V8 can't run on a microcontroller. Maybe a microprocessor. But YES you can run javascript on a microcontroller. Espruino is a great example of that. I don't know about the speed of it but it seems to be capable of filling the hobbyist space for programming microcontrollers. Just as micropython does.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.