Today’s web applications are nowhere near as fast and responsive as native desktop applications, but what if they could be? That’s the promise of WebAssembly.WebAssembly is a low-level, assembly-like language with a compact binary format that runs with near-native performance in web browsers. At the same time, WebAssembly provides a portable compilation target for C/C++, C#, Rust, Go, Kotlin, Swift, and other programming languages.Hailed as a way to both improve web application performance and allow languages other than JavaScript to be used in the development of browser apps, WebAssembly is championed by Google, Mozilla, Apple, and Microsoft, all of which support the technology in their browser engines.WebAssembly has led to the development of a range of new technologies, including whole new programming languages, that harness its power. Following are 13 language projects that have made big bets on WebAssembly.BinaryenBinaryen is a compiler toolchain infrastructure library for WebAssembly. Written in C++, Binaryen is intended to make compiling to WebAssembly easy, effective, and fast. It has a C API in a single header, and it can be used from JavaScript. Input is accepted in WebAssembly-like form but a general control graph also is accepted for compilers that prefer it.The internal IR (intermediate representation) of Binaryen uses compact data structures and draws on all CPU cores for parallel codegen and optimization. The IR also compiles down to WebAssembly easily because it is essentially a subset of WebAssembly. WebAssembly-specific optimzations improve both code size and speed, making Binaryen useful as a compiler back end by itself. You can download Binaryen from GitHub.Blazor WebAssemblyBlazor WebAssembly is a framework for building interactive, client-side, single-page web apps using .NET, and hosting those apps in modern browsers (including mobile browsers) on a WebAssembly-based .NET runtime. No plug-ins or recompiling of code into other languages is required. The runtime enables the .NET code to access browser functionality via WebAssembly’s JavaScript APIs. When a Blazor WebAssembly app is run in the browser, C# code files and Razor files are compiled into .NET assemblies, which are downloaded to the browser along with the .NET runtime. And because the .NET code is executed on WebAssembly in the browser’s JavaScript sandbox, it is protected against malicious actions on the client machine. Blazor WebAssembly apps can be deployed standalone or with server-side support.Instructions for getting started with Blazor can be found at dotnet.microsoft.com.CheerpLeaning Technologies’ Cheerp is positioned as an enterprise-grade C/C++ compiler for the web, compiling C and C++, up to C++ 17, into WebAssembly, JavaScript, or a combination of the two. Cheerp is integrated into LLVM/Clang infrastructure, with custom optimizations intended to improve performance and minimize the size of the compiled output. Primarily used to port existing C/C++ libraries and applications to HTML5, Cheerp also can be used to write web applications and WebAssembly components. Cheerp is offered under open source and commercial licenses.You can download Cheerp from leaningtech.com. CheerpJBilled as “the Java compiler for the web,” this LLVM-based compiler converts any Java client application into WebAssembly, JavaScript, and HTML, enabling Java client applications to run in modern browsers. CheerpJ leverages three components: an AOT (ahead-of-time) compiler, a runtime in WebAssembly and JavaScript, and JavaScript DOM interoperability APIs, to access the DOM from Java. With CheerpJ, JAR archives can be compiled using the AOT compiler. CheerpJ does not require any server-side support.Like Cheerp, CheerpJ comes from Leaning Technologies. You can download it from leaningtech.com.[ Also on InfoWorld: What is LLVM? The power behind Swift, Rust, Clang, and more ]EmscriptenThis open source compiler toolchain compiles C and C++, or any other language using LLVM compiler technology, into WebAssembly for deployment on the web, Node.js, or a Wasm runtime such as Wasmer. (The Emscripten compiler, emcc, also emits JavaScript that provides API support to the compiled code. Emscripten has been used to convert a list of real-world codebases into WebAssembly, including commercial codebases such as the Unreal Engine 4 game engine and Unity 3D platform. Emscripten supports the C and C++ standard libraries, C++ exceptions, and OpenGL/WebGL graphics commands. The Emscripten SDK used to install the Emscripten toolchain (emcc, LLVM, etc.) can be used on Linux, MacOS, and Windows. You can download Emscripten from emscripten.org.ForestForest is a functional programming language that compiles to WebAssembly. The goal behind Forest is to provide a language that makes it easier to create web apps that are complex, interactive, and functional, but without the traditional overhead of that approach, developer Nick Johnstone said.Currently described as “pre-alpha, experimental, conceptual research software,” Forest features static typing, pattern matching, immutable data structures, multiple syntaxes, and automatic code formatting. The first syntax in development is inspired by Elm and Haskell.Design principles of the Forest language include ease of collaboration, painless-as-possible testing, and agreement on structure and semantics, while agreeing to disagree on syntax. Johnstone strives to make Forest fast enough for building complex games so that normal web apps will be “blazing fast.”You can download Forest from GitHub.GrainThe Grain language brings features from academic and functional languages to the 21st century, the project website states. Compiling to WebAssembly via the Binaryen toolchain and compiler infrastructure, Grain can run in the browser, on the server, and potentially anywhere. There are no runtime type errors and no need for type annotations. The Grain toolchain features a CLI, compiler, runtime, and standard library, shipping as a single binary. Developers will need Node.js and Yarn to build Grain from source, and binaries are available for Linux, MacOS, and Windows. You can find instructions for getting started with Grain at grain-lang.org.JWebAssemblyJWebAssembly, from I-Net Software, is a Java bytecode to WebAssembly compiler that takes Java class files as input and generates WebAssembly binary format (.wasm file) or text format (.wat file) as output. The target is to run natively in the browser with WebAssembly. In theory, JWebAssembly can compile any language that compiles to Java bytecode such as Clojure, Groovy, JRuby, Kotlin, and Scala, pending testing.JWebAssembly should be production-ready soon. All of the milestones necessary for the JWebAssembly 1.0 release have been implemented, and a release candidate has been published. The version 1.0 roadmap calls for capabilities such as a Java bytecode parser, a test framework, and a Gradle plug-in.You can download JWebAssembly from GitHub.PyodideThe Pyodide project, which recently moved from Mozilla to become an independent project, compiles Python and the Python scientific stack to WebAssembly, bringing the Python 3.8 runtime, NumPy, SciPy, Matplotlib, Scikit-learn, and dozens of other packages to the browser. Pyodide provides transparent conversion of objects between JavaScript and Python, and gives Python access to web APIs. Pyodide began in 2018 as part of the Iodide project for doing data science in a browser. Pyodide can be tried from a REPL in the browser.You can find instructions for downloading and using Pyodide at pyodide.org.SpinSpin, from cloud computing software provider Fermyon Technologies, is a WebAssembly framework for microservices, web apps, and other server-based applications. Developers can use Spin to write WebAssembly for the cloud. Interfaces are provided for writing WebAssembly modules for functions such as answering HTTP requests. With Spin, developers can use languages including Rust, Go, Python, Ruby, AssemblyScript, Grain, C/C++, and others. Spin supports WAGI (WebAssembly Gateway Interface) modules and the Bindle packaging system. Now in an early preview phase, Spin is considered experimental code, with breaking changes expected before the first stable release. Spin is hosted on GitHub.TeaVMAn ahead-of-time compiler for Java bytecode, TeaVM emits WebAssembly and JavaScript to run in the browser. However, note that WebAssembly support is currently experimental. Like close cousin GWT (Google Web Toolkit), TeaVM allows developers to write applications in Java and deploy them as JavaScript. Unlike GWT, TeaVM works with compiled class files, not source code. In addition, TeaVM relies on existing compilers such as javac, kotlinc, and scalac, so can compile Kotlin and Scala code as well as Java. TeaVM is primarily a web development tool; it’s not designed for taking large codebases in Java or Kotlin and producing JavaScript. A TeaVM subproject, Flavour, serves as a framework for writing single-page web applications.You can find instructions for downloading and using TeaVM on GitHub.Uno PlatformAn alternative to the Xamarin mobile app platform, Uno Platform is a UI platform for .NET teams to build single-codebase applications for WebAssembly, the web, Windows, MacOS, Linux, iOS, and Android, using C# and XAML. Uno leverages the Mono-WASM runtime in .NET 5 to run C# code in all of the major web browsers, and serves as a bridge for WinUI and UWP (Universal Windows Platform) apps to run natively on WebAssembly. For building web apps with Uno, developers can use Visual Studio or Visual Studio Code.Directions on getting started can be found on the Uno Platform website.WasmcloudFrom Cosmonic, Wasmcloud is an application runtime that leverages WebAssembly in the development of composable, portable applications that plug into multi-cloud, edge, and browser environments. The technology is billed as offering near-native performance, with security provided via a WebAssembly sandbox and an actor model separating business logic from specific underlying capabilities. Developers can write microservices once in the language of their choice and deploy them everywhere. Current languages supported include Rust, TinyGo, and AssemblyScript. Wasmcloud has been accepted as a Cloud Native Computing Foundation (CNCF) Sandbox project.Installation instructions for wasmCloud can be found at wasmcloud.dev.
Copyright © 2022 IDG Communications, Inc.
Source link