V8 is, I'm sure, the most used implementation of JavaScript today. Used in Chrome, (and by extension) Microsoft Edge, Node.js, etc. Safari's JavaScriptCore and Firefox's SpiderMonkey are also contenders for extremely mainstream implementations.
But what else is out there? What if I want to embed JavaScript in a C program, or a Go program, or a Rust program, or a Java program(, and so on)? It turns out there are a ton of high-quality implementations out there.
This post describes a number of them and their implementation choices in detail. I'm not going to cover V8, JavaScriptCore, or SpiderMonkey because they are massive and hide multiple various interpreters and compilers inside. Plus, you already know about them.
I'm going to miss some implementations and get some details wrong. Please Tweet or email me with your corrections! I'd be particularly interested to hear about pure-research; and commercial, closed-source implementations of JavaScript.
Corporate-backed
These are implementations that would make sense to look into for your own commercial, production applications.
On the JVM
- Oracle's GraalJS: compiles JavaScript to JVM bytecode or GraalVM
- Support: Full compatibility with latest ECMAScript specification
- Implementation language: Java
- Runtime: GraalVM or stock JDK
- Parser: Hand-written
- First release: 2019?
- Notes: Replaced Nashorn as the default JavaScript implementation in JDK.
- Mozilla's Rhino: interprets and compiles JavaScript to JVM bytecode
- Oracle's Nashorn: compiles JavaScript to JVM bytecode
- Support: ES5
- Implementation language: Java
- Runtime: compiles to JVM bytecode
- Parser: Hand-written
- First release: 2012?
- Notes: Replaced Rhino as default JavaScript implementation on JVM. Replaced by GraalJS more recently, but remains actively developed.
Embeddable
- Nginx's njs
- ChowJS: proprietary AOT compiler based on QuickJS for game developers
- Support: everything QuickJS does presumably (see further down for QuickJS)
- Implementation language: C presumably
- Runtime: QuickJS's bytecode interpreter but also an AOT compiler
- Parser: QuickJS's presumably
- First release: 2021
- Notes: Code is not available so exact analysis on these points is not possible at the moment.
Embedded Systems
Other
Implementations toward the top are more reliable and proven. Implementations toward the bottom less so.
If you are a looking to get involved in language development, the implementation further down on the list can be a great place to start since they typically need work in documentation, testing, and language features.
These last few are not toys but they are also more experimental or, in AssemblyScript's case, not JavaScript.
Research Implementations
- Higgs
- eJS
- Support: Unclear
- Implementation language: Java
- Runtime: Bytecode VM
- Parser: ANTLR
- Notes: eJS is a framework to generate JavaScript VMs that are specialised for applications.
- Jessie: safe subset of JavaScript non-exploitable smart contracts
- https://github.com/b9org/b9
Thanks to @smarr for contributing eJS, Higgs, and b9!
Notable Abandoned
- twostroke
- PyPy-JS
- js.js
- Support: Unclear
- Implementation language: JavaScript
- Runtime: Too scared to look at the gigantic files in this repo.
- Parser: Ditto.
- IronJS
- Support: ES3
- Implementation language: F#
- Runtime: .NET through DLR, I think.
- Parser: Hand-written
- jispy
Notable toy implementations
Great for inspiriration if you've never implemented a language before.
from Hacker News https://ift.tt/3nTGqrI
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.