Emscripten

Last updated
Emscripten
Original author(s) Alon Zakai
Stable release
3.1.56 [1]   OOjs UI icon edit-ltr-progressive.svg / 14 March 2024;14 days ago (14 March 2024)
Repository
Written in C, C++, JavaScript [2]
Type Compiler
License MIT License, University of Illinois/NCSA Open Source License
Website emscripten.org   OOjs UI icon edit-ltr-progressive.svg

Emscripten is an LLVM/Clang-based compiler that compiles C and C++ source code to WebAssembly [3] (or to a subset of JavaScript known as asm.js, [4] its original compilation target before the advent of WebAssembly in 2017), primarily for execution in web browsers.

Contents

Emscripten allows applications and libraries written in C or C++ to be compiled ahead of time and run efficiently in web browsers, typically at speeds comparable to or faster than interpreted or dynamically compiled JavaScript. It even emulates an entire POSIX operating system, enabling programmers to use functions from the C standard library (libc). [5]

With the more recent development of the WebAssembly System Interface (WASI) [6] and WebAssembly runtimes such as Node.js, Wasmtime, [7] and Wasmer, [8] Emscripten can also be used to compile to WebAssembly for execution in non-Web embeddings as well.

Usage

Emscripten has been used to port a number of C/C++ code bases to WebAssembly, including Unreal Engine 3, SQLite, [9] MeshLab, [10] Bullet physics, [11] AutoCAD, [12] and a subset of the Qt application framework. [13] Other examples of software ported to WebAssembly via Emscripten include the following:

Game engines

The Unity, Defold, and Godot game engines provide an export option to HTML5, utilizing Emscripten. [14] [15] [16] The Unreal Engine had this export option but it has been migrated out of the engine to a community member plug in. [17]

Frameworks & toolkits

openFrameworks exports native C++ applications to HTML5 via Emscripten. [18] emscripten-qt permits compiling applications written using the Qt application framework to WebAssembly. [13]

Software archiving

In December 2014, the Internet Archive launched a DOSBox emulator compiled in Emscripten to provide browser-based access to thousands of archived MS-DOS and PC programs. [19] [20] [21]

See also

Related Research Articles

<span class="mw-page-title-main">Adobe Flash</span> Deprecated multimedia platform used to add animation and interactivity to websites

Adobe Flash is a deprecated multimedia software platform used for production of animations, rich internet applications, desktop applications, mobile apps, mobile games, and embedded web browser video players.

In computing, cross-platform software is computer software that is designed to work in several computing platforms. Some cross-platform software requires a separate build for each platform, but some can be directly run on any platform without special preparation, being written in an interpreted language or compiled to portable bytecode for which the interpreters or run-time packages are common or standard components of all supported platforms.

<span class="mw-page-title-main">SpiderMonkey</span> JavaScript and WebAssembly engine maintained by the Mozilla Foundation

SpiderMonkey is an open-source JavaScript and WebAssembly engine by the Mozilla Foundation.

WebKit is a browser engine developed by Apple and primarily used in its Safari web browser, as well as all web browsers on iOS and iPadOS. WebKit is also used by the PlayStation consoles starting with the PS3, the Tizen mobile operating systems, the Amazon Kindle e-book reader, Nintendo consoles starting with the 3DS Internet Browser, and the discontinued BlackBerry Browser. WebKit's C++ application programming interface (API) provides a set of classes to display Web content in windows, and implements browser features such as following links when clicked by the user, managing a back-forward list, and managing a history of pages recently visited.

A user interface markup language is a markup language that renders and describes graphical user interfaces and controls. Many of these markup languages are dialects of XML and are dependent upon a pre-existing scripting language engine, usually a JavaScript engine, for rendering of controls and extra scriptability.

Netscape Plugin Application Programming Interface (NPAPI) is a deprecated application programming interface (API) for web browser plugins, initially developed for Netscape Navigator 2.0 in 1995 and subsequently adopted by other browsers.

<span class="mw-page-title-main">Google Web Toolkit</span> Free Java library

Google Web Toolkit, or GWT Web Toolkit, is an open-source set of tools that allows web developers to create and maintain JavaScript front-end applications in Java. It is licensed under Apache License 2.0.

V8 is a JavaScript and WebAssembly engine developed by Google for its Chrome browser. V8 is free and open-source software that is part of the Chromium project and also used separately in non-browser contexts, notably the Node.js runtime system.

<span class="mw-page-title-main">Node.js</span> JavaScript runtime environment

Node.js is a cross-platform, open-source JavaScript runtime environment that can run on Windows, Linux, Unix, macOS, and more. Node.js runs on the V8 JavaScript engine, and executes JavaScript code outside a web browser.

A lightweight web browser is a web browser that sacrifices some of the features of a mainstream web browser in order to reduce the consumption of system resources, and especially to minimize the memory footprint.

<span class="mw-page-title-main">Chromium Embedded Framework</span> Free and open-source software framework

The Chromium Embedded Framework (CEF) is an open-source software framework for embedding a Chromium web browser within another application. This enables developers to add web browsing functionality to their application, as well as the ability to use HTML, CSS, and JavaScript to create the application's user interface.

asm.js is a subset of JavaScript designed to allow computer software written in languages such as C to be run as web applications while maintaining performance characteristics considerably better than standard JavaScript, which is the typical language used for such applications.

<span class="mw-page-title-main">WinJS</span> Open-source JavaScript library

The Windows Library for JavaScript is an open-source JavaScript library developed by Microsoft. It has been designed with the primary goal of easing development of Windows Store apps for Windows 8 and Windows 10, as well as Windows Phone apps for Windows Phone 8.1, Windows 10 Mobile and Xbox One applications using HTML5 and JavaScript, as an alternative to using WinRT XAML and C#, VB.NET or C++ (CX).

<span class="mw-page-title-main">WebAssembly</span> Cross-platform assembly language and bytecode designed for execution in web browsers

WebAssembly defines a portable binary-code format and a corresponding text format for executable programs as well as software interfaces for facilitating interactions between such programs and their host environment.

<span class="mw-page-title-main">Electron (software framework)</span> Development framework built on Chromium

Electron is a free and open-source software framework developed and maintained by OpenJS Foundation. The framework is designed to create desktop applications using web technologies that are rendered using a version of the Chromium browser engine and a back end using the Node.js runtime environment. It also uses various APIs to enable functionality such as native integration with Node.js services and an inter-process communication module.

<span class="mw-page-title-main">Phaser (game framework)</span> Cross-platform JavaScript video game framework

Phaser is a 2D game framework used for making HTML5 games for desktop and mobile. It is free software developed by Photon Storm.

<span class="mw-page-title-main">Deno (software)</span> Secure JavaScript and TypeScript runtime

Deno is a runtime for JavaScript, TypeScript, and WebAssembly that is based on the V8 JavaScript engine and the Rust programming language. Deno was co-created by Ryan Dahl, who also created Node.js.

<span class="mw-page-title-main">AssemblyScript</span> Programming language, variant of TypeScript that compiles to WebAssembly

AssemblyScript is a TypeScript-based programming language that is optimized for, and statically compiled to, WebAssembly. Resembling ECMAScript and JavaScript, but with static types, the language is developed by the AssemblyScript Project with contributions from the AssemblyScript community.

References

  1. "Release 3.1.56". 14 March 2024. Retrieved 22 March 2024.
  2. "emscripten-core/emscripten: Emscripten: An LLVM-to-JavaScript Compiler". GitHub . C: 40.0%; C++: 34.4%; JavaScript: 17.4%.
  3. WebAssembly · emscripten-core/emscripten Wiki · GitHub
  4. Walton, Zach (2012-04-04). "Easily Port C++ To HTML5/JavaScript With Emscripten". WebProNews. iEntry Network. Archived from the original on 2013-07-30. Retrieved 2012-04-25.
  5. Clark, Lin. "Standardizing WASI: A system interface to run WebAssembly outside the web – Mozilla Hacks - the Web developer blog". Mozilla Hacks – the Web developer blog. Mozilla. Retrieved 31 October 2022.
  6. The Wasmtime Project. "WASI: The WebAssembly System Interface". WASI.dev. The Wasmtime Project. Retrieved 2021-02-10.
  7. The Wasmtime Project. "Wasmtime: A small and efficient runtime for WebAssembly & WASI". Wasmtime.dev. The Wasmtime Project. Retrieved 2021-02-10.
  8. Wasmer. "Wasmer: The Universal WebAssembly Runtime". Wasmer.io. Wasmer. Retrieved 2021-02-10.
  9. "sqlite3 WebAssembly & JavaScript Documentation Index". SQLite. Retrieved 2023-05-08.
  10. http://www.meshlabjs.net - Homepage of the experimental, client based, javascript, version of MeshLab that runs inside a browser
  11. "Porting Examples and Demos". Emscripten GitHub wiki. Retrieved 2016-03-01.
  12. "The Future of AutoCAD". Through the Interface. Retrieved 2018-05-09..
  13. 1 2 "Qt for WebAssembly".
  14. "Unity game engine heading to the browser without plug-ins". Ars Technica. 18 March 2014. Retrieved 2016-03-01.
  15. "The future of scripting in Unity – Unity Blog". Unity Technologies Blog. Retrieved 2016-03-01.
  16. "Defold HTML Development". Defold Documentation. Retrieved 2023-12-18.
  17. "Developing HTML5 with Unreal". Unreal Documentation. 18 December 2023. Retrieved 2018-12-18.
  18. "openFrameworks setup for Emscripten". openFrameworks. Retrieved 2016-03-04.
  19. Ohlheiser, Abby (2015-01-05). "You can now play nearly 2,400 MS-DOS video games in your browser". The Washington Post . Retrieved 2015-01-08.
  20. Each New Boot a Miracle by Jason Scott (December 23, 2014)
  21. "Internet Archive Search: "collection:softwarelibrary_msdos"". archive.org. Retrieved 2016-03-01.