Today we are very proud to announce Cheerp 3.0, the latest major release of our C++ compiler for the Web.
More than a year has passed since the previous release of Cheerp (Cheerp 2.7), and this new version is packed with new features and optimizations that, once more, move the state of the art of using C++ as a programming language for Web applications and games.
Most importantly, with this release we are making a significant change to the licensing model of Cheerp. Starting from Cheerp 3.0, all the compiler core components and libraries are now licensed permissively under the Apache 2.0 / LLVM license. This marks a radical departure from our previous GPLv2 / dual commercial licensing model, allowing for Cheerp 3.0 to be used for any purpose, with no restrictions.
Why are we changing the license of Cheerp?
Since its release in 2014 Cheerp has been licensed under a dual licensing scheme: GPLv2 for non-commercial users, and a proprietary license for anybody not willing to comply with GPLv2 terms.
For us at Leaning Technologies, this has always represented a less than ideal,but necessary choice. As a bootstrapped company with no external capital, we felt that dual licensing was the only way to monetize the tool, even if that came at the expense of a wider community adoption.
A lot has happened since 2014: we have grown significantly and released multiple products ( CheerpJ, CheerpX for Flash and WebVM). We are in a very different place financially and in terms of maturity. During this time, Cheerp remained the cornerstone of all our technologies. Everything that we make at Leaning Technologies is written in C++ and compiled with Cheerp, and it would not have been possible otherwise.
Having reflected on what role we want to play in the WebAssembly ecosystem, we realized that now is the right time to change gears, and prioritize a wider adoption of this tool. By relicensing it to a permissive liberal license we hope to remove any barrier to the adoption of Cheerp, which can now be used by anybody with ‘no strings attached’.
What makes Cheerp unique?
Cheerp is a compiler designed to make C++ a first class language for Web programming.
To achieve this, it has several unique features and optimizations:
- A state-of-the-art WebAssembly backend: This is expected by a modern C++ compiler that can target the Web. Cheerp generates extremely high quality WebAssembly code in one step, with no post-processing required (e.g. Binaryen wasm-opt). Cheerp supports post-MVP features of WebAssembly including tail calls, SIMD and externrefs. All these features can be selectively enabled using the -cheerp-wasm-enable= command line flag to make sure you can target as many browsers as possible depending on your requirements.
- Advanced optimizations to reduce code size: Cheerp heavily takes advantage of whole program optimization techniques. We have developed advanced optimization such as PreExecuter (convert global C++ constructors to constants), PartialExecuter (remove code that can be proven to never be run based on partial knowledge of function parameters), and a sophisticated devirtualizer. All of these contribute to a significant reduction in code size.
How does Cheerp compare to Emscripten?
Both Cheerp and Emscripten are based on the industry standard LLVM/Clang infrastructure, and, fundamentally, do the same thing: compiling C++ code into something that can run in the browser.
At a high level, the main difference between the two tools is a matter of philosophy. Emscripten has a strong focus towards converting whole C++ applications to WebAssembly so they can run on the browser. Conversely, Cheerp focuses on allowing existing C++ code to be used as part of a new, Web-native user experience. This is what almost all of our customers actually required for their use cases.
On the technical side, the main differences are about how intermediate outputs are represented and how linking happens. Emscripten uses by default WebAssembly as the object format, the various files are then linked and optimized in post-processing by wasm-opt (part of binaryen).
We routinely benchmark Cheerp against the Emscripten test suite. The results reflect the aforementioned differences in approach. In terms of output size, thanks to LLVM level whole program optimization and our custom passes, Cheerp normally achieves better results across the board, with an average 7% smaller build size.
Output size benchmarks, lower is better. Data available here.
The only significant missing feature in Cheerp 3.0 is support WebAssembly atomics and multithreading, but we are currently working on this feature and we expect this last gap to be filled over the next few months with the release of Cheerp 3.1.
It should be noted that the use of multithreading in browsers currently requires jumping through more than a few hoops to enable SharedArrayBuffer (i.e. COEP/COOP/CORP headers for cross-origin isolations). These hoops can become real limitations to load third-party resources, which is not uncommon in Web applications. This means that, in practice, it might be wise not to depend on multithreading unless you really need the feature.
Give Cheerp a try!
Cheerp has been used to build a lot of amazing products, including all of Leaning Technologies’ tools (e.g. WebVM, a x86 virtual machine running in the browser at high performance).
The question is, what will you build with Cheerp?
If you are unsure where to start, check out the Cheerp documentation.
For further support make sure to join our Discord: https://discord.leaningtech.com, where you will find Leaning Technologies core developers, including myself. We are always happy to help!
We hope you will enjoy using Cheerp, see you soon!