Live data from Hacker News

Emscripten and asm.js: C++'s role in the modern web

kripken.github.io

71–80 of 100 posts

Re: Emscripten and asm.js: C++'s role in the modern web

#71

Earlier quoted context omitted.

I love the idea that we can make web apps just as successful as native apps, but the reality seems to be the opposite. Mobile web usage went from 20% to 14% according to flurry from 2013 to 2014. That trend could be reversed with a new movement towards the web, but it seems like it would take quite a trend reversal. We're stuck with apple- and google- based rent seeking platforms. http://www.flurry.com/bid/109749/App…

We need installable , offline web apps. They are working on it, but it is late. https://github.com/w3c/manifest (I should note that technically, AppCache + bookmarking provides installable web apps, but nobody seems to want to program with AppCache, and bookmarking doesn't really feel like installing an app, which it should.)

AppCache sucks. It's completely broken.

At least we have the Service Workers spec[0] coming soon, though, which should solve the problem.

[0] https://github.com/slightlyoff/ServiceWorker/

Re: Emscripten and asm.js: C++'s role in the modern web

#72
post #69

Although this is very cool stuff, I have a hard time trying to understand where this is going to prove useful. I would image that the major target for something like this will be in doing ports of old games to the browser. Anything other than that would seem like a non-starter. I'm not sure why a developer would take the long road to write a c++ app with the intention of eventually converting it to javascript. Also,…

There are at least 2 major scenarios where C++ ported to JS is useful:

(1) the web as "just another platform" next to desktop, game consoles and native mobile apps, the advantage here is that you can use the same code base for all platforms and only need a small percentage of platform specific code (about 2% platform specific code from my experience)

(2) cross-compile existing C/C++ middleware libs for use in "traditional" JS web apps, this has been demonstrated for physics engines (bullet), but would also work for pathfinding, AI, and other specialized libs

If you're concerned about opening up your precious source code by cross-compiling to JS, restoring the original code is just as complicated as restoring from a compiled binary, since the JS code has been generated from LLVM bitcode, and is additionally minified. You're basically getting a big, opaque ASCII blob out of an emscripten compile.

The only disadvantage of cross-compiled code is that you get a certain static size overhead for parts of the C/C++ runtime that gets compiled into the generated Javascript file which is somewhere between 100 and 300 kByte. This overhead gets (relatively) smaller the more complex the application is, and emscripten/LLVM is very aggressive about dead code removal.

So, a small web page which just wants to use some WebGL effects doesn't make much sense to write in C++, but once you start to write a real game and use JS libs like three.js (currently at 424kByte minified), the size advantage of manually written JS quickly disappears.

Re: Emscripten and asm.js: C++'s role in the modern web

#73
post #69

Although this is very cool stuff, I have a hard time trying to understand where this is going to prove useful. I would image that the major target for something like this will be in doing ports of old games to the browser. Anything other than that would seem like a non-starter. I'm not sure why a developer would take the long road to write a c++ app with the intention of eventually converting it to javascript. Also,…

Besides performance, the big appeal for me is being able to build largish systems with the sanity-checking and refactoring support provided by strongly typed languages.

Re: Emscripten and asm.js: C++'s role in the modern web

#74
post #50

Earlier quoted context omitted.

In the 90ies we thought it would be Java.

And it looks like that in the future we will have something like JVM and its classloaders. Just with different names (LLVM? v8? RequireJS? JS AMD?) and a lot more kludges. And without Gosling, Joy and Steele.

In the future JS-ASICs will define what you can do in the web. People will complain "123JS ASIC is the new IE6".

Re: Emscripten and asm.js: C++'s role in the modern web

#76
post #69

Although this is very cool stuff, I have a hard time trying to understand where this is going to prove useful. I would image that the major target for something like this will be in doing ports of old games to the browser. Anything other than that would seem like a non-starter. I'm not sure why a developer would take the long road to write a c++ app with the intention of eventually converting it to javascript. Also,…

There are at least 2 major scenarios where C++ ported to JS is useful: (1) the web as "just another platform" next to desktop, game consoles and native mobile apps, the advantage here is that you can use the same code base for all platforms and only need a small percentage of platform specific code (about 2% platform specific code from my experience) (2) cross-compile existing C/C++ middleware libs for use in "tradit…

It's hard to overstate how fantastic (1) is. A single code base for all platforms is really amazing. C++ is much closer to universal than Python, Java, etc.

Re: Emscripten and asm.js: C++'s role in the modern web

#77

Very interested in this technology, would like to see some examples created with this technology, more than games. Are there any cpu/gpu heavy applications out there that compile from C++ to asm.js ? Or any good examples of writing the whole webpage with C++ somehow? All the current examples I've seen utilize webgl canvas and handle the interaction there. How about interaction with a regular HTML interface ?

There are examples of python and lua interpreters being compiled, a pdf renderer, graphviz, a 2d physics engine, and a speech synthesizer. you just need to google it. I myself have modified an emulator to run aswell.

Oh right! I almost forgot another cool side project I did last christmas with emscripten: use JSMESS to restore some of my old 8-bit games I wrote as kid in the 80's on an obscure East-German home computer:

http://www.flohofwoe.net/history.html

Re: Emscripten and asm.js: C++'s role in the modern web

#78
post #71

Earlier quoted context omitted.

We need installable , offline web apps. They are working on it, but it is late. https://github.com/w3c/manifest (I should note that technically, AppCache + bookmarking provides installable web apps, but nobody seems to want to program with AppCache, and bookmarking doesn't really feel like installing an app, which it should.)

AppCache sucks . It's completely broken. At least we have the Service Workers spec[0] coming soon, though, which should solve the problem. [0] https://github.com/slightlyoff/ServiceWorker/

What's completely broken about it? If you use it the way it was intended to be used, as a cache for apps, then it works perfectly fine in my experience. It behaves like a native app that updates itself in the background (Chrome itself does this, for example). If you try to use it as a HTTP cache then yes, it's completely the wrong tool for the job and you're gonna have a bad time.

Re: Emscripten and asm.js: C++'s role in the modern web

#79

Very interested in this technology, would like to see some examples created with this technology, more than games. Are there any cpu/gpu heavy applications out there that compile from C++ to asm.js ? Or any good examples of writing the whole webpage with C++ somehow? All the current examples I've seen utilize webgl canvas and handle the interaction there. How about interaction with a regular HTML interface ?

It would be interesting to see node.js and meteor working with emscripten. Then you can forget javascript and keep it all in c++.

Re: Emscripten and asm.js: C++'s role in the modern web

#80
post #22

I like how he says 'compiled c++ (to javascript) is immune to buffer overflows' yet completely sidesteps the real issue at hand: Every major javascript virtual machine is riddled with security holes. In Firefox case (no sandbox, no process-per-tab, one of the worst C++ codebases I've ever seen security-wise, _infested_ with memory leaks and UAFs) these holes can effortlessly lead to system compromise. In Chrome case,…

Bugs exist. Report them. Doesn't change the intent of asm.js to be immune to buffer overflows.
Post reply on HN