[英]Can V8 be installed in an embedded chip?
In a channel I frequent someone asked the following question:在我经常看到的一个频道中,有人问了以下问题:
This company thats trying to hire me is doing vanilla javascript and jquery.这家试图雇用我的公司正在做普通的 javascript 和 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? JQuery 是众所周知的最骇人听闻的狗屎,在 2020 年他们仍然没有使用更好的东西,这不是很奇怪吗? Would you pick up such offer?你会接受这样的提议吗? [1] [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.这让我想到:当然,如果一家公司正在做任何事情,它有一个很好的理由,将 javascript 推到运行它没有意义的地方是很受欢迎的。 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].这样的想法让我想起了马克扎克伯格说过“Facebook浪费了太多时间试图在 javascript 和 HTML5 而不是原生实现移动应用程序”[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.我似乎无法找到消息来源,但我确实听到了一些谣言,说他被一些公司迅速证明是错误的,这些公司了解 javascript 如何在移动设备上工作的来龙去脉。 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. V8 开发人员在这里。 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: V8 有一定的硬性要求,例如:
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?曾经见过 Raspberry Pi 在 Pentium-133 上启动常规 Linux 发行版或 Windows XP 吗? 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.说到 C/C++ 与 JavaScript:很难比较。 The short answer is that C is faster, but it depends.简短的回答是 C 更快,但这取决于。 You can craft microbenchmarks where dynamically compiled code is at an advantage, so JavaScript will be faster.您可以在动态编译代码具有优势的情况下制作微基准,因此 JavaScript 会更快。 Usually, language features like automatic garbage collection cost a few percent of performance compared to manual memory management.通常,与手动 memory 管理相比,自动垃圾收集等语言功能会花费百分之几的性能。 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.通过 JIT 编译来缓解动态语言的缓慢性同样需要花费一些时间,因为这是 CPU 必须做的额外工作。 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.没有 V8 不能在微控制器上运行。 Maybe a microprocessor.也许是微处理器。 But YES you can run javascript on a microcontroller.但是是的,您可以在微控制器上运行 javascript。 Espruino is a great example of that. Espruino就是一个很好的例子。 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.就像 micropython 一样。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.