Emscripten

{{Short description|Program converting LLVM bytecode to WebAssembly}}

{{Infobox software

| name = Emscripten

| title = Emscripten

| logo = Emscripten logo.svg

| logo caption =

| screenshot =

| caption =

| collapsible =

| author = Alon Zakai

| released = {{Start date|2011|10|22|df=yes}}{{cite book |chapter-url=https://dl.acm.org/doi/10.1145/2048147.2048224 |title=Proceedings of the ACM international conference companion on Object oriented programming systems languages and applications companion |publisher=OOPSLA |author1=Zakai,Alon |chapter=Emscripten: An LLVM-to-JavaScript compiler |date=22 October 2011 |pages=301–312 |doi=10.1145/2048147.2048224 |isbn=978-1-4503-0942-4 }}

| discontinued =

| latest release version = {{wikidata|property|preferred|references|edit|P348|P548=Q2804309}}

| latest release date = {{Start date and age|{{wikidata|qualifier|preferred|single|P348|P548=Q2804309|P577}}|df=yes}}

| latest preview version =

| latest preview date =

| status =

| programming language = C, C++, JavaScript{{cite web |url=https://github.com/emscripten-core/emscripten/releases |title=emscripten-core/emscripten: Emscripten: An LLVM-to-JavaScript Compiler |website=GitHub |quote=C: 40.0%; C++: 34.4%; JavaScript: 17.4%.}}

| operating system =

| platform =

| size =

| genre = Compiler

| license = MIT License, University of Illinois/NCSA Open Source License

| alexa =

}}

Emscripten is an LLVM/Clang-based compiler that compiles C and C++ source code to WebAssembly,[https://github.com/kripken/emscripten/wiki/WebAssembly WebAssembly · emscripten-core/emscripten Wiki · GitHub] primarily for execution in web browsers.

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).{{cite web |last1=Clark |first1=Lin |title=Standardizing WASI: A system interface to run WebAssembly outside the web – Mozilla Hacks - the Web developer blog |url=https://hacks.mozilla.org/2019/03/standardizing-wasi-a-webassembly-system-interface/ |website=Mozilla Hacks – the Web developer blog |publisher=Mozilla |access-date=31 October 2022}}

With the more recent development of the WebAssembly System Interface (WASI){{cite web|url=https://wasi.dev/|title=WASI: The WebAssembly System Interface|author=The Wasmtime Project|website=WASI.dev|publisher=The Wasmtime Project|access-date=2021-02-10}} and WebAssembly runtimes such as Node.js, Wasmtime,{{cite web|url=https://wasmtime.dev/|title=Wasmtime: A small and efficient runtime for WebAssembly & WASI|author=The Wasmtime Project|website=Wasmtime.dev|publisher=The Wasmtime Project|access-date=2021-02-10}} and Wasmer,{{cite web|url=https://wasmer.io/|title=Wasmer: The Universal WebAssembly Runtime|author=Wasmer|website=Wasmer.io|publisher=Wasmer|access-date=2021-02-10}} 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,{{Cite web

| url = https://sqlite.org/wasm

| title = sqlite3 WebAssembly & JavaScript Documentation Index

| website = SQLite

| access-date = 2023-05-08

}} MeshLab,http://www.meshlabjs.net - Homepage of the experimental, client based, javascript, version of MeshLab that runs inside a browser Bullet physics,{{Cite web

| url = https://github.com/emscripten-core/emscripten/wiki/Porting-Examples-and-Demos

| title = Porting Examples and Demos

| website = Emscripten GitHub wiki

| access-date = 2016-03-01

}} AutoCAD,{{Cite web

| url = http://through-the-interface.typepad.com/through_the_interface/2018/03/the-future-of-autocad.html

| title = The Future of AutoCAD

| website = Through the Interface

| access-date = 2018-05-09

}}. and a subset of the Qt application framework.{{Cite web|url=https://doc.qt.io/qt-5/wasm.html|title=Qt for WebAssembly}} 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.{{Cite web

| url = https://arstechnica.com/gadgets/2014/03/unity-game-engine-heading-to-the-browser-without-plug-ins/

| title = Unity game engine heading to the browser without plug-ins

| website = Ars Technica

| date = 18 March 2014

| access-date = 2016-03-01

}}{{Cite web

| url = http://blogs.unity3d.com/2014/05/20/the-future-of-scripting-in-unity/

| title = The future of scripting in Unity – Unity Blog

| website = Unity Technologies Blog

| access-date = 2016-03-01

}}{{Cite web

| url = https://defold.com/manuals/html5/

| title = Defold HTML Development

| website = Defold Documentation

| access-date = 2023-12-18

}}

Unreal Engine had this export option but it has been migrated out of the engine to a community member plug in.{{Cite web

| url = https://docs.unrealengine.com/4.26/en-US/SharingAndReleasing/HTML5/GettingStarted/#:~:text=The%20Unreal%20Engine%204%20(UE4,UE4%27s%20C%2B%2B%20code%20into%20Javascript

| title = Developing HTML5 with Unreal

| website = Unreal Documentation

| date = 18 December 2023

| access-date = 2018-12-18

}} The Source Engine, has a community developed port for Emscripten dubbed "HalfLife2JS"{{Citation |title=Half-Life 2: Javascript|date=2025-04-13 |url=https://github.com/EmSource/EmSource/ |access-date=2025-04-14 |publisher=EmSource}}

= Frameworks & toolkits =

openFrameworks exports native C++ applications to HTML5 via Emscripten.{{Cite web

| url = http://openframeworks.cc/setup/emscripten/

| title = openFrameworks setup for Emscripten

| website = openFrameworks

| access-date = 2016-03-04

}} emscripten-qt permits compiling applications written using the Qt application framework to WebAssembly.

= 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.{{cite news|url=https://www.washingtonpost.com/blogs/the-switch/wp/2015/01/05/you-can-now-play-nearly-2400-ms-dos-video-games-in-your-browser/ |title=You can now play nearly 2,400 MS-DOS video games in your browser |first=Abby |last=Ohlheiser |date=2015-01-05 |access-date=2015-01-08 |newspaper=The Washington Post}}[http://ascii.textfiles.com/archives/4471 Each New Boot a Miracle] by Jason Scott (December 23, 2014){{Cite web

| url = https://archive.org/search.php?query=collection%3Asoftwarelibrary_msdos&page=1

| title = Internet Archive Search: "collection:softwarelibrary_msdos"

| website = archive.org

| access-date = 2016-03-01

}}

See also

{{Portal|Free and open-source software}}

References

{{Reflist|30em}}