3 min read

On Tuesday, Fabrice Bellard, the creator of FFmpeg and QEMU and Charlie Gordon, a C expert, announced the first public release of QuickJS. Released under MIT license, it is a “small but complete JavaScript engine” that comes with support for the latest ES2019 language specification.

Features in QuickJS JavaScript engine

  • Small and easily embeddable: The engine is formed by a few C files and does not have any external dependency.
  • Fast interpreter: The interpreter shows impressive speed by running 56,000 tests from the ECMAScript Test Suite1 in just 100 seconds, and that too on a single-core CPU. A runtime instance completes its life cycle in less than 300 microseconds.
  • ES2019 support: The support for ES2019 specification is almost complete including modules, asynchronous generators, and full Annex B support (legacy web compatibility). Currently, it does not has support for realms and tail calls.
  • No external dependency: It can compile JavaScript source to executables without the need for any external dependency.
  • Command-line interpreter: The command-line interpreter comes with contextual colorization and completion implemented in Javascript.
  • Garbage collection: It uses reference counting with cycle removal to free objects automatically and deterministically. This reduces memory usage and ensures deterministic behavior of the JavaScript engine.
  • Mathematical extensions: You can find all the mathematical extensions in the ‘qjsbn’ version, which are fully-backward compatible with standard Javascript. It supports big integers (BigInt), big floating-point numbers (BigFloat), operator overloading, and also comes with ‘bigint’ and ‘math’ mode.

This news struck a discussion on Hacker News, where developers were all praises for Bellard’s and Gordon’s outstanding work on this project. A developer commented, “Wow. The core is a single 1.5MB file that’s very readable, it supports nearly all of the latest standard, and Bellard even added his own extensions on top of that. It has compile-time options for either a NaN-boxing or traditional tagged union object representation, so he didn’t just go for a single minimal implementation (unlike e.g. OTCC) but even had the time and energy to explore a bit. I like the fact that it’s not C99 but appears to be basic C89, meaning very high portability.

Despite my general distaste for JS largely due to websites tending to abuse it more than anything, this project is still immensely impressive and very inspiring, and one wonders whether there is still “space at the bottom” for even smaller but functionality competitive implementations.

Another wrote, “I can’t wait to mess around with this, it looks super cool. I love the minimalist approach. If it’s truly spec compliant, I’ll be using this to compile down a bunch of CLI scripts I’ve written that currently use node.

I tend to stick with the ECMAScript core whenever I can and avoid using packages from NPM, especially ones with binary components. A lot of the time that slows me down a bit because I’m rewriting parts of libraries, but here everything should just work with a little bit of translation for the OS interaction layer which is very exciting.

To know more about QuickJS, check out Fabrice Bellard’s official website.

Read Next

Firefox 67 will come with faster and reliable JavaScript debugging tools

Introducing Node.js 12 with V8 JavaScript engine, improved worker threads, and much more

React Native 0.59 is now out with React Hooks, updated JavaScriptCore, and more!