17.12.2020 - Carlo Piovesan
Today we are releasing Cheerp 2.6, the latest major release of Cheerp , with plenty of new optimizations and features, and full backwards compatibility.
This post introduces Cheerp, its features, and the problems that can be solved thanks to this tool.
The intended workflow of Cheerp usually looks like this:
- You go through the codebase, and tag the relevant APIs that you need exported to HTML5;
- You serve the .js and .wasm files on an HTTP server, alongside the rest of your HTML5 application, all to be executed by the browser client-side;
- If you need to change or add functionality to the component, you edit the C/C++ source;
- Go back to step 3: compile your code, serve it, and iterate.
Compatibility and Safety
The execution is fully local to the user device, meaning that once the static assets are served, no data transmission is required except if inherent part of the application, enhancing the privacy/security model, and the responsiveness.
The universality of the web browser as an execution target allows you to simplify delivery of your solutions, complementing or substituting install-based solutions or server-based solutions.
Use case: HomebyMe
A client we are very proud to work with is 3DVia — a brand of Dassault Systèmes . You can try out their fully client-side 3D home design CAD directly from your own browser visiting: https://home.by.me/en/.
Behind this product there is a complex C++ codebase that has been moved to the Web thanks to the Cheerp compiler.
Now whenever a new feature is added to their codebase, they just have to recompile for all their supported architectures and serve the resulting files. This allows them to offer a more responsive and easier to manage cross platform solution to 3D CAD.
home.by.me , by 3DVia
- tagging classes, namespaces or free functions with
- declaring functions and classes in the namespace client , or
In all cases the codebase will expressively encode this information (as opposed to having to provide external configuration files or compile time variables).
Cheerp 101: state-of-the-art WebAssembly code generationCheerp 101: state-of-the-art WebAssembly code generation
This means that all the tools have to proceed only with partial information, and are therefore unable to perform some link time optimizations.
Cheerp 101: custom IR optimizations
When you invoke the Cheerp compiler, the code is first translated from C/C++ to an Internal Representation (IR) that stores all information to be transformed and optimized.
Cheerp 101: usability
Either from supporting our clients, or from extensively using it internally, we have plenty of experience with Cheerp, and we found that the best way to help ourselves and other developers is having a tool that’s easy to use right and strengthen development.
We worked on ensuring that builds are deterministic, that Cheerp provides meaningful warnings and errors, and that there are no breaking changes between versions, allowing compilation pipelines to cope easily with upgrades in the compiler.
There are still plenty of features we look forward to add in this area, and we look forward to feedback.
Cheerp 101: opt-in post-MVP WebAssembly standards
By default, Cheerp generates standard, widely available WebAssembly, but it also allows to opt-in for targeting more powerful post-MVP instruction sets.
In particular Cheerp can generate ExternRef , use BigInts at the Wasm-JS interface, and tail calls. We are also collaborating to standardize branch hints , which we believe will help browsers’s code generation (that implies performances gains).
How do I try it?
How to upgrade your project to Cheerp 2.6
Cheerp is fully backward compatible with its previous versions, but intermediate compilation artifacts might not be, so it should just be a matter of going to your Cheerp build folder and running:
make clean && make && make install
You should now experience a smaller footprint and improved performance without any change required neither on your codebase nor in the way your code is built or integrated.
You can also now enjoy the newer JSExport capabilities, we recommend to start from the main article about it [ link ].
Use cases: CheerpJ and CheerpX
Cheerp is also the cornerstone of two other tools developed at Leaning Technologies :
- CheerpX , an extremely efficient solution to run unmodified x86 binaries in the browser thanks to a fast JIT that generates Wasm modules at runtime.
CheerpJ (for Java), Cheerp (for C++), CheerpX (for x86 and Flash)
With Cheerp 2.6, we deliver a mature tool that allows to unlock your C++ code bases and bring them to the Web. Update your Cheerp version, or try it for the first time getting started on our documentation .