Experimental JavaScript compiler shakes up ideas about speed, simplicity

Higgs, an experimental JavaScript engine written in D, uses novel approaches to speed up JavaScript -- and could inspire similar projects

An experimental new JavaScript compiler could provide useful lessons for the existing crop of JavaScript engines -- or for as-yet-undeveloped JIT (just-in-time) compilers for other languages.

The Higgs compiler is written in the D language and is available under the BSD license. It was created by Maxime Chevalier-Boisvert as part of her doctoral research work in computer science at the Université de Montréal.

According to Chevalier-Boisvert, Higgs uses an architecture unlike those of other JIT compilers, such as Google's V8 -- the basis for Node.js -- Mozilla's SpiderMonkey, or Apple's LLVM-backed FTLJIT project.

"[Those other engines] are all multitiered architectures," Chevalier-Boisvert said in an email interview. "They incorporate multiple JIT compilers with different levels of optimization. The highest optimization level usually relies on type feedback and type analysis to extract type information. These type analyses can be very expensive in terms of running time and memory usage."

Higgs, by contrast, uses a much smaller and simpler architecture with a single level of optimization and no type analysis as is conventionally implemented. Instead, type information is accumulated as machine-level code and is generated by the compiler.

Chevalier-Boisvert is hopeful that specific innovations in Higgs could find their way into other JavaScript compilers. One such innovation, lazy code generation -- which compiles only the functions that actually run -- already exists in some form in many JITs, but "that too could become more important in future JIT compilers." At this point, Higgs is faster than V8 in certain cases, by Chevalier-Boisvert's own analysis, though it's still slower overall.

Some of Chevalier-Boisvert's work with Higgs in D is reminiscent of an experimental approach Mozilla has been taking. Mozilla's Rust language -- approaching a 1.0 milestone -- is being used to create a new browser engine and JavaScript compiler called Servo that benefits from the safety and inherent parallelism of Rust.

Chevalier-Boisvert was pleased to see new languages with a solid grounding in type theory applied to systems programming for the sake of safety. "C++ is an aging language with many issues," she noted, "and it's good that there are efforts to make a better replacement, such as Rust, D, and Nimrod."

The plan with Higgs is not to explicitly create a replacement for existing JavaScript compiler technologies. Crucial pieces are still missing, said Chevalier-Boisvert, such as a robust garbage collection system. (Note: Higgs is written in D, which has issues with garbage collection that Chevalier-Boisvert has pinpointed in the past.) Rather, Chevalier-Boisvert's stated intention is to stimulate new thinking about how JavaScript compilers can be created. "We're trying something different," she said.

Copyright © 2014 IDG Communications, Inc.

How to choose a low-code development platform