From MozillaWiki
Jump to: navigation, search

Project statement

Emscripten is an LLVM to JavaScript compiler. It takes LLVM bytecode (which can be generated from C/C++ using Clang, or any other language that can be converted into LLVM bytecode) and compile that into JavaScript, which can be run on the web (or anywhere else JavaScript can run). Using Emscripten, you can

  • Compile C and C++ code into JavaScript and run that on the web
  • Run code originated in languages like Python on the web as well, for example by compiling CPython from C to JavaScript

This is a really cool and very useful technology, and it is essential for the success of some of Mozilla's current initiatives, such as web gaming. But the uses of Emscripten go beyond just building amazing games, therefore I have decided that Emscripten should have its own landing page on MDN, covering Emscripten in a more complete fashion.

Emscripten currently has a wiki on github that contains some great content, but this content could use some updating and reorganization, and we have lots of other ideas for content too, to tell the full story of how useful Emscripten is to interested parties such as C++ developers.

This document outlines the plans for an MDN resource covering Emcripten.

Where will this project live?

The main host for this docs project will be an MDN zone, with its landing page at

We will also have a professional looking external site, say at, with nice links to demos etc., maybe a dozen pages all in all. This will be the "landing page", but will link back to MDN for the meat of the content.

What content should it have?

Although Emscripten can be used to compile a number of different languages into JavaScript, it would make sense to start with C++, as that is the best supported and most useful target laguage for our current projects. The following quote from Jukka provides some good context for the purpose of these docs:

My experience and perspective is mainly from the "Game developer who has written a native game in C/C++ for Android/iOS/PC and wants to port it to FxOS/browser" viewpoint.

Proposed structure

  • - Introducing Emscripten
  • - Web abilities and limitations
  • Product manual (covers latest version, currently 1.7.8)
    • - Download and install
    • - Workflow and tools
    • - Techniques
    • - Reference
  • - Demos
  • - Older product manual versions
    • - 1.7.1
      • - Download and install
      • - Workflow and tools
      • - Techniques
      • - Reference
    • - 1.5.1
      • - Download and install
      • - Workflow and tools
      • - Techniques
      • - Reference

Introducing Emscripten (always cover the latest version of Emscripten)

An introduction to Emscripten, including how it works, how to get it set up and start working with it, and some beginner's tutorials. Throughout this section we can reference more detailed guides in later sections.

Web abilities and limitations (probably doesn't need to be version-specific)

This could be a single article but may well be multiple articles under a single section as the document resource grows. The main purpose here is to provide native developers trying to research the feasibility of running their project on the web with some answers.

Download and install (could be versioned)

  • Win
  • Mac
  • Linux
  • Troubleshooting
  • Other useful tool links

Workflow and tools (could be versioned)

As a native developer, how can I get up and running with Emscripten, including it as an additional development target that fits into my existing toolchain?

Techniques for working with Emscripten (could be versioned)

More detailed tutorials than you got with the hello world section in the introductory material. Generally these should help developers solve specific problems with their code, and porting it across. It might be an idea to, at each point, say what C++ component is being used, and what JavaScript API/construct it is being compiled into, making it easier to understand what is going on whether you are a C++ person or a JavaScript person.

Generally the C++ devs won't be initially familiar with the JS specs, and if they are presented e.g. with the Gamepad API or Web Audio API, they'll reject those docs since they are foremost looking for C/C++ solutions to their problems. This is partly because they have just learned about this Emscripten C/C++ compiler that they are now harnessing, and they are right now getting their initial problems solved in the C/C++ side without a single line of JS. Another reason is that devs might not know the JS syntax at all, or if they do, there's a considerable amount of new C/C++ <-> JS interop machinery that one needs to learn, and how to integrate JS into the native build arch, and so on, so being able to develop against JS side APIs will generally come much later during the porting cycle, when the landscape has been charted sufficiently enough to know that one can't (yet) solve all the problems with just native C/C++ code alone.

Reference documentation (could be versioned)

Demos (does this need to be versioned?)

  • a
  • b
  • c
  • etc.

What should we talk to?

Alon, Jukka, Vlad, Martin Best, Dave Herman, Luke Wagner, the rest of the games team!