Cheerp 2.0RC1 released — C/C++ to WebAssembly, mixed JavaScript/Wasm output, 30–90% smaller than Emscripten

(originally published on November 14, 2017)

We are excited to announce the first public release candidate of Cheerp 2.0, our open-source C/C++ compiler for Web applications! Cheerp 2.0 is by far the most substantial update in terms of both features and performance since our initial stable release Cheerp 1.0.

With this release, we introduce full support for compilation to WebAssembly, as well as for a mixed mode WebAssembly-JavaScript output, allowing to take advantage of the benefits of each compilation mode within different parts of the same C++ codebase. We also introduce a streamlined building flow that allows to generate a WebAssembly binary as well as the required JavaScript loader in one simple command line, making the compilation experience straightforward.

We achieved two key objectives with Cheerp 2.0RC1:

  • Cheerp 2.0 has bridged the performance gap with Emscripten (leveraging WebAssembly), but allows zero-overhead access to the DOM and any Web API (WebGL, WebAudio, etc). Cheerp 2.0 features a new mixed-output mode to combine regular JavaScript output and WebAssembly from one origin C++ code base, enabling to also retain a garbage-collectible output on part of the code.
  • The slowdown compared to a native build when compiling C++ with Cheerp in WebAssembly averages 1.1x (10% slower) on Firefox and 1.5x on Chrome (50% slower). This is approximately twice faster compared to JavaScript on Firefox and 30% faster than JavaScript on Chrome.

Finally, thanks to extensive work on optimisations and our PreExecuter algorithm, the output of Cheerp 2.0-rc1 is on average 30% smaller than Emscripten on large benchmarks and 90% smaller on small benchmarks.

We will be publishing a few blogposts focused on the new features introduced by Cheerp 2.0 in the near future. In this post, we summarise the performance of Cheerp 2.0 and compare it with Emscripten. We also have two new demos upcoming: the porting of a C++ multiplayer videogame in a mix of WebAssembly and JavaScript, and a full Python interpreter and shell in WebAssembly. A tutorial on how to build a mixed WebAssembly and JavaScript output application with Cheerp is available here.

Given the major performance improvements of Cheerp 2.0, and the capacity of generating fully garbage-collectible, dynamic memory JavaScript outputs from C++, we believe that Cheerp is the most advanced, best performing solution to run C/C++ code on the Web, and that it provides a superior alternative to Emscripten, particularly in commercial settings.

New Features of Cheerp 2.0

Cheerp 2.0 introduces support to WebAssembly (as well as asm.js for backward compatibility), in addition to the garbage-collectible JavaScript target that has always been part of Cheerp. In addition, Cheerp 2.0 introduces a new mixed mode, which allows to compile C/C++ to JavaScript, WebAssembly, or a combination of them, from a single code base.

Compared to alternative C++ compilers such as Emscripten, Cheerp has traditionally focussed on allowing C++ to be compiled to an object-based, garbage-collectible JavaScript target which can interact with the DOM and HTML5 APIs in a fully transparent way, with no overhead.

Thanks to the new mixed-output mode, Cheerp 2.0 allows to retain the flexibility and power of the object-based compilation to regular JavaScript, while having access to the raw performance benefit deriving from WebAssembly.

Thanks to a new range of attribute tags (such as [[cheerp::genericjs]] and [[cheerp::wasm]]), Cheerp 2.0 new mixed mode allows to tag specific functions that will be compiled to the specified target, allowing to mix-and-match WebAssembly and JavaScript modes automatically. No tags are required at all if the codebase is wholly compiled to WebAssembly or to JavaScript.

Cheerp 2.0 also introduces a new set of improved optimisation steps, targeting both improved runtime performance as well as reduced output size.

A future blog post will focus on how the new mixed mode C++ compilation to WebAssembly and JavaScript can be leveraged with Cheerp 2.0. A Tutorial is available showing how to create a simple game of Pong in C++, and compile it to a combination of WebAssembly (game logic) and JavaScript (game graphics) with Cheerp 2.0.

Performance Benchmarks

Performance benchmarks are provided for both regular JavaScript target and for WebAssembly. If compiling a large codebase to a combination of the two, the expected performance will fall in the middle depending on the target in which different portions of the code are compiled.

Generally speaking, computationally-intensive parts of the code can be compiled to WebAssembly, whereas sections that benefit highly from dynamic memory allocation or need to interact with JavaScript and the DOM will be compiled in JavaScript.

Performance was evaluated on v8 (git revision 313f8d3f) and SpiderMonkey (hg revision 613f64109bde) engines (used by Chrome and Firefox, respectively).

WebAssembly target

Compared to a native binary build, C++ compiled to WebAssembly and executed on browsers is 1.1x slower (Firefox) and 1.5x slower (Chrome).

Across our test suite, slowdown compared to native ranges from 1x (native speed) to 2.1x, depending on the specific code base. This is approximately twice faster compared to JavaScript on Firefox and 30% faster than JavaScript on Chrome.

This is the performance slowdown to be expected on all portions on code compiled to Wasm, for which platforms restrictions such as static memory allocation and no JavaScript/DOM compatibility are acceptable.

Across all benchmarks, WebAssembly introduces a very significant reduction in output size compared to regular JavaScript. Counting all the components to be downloaded (wasm binary + required JavaScript loader), C++ code compiled to WebAssembly is on average 38% smaller compared to a JavaScript output, thanks to a more compact binary representation and dedicated instruction set.

JavaScript target

Compared to native runtime performance, C++ compiled to regular JavaScript with Cheerp is on average 2.1x slower (Firefox and Chrome). Across our benchmark suite, slowdown compared to native ranges from 1x (same speed as native) to 7x, which means that specific runtime performance compared to native is highly variable and code-base dependent.

This is the performance slowdown to be expected on all portions of code for which it is important to have all the flexibility of the JavaScript output, such as dynamic memory, JavaScript object-based interoperability and DOM manipulation.

Runtime performance is approximately 20% faster than Cheerp 1.3 due to a wealth of optimisations introduced by Cheerp 2.0.

On large-scale benchmarks, Cheerp 2.0 introduces an average 25% size reduction compared to Cheerp 1.3 due to more advanced pre-execution optimisations and further optimisations on code size reduction. A higher reduction can be expected on smaller code bases based on the impact of pre-execution.

Comparing Cheerp 2.0RC1 with Emscripten


Compared to Emscripten, Cheerp 2.0 introduces a new mixed output mode, which allows to combine WebAssembly and JavaScript outputs from an origin C++ codebase, by allowing to tag different sections of the code with specific attributes. Further details on the new mixed mode will be published soon.

When compiling to regular JavaScript, Cheerp 2.0, differently from Emscripten, allows object-based, fully transparent interoperability with JavaScript, as well as DOM manipulation, with no overhead or need for wrapper APIs. Compiling to regular JavaScript also allows to generate fully garbage-collectible, dynamic memory code, which is very beneficial in many applications with high memory pressure.

In addition, JavaScript code generated by Cheerp 2.0 has faster startup time and is significantly smaller in size compared to Emscripten standard asm.js output.

When compiling to WebAssembly, Cheerp 2.0 features custom optimisation passes compared to Emscripten, particularly important being the PreExecuter step. As a result, WebAssembly code generated by Cheerp 2.0 is significantly smaller, and has comparable runtime performance compared to Emscripten.

Performance and Size

The performance of Cheerp on regular JavaScript with dynamic memory and DOM manipulation has always been highly superior to Emscripten, and with further improvements in Cheerp 2.0 this continues to be the case.

Traditionally, Emscripten use of asm.js and static memory meant that code compiled with it would be faster compared with Cheerp. With the introduction of WebAssembly in Cheerp 2.0 and the deprecation of asm.js, there no longer is a performance gap between Cheerp and Emscripten.

Cheerp and Emscripten have essentially equal average performance across our test suite when compiling to WebAssembly.

However, Cheerp 2.0 output is on average 30% smaller compared to Emscripten across the largest benchmarks of our suite, and 90% smaller on small benchmarks.

Getting started with Cheerp 2.0

Cheerp 2.0RC1 (Release Candidate 1) is available to download for Linux, Windows and macOS at

To get started with Cheerp, please visit the main GitHub project page. You will find instructions on how to download, install and use Cheerp, as well as step-by-step tutorials.

A tutorial on how to build a game of Pong application in mixed WebAssembly and JavaScript with Cheerp is available here.


Cheerp 2.0RC1 introduces for the first time support for WebAssembly, as well as to mixing-and-matching different compilation targets on the same origin C++ code base, between JavaScript and WebAssembly.

Cheerp 2.0 allows to take advantage of all the benefits of compiling to regular JavaScript, such as dynamic memory, object-based JavaScript interoperability and DOM manipulation, while allowing to access the performance advantage of compiling to WebAssembly.

As such, Cheerp is the best technology to enable a complex, large-scale codebase to be converted to a Web application, with better performance and fewer limitations compared to alternative technologies.

Official Release — General availability (When?)

We are expecting to release at least a second release candidate for Cheerp 2.0, followed by an official Cheerp 2.0 release currently expected before the end of 2017.

Want to know more?

For more information on how Cheerp can help your organization to leverage your existing C++ code to develop HTML5/JavaScript web-based applications that work on any device, with no need for plug-ins or download, please check out our website at

Follow us on twitter (@leaningtech) and visit to receive all our updates. For additional technical information on Cheerp, please visit our wiki or our tech blog