February 18th, 2019: Cheerp 2.0 released. Support for WebAssembly and mixed-mode JavaScript/WebAssembly output. Faster and smaller than Emscripten. Read more!
Cheerp - the C++ compiler for the Web
Cheerp compiles C/C++ into WebAssembly, JavaScript, or a combination, with no-overhead DOM and Web APIs access.
Chosen by:

Why C++?

> write Web applications in type-safe, highly maintenabile C++ code
> use countless C/C++ libraries and frameworks in Web apps
> maintain a single code base for native and browser targets
> reuse code and avoid code duplication
> leverage existing team skills

Why Cheerp?

> open-source C/C++ compiler based on LLVM/Clang standard
> compiles into WebAssembly, JavaScript or a combination
> no-overhead access to HTML5 DOM and WebApis (WebGL, WebAudio)
> faster and smaller output compared to Emscripten*
> can generate fully garbage-collectible JavaScript
> in-browser debugging
> enterprise-grade support, consulting, training and porting services
> a seamless C++ programming experience for the Web
In short, Cheerp is a modern, fast and robust open-source C++ to WebAssembly/JavaScript compiler, battle-tested on tens of millions lines of code and backed by enterprise-grade licensing, support, consulting, training and porting services.


Compile to WebAssembly and JavaScript

Cheerp compiles C/C++ into WebAssembly, JavaScript, or a combination thereof. Cheerp mixed-mode compilation automatically converts a single C++ code base into a combination of WebAssemly and JavaScript based on attribute tags.

This allows to leverage the performance benefit of WebAssembly without sacrificing access to the DOM and Web APIs, as well as dynamic memory and garbage collection that are exclusive to JavaScript.
// This class will be compiled to WebAssembly
class [[cheerp::wasm]] CheerpWasmClass {}

// This class will be compiled to regular JavaScript
class [[cheerp::genericjs]] CheerpJSClass {}

No-overhead access to HTML5 DOM and Web Apis

Cheerp enables no-overhead DOM manipulation and access to any HTML5 API function including WebGL, and WebAudio.
HTMLElement* body=document.get_body();
HTMLElement* newElement=document.createElement("h1");
newElement->set_textContent("Hello World");
With Cheerp, no libraries or wrappers are needed to access the power of HTML5 from C++. Interfaces can be extended to any WebApi through simple header files.

Native memory model in [[cheerp::genericjs]]

Cheerp is the only C++-to-Javascript compiler that enables the native JavaScript object-based memory model without emulation layers.

When Cheerp compiles [[cheerp::genericjs]] classes, C++ objects are mapped directly to JavaScript objects, allowing:

> Dynamic memory allocation

C++ objects are allocated and deallocated when needed, there is no necessity to pre-allocate all the space before to avoid costly reallocation operations.

> No memory limits

Flat memory emulation is limited by the maximum size of JavaScript typed arrays and by the memory size addressable by pointers emulated with 32-bit integers.

This means that, practically speaking, memory-emulating applications are limited to 2 gigabytes of memory, or they have to resort to slow paging emulation techniques.

> Security by design

Buffer-overflow vulnerabilities intrinsically need the flat memory model to exist. With Cheerp, every object is perfectly insulated from the rest of the memory.

Interact with JavaScript

Cheerp allows to use C++ classes from JavaScript code using the [[cheerp::jsexport]] attribute and embed arbitrary JavaScript code in C++ code with the __asm__ keyword.
// C++: Expose the class to JavaScript
class [[cheerp::jsexport]] JsStruct
        float a;
        JsStruct(float _a):a(_a) {}
        void test()
            client::console.log("C++ code is been called!");

// JS: Call methods from your JS code
var testExport = new JsStruct(42.0);
Find out more on this feature here.

In-browser debugging support

Cheerp fully supports the SourceMaps standard, which makes it possible to debug your original C++ code directly in the browser.

Set break points, step the execution and see the original C++ code when an exception happens.

Optimized performances

LLVM provides a bulletproof, state-of-the-art foundation for our compile-to-JavaScript technology.

Your code will pass through the full optimization stack provided by LLVM, plus a few Cheerp specific optimizations.

You write nice, easy to understand and maintain code, Cheerp will take care of generating highly optimized JavaScript from it.

Open-source and commercial licensing

The Cheerp compiler core is distributed as a Free and Open Source Software under the University of Illinois/NCSA Open Source License, the same license the LLVM compiler is distributed under.

The supporting libraries, which need to be linked to applications compiled with Cheerp, are licensed either under the GNU General Public License v2 or under a commercial, non-copyleft proprietary license available for a licensing fee.

Please note that if you use the GPLv2-licensed cheerp libraries for developing commercial applications, you need to comply to the GPLv2 license terms regarding the distribution of you application source code to your users.

If you want to know more about our licensing schemes and pricing, you can visit the pricing section.

Enterprise-grade support and services

In addition to commercial licensing, we offer enterprise-grade support with customizable SLAs and tailored consulting services.

We will adjust our consulting offer based on your company precise needs.

Our services range from basic advice and NDA-bound code review to complete application porting service.

Getting started is easy!

To get started with Cheerp, just follow these 3 easy steps:
  1. Download and install Cheerp for your platform
  2. Follow the tutorial and the browser-side programming guide
  3. Read our Documentation and the DOM API reference
If you need assistance getting up to speed, you can find us on Gitter.