Emscripten brings C++ code to web applications

By Kshitij Sobti | Published 30 Aug 2010 15:01 IST
Emscripten brings C++ code to web applications

A project by Alon Zakai, of the Mobile Team at Mozilla, called Emscripten could ease a lot of work for those “porting” their native application to run on the web. Emscripten is an LLVM to JavaScript compiler; meaning that is can take LLVM bytecode, which can be generated from any language that can target LLVM (for example C ), and generate the corresponding JavaScript code.

This is not to be confused with Google’s NaCl (Native Client). Google’s solution allows web developers to create applications which run natively on the end-user’s computer, making such applications more powerful as they run directly on the CPU instead of being interpreted.

While NaCl runs native code itself through a plugin, Emscripten can convert code written in languages such as C to JavaScript. This enables it’s use in any browser or any other scripting environment supporting JavaScript, without the need of any plugins. While this increases the reach of the generated code, it also makes it much slower, about 20 times slower by the author’s own estimation. However since the compiler is in its early stages, is open source — and will hopefully attract contributors — the generated JavaScript aught to get faster with time. Additionally, browser engines will not stay stagnant, and as each browser tries to best the other, this could make a large amount of code usable.

For someone with a large volume of code in C , such as “physics engines, game logic, etc.”, this could spell a new breath of life for that code on the web. Since JavaScript is a language that will run on any system with a browser, this can increase the reach of such code a lot.

To find out more about this brilliant new tool, check out the original blog post by its creator.

Kshitij Sobti
Kshitij Sobti

Email Email Kshitij Sobti

Trending Articles


Latest Articles View All