Hacker News 中文摘要

RSS订阅

JavaScript引擎动物园——全面对比各款引擎 -- JavaScript engines zoo – Compare every JavaScript engine

文章摘要

这篇文章简要介绍了多个主流JavaScript引擎的技术参数和背景,包括Safari/WebKit的JavaScriptCore、Chrome和Node.js使用的V8、微软Edge Legacy的Chakra、JVM/GraalVM的高性能引擎GraalJS、Firefox的SpiderMonkey以及JDK 8-14使用的Nashorn等。内容涵盖了各引擎的开发语言、发布时间、ECMAScript支持程度、开源协议等关键信息。

文章总结

JavaScript引擎动物园

本文汇总了当前主流及历史性的JavaScript引擎信息,涵盖开源与闭源项目,按代码库活跃度排序呈现关键数据。

核心引擎

  1. JavaScriptCore

    • 归属:Apple
    • 应用:Safari/WebKit内核
    • 特性:支持ESnext,LGPL-2.0协议,代码库28MB
  2. V8

    • 归属:Google
    • 应用:Chrome/Node.js
    • 特性:ESnext兼容,BSD-3协议,含JIT优化
  3. ChakraCore

    • 归属:Microsoft
    • 应用:旧版Edge
    • 特性:ES2019支持,MIT协议

新兴引擎

  • GraalJS:Oracle推出的JVM高性能引擎,支持GraalVM
  • Hermes:Facebook为React Native优化的AOT引擎
  • QuickJS:轻量级嵌入式引擎,MIT协议

特殊场景引擎

  • Duktape:面向微控制器的嵌入式引擎(1.1MB)
  • Espruino:物联网专用引擎(MPL-2.0协议)
  • Goja:纯Go实现的ES5兼容引擎

历史引擎

  • Netscape Navigator 2.0引擎:史上首个JS引擎(1995年)
  • Rhino:Mozilla的Java平台引擎(JDK 6-7内置)
  • KJS:KDE Konqueror的原始引擎(1998年)

语言实现

  • Rust:Boajs、Spidermonkey移植版
  • Python:PyPy的JS解释器
  • .NET:多个C#实现(如Jint、ClearScript)

注:部分引擎已停止维护(如Edge旧版Chakra),部分为实验性项目(如Rust编写的Boajs)。完整数据可参考原站统计图表。

(注:原文中大量数字指标为代码库统计信息,此处保留核心参数,省略冗余数据。)

评论总结

以下是评论内容的总结:

  1. 对JavaScript引擎性能的惊讶

    • 用户对JavaScriptCore持续优于V8表示惊讶,并认为SpiderMonkey表现不佳
      "This is super cool, I didn't know JavaScriptCore consistently outperformed V8"
      "SpiderMonkey seems... not up there compared to the other 2"
  2. 对Brimstone项目的赞赏

    • 用户惊叹于Brimstone仅由单人开发,代码量少但ES6兼容性高
      "That's a staggering accomplishment"
      "74k LoC (vs 1.3M for V8) and it's 97% compatible with ES6"
  3. 对引擎多样性的关注

    • 用户对引擎数量之多表示惊讶,赞赏比较工作的全面性
      "I never thought they are so many!"
      "Seeing the actual comparison is astounding!"
  4. 对内存使用和基准测试的疑问

    • 用户希望看到内存使用比较,质疑某些引擎是否为了性能牺牲内存
      "Is there any benchmarks between engines that record memory usage?"
      "How many of these engines are chasing benchmarks at the cost of increased memory usage?"
  5. 对安全沙箱的需求

    • 用户表达对可靠JavaScript沙箱解决方案的需求,对现有项目维护状况表示担忧
      "it's still remarkably hard to find a robust solution for executing JavaScript from untrusted sources"
      "I want my sandbox to be backed by a large, well funded security team"
  6. 对特定引擎性能的关注

    • 用户注意到SpiderMonkey旧版本在某些方面优于新版本
      "SpiderMonkey 24 from 2013 outperforms 147alpha by ~2000 pts"
      "having 1/4 LOC, 1/3 binary size and almost 1:1 on other metrics"
  7. 对未来发展的期待

    • 用户对Meta的Static Hermes引擎在Apple Silicon上的表现表示期待
      "outperforms both V8 and JSCore on Apple Silicon"
      "It'll be interesting to see how much it will affect React Native apps"