Paul Krill
Editor at Large

Cheerp creator: Our C++-to-JavaScript compiler beats Emscripten

news
Feb 3, 20162 mins

Cheerp 1.2 offers speedier compilation with no memory size limitations

conceptual image of hand on keyboard with code raining down from above
Credit: Thinkstock

Cheerp, a C++ compiler that generates JavaScript code for use in any browser, is being upgraded this week with improved performance, reduced output code size, and  backing for 64-bit integers.

Open source Cheerp, from Leaning Technologies, is based on LLVM, which features a set of modular, reusable compiler technologies. Version 1.2, introduced this week, “comes with some big performance improvements, both in execution time and in startup time,” according to a blog post by Leaning Technologies CEO Stefano De Rossi.

Cheerp reached a slowdown of  “only 2 to 6 times compared to native,” while still allowing full dynamic memory management and no memory size limitations, the blog states. “Compared with Emscripten in split memory mode, Cheerp is always as fast but most often 2-3 times faster, has a 10-11 times faster startup, requires no effort from the developer to fine-tune compilation parameters, and allows for real dynamic memory management.” The rival Emscripten compiler, which also leverages LLVM, converts C/C++ code into the Asm.js JavaScript subset.

In addition to native 64-bit integer capabilities, Cheerp 1.2 supports a PreExecuter capability, currently in an experimental state. “The PreExecuter is a technique that converts C++ code used to initialize global structures into simple data,” De Rossi said. “Its main effect is a further reduction of the output JavaScript startup time and a much reduced output code size.”

In an email, De Rossi championed the use of C++ for Web development:

C++ is the world’s most widespread language for medium and large-scale applications, and has been a de facto industry standard for decades. C++ has been and still is used on virtually any available device and platform, and it is very natural to allow developers to use it also for Web applications. Using a C++ to JavaScript compiler allows developers to reuse existing C++ code such as complex, high-performing legacy libraries, to share code between the client and the server when needed, and to make multi-platform applications which can also run on browsers.

Also new in version 1.2 are Runtime Type Information support, dynamic_cast, and covariant return types. “Cheerp now also experimentally supports the module pattern to isolate generated code from other scripts,” De Rossi said.

Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorld’s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorld’s audience of software developers and other information technology professionals. Paul has won a “Best Technology News Coverage” award from IDG.

More from this author