WebAssembly Used by Java-to-Web Compiler CheerpJ 2.0 to Port Java Applications to Browsers

LeaningTech recently released the second major iteration of CheerpJ. CheerpJ 2.0 may convert Java applications into a mix of HTML, WebAssembly and JavaScript, so that developers can run Java applications (including applets) in browsers or integrate Java libraries into web applications. CheerpJ 2.0 uses WebAssembly to improve runtime speed.

By: Bruno Zouriol | InfoQ.

CheerpJ 2.0 provides a full (100% of the Java 8 language), modular, optimized Java 8 SE runtime library in WebAssembly and JavaScript. The runtime is complemented by a collection of browser-based native implementations of different functionalities (e.g. multi-threading with web workers, audio with Web Audio, file system access on top of IndexedDB and more). CheerpJ 2.0 newly leverages WebAssembly runtime modules to improve runtime speed and reduce the size of packages with heavy computational cost (e.g. font rendering).

CheerpJ’s previous versions shipped over 1MB of JavaScript for a simple increment-a-counter application. CheerpJ 2.0 strives to bring the download size down by shipping only the required components of the runtime. However, after accounting for the gain in parsing time for Wasm modules vs. equivalent JavaScript modules, CheerpJ 2.0 applications may still exhibit a perceptible waiting time for users to start using the application. As a result, CheerpJ does not fit all developers’ use cases. In particular, Stefano De Rossi, LeaningTech’s CEO, emphasized one CheerpJ non-goal:

CheerpJ is not intended for writing a web application from scratch (…), We do not see CheerpJ as a Blazor-equivalent for Java (…)

Read the full article here.