Live data from Hacker News

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

kripken.github.io

51–60 of 100 posts

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

#51
There's a couple of points going around in my head which I find interesting / relevant when it comes to emscripten/asm.js, the web and mobile platforms:

- asm.js code runs faster then Java code running through the Dalvik VM on Android (https://blog.mozilla.org/javascript/2013/08/01/staring-at-th...)

- porting and cross-compiling code to JS with emscripten is (arguably) easier then setting up and working with the Android NDK

- the new Javascript LLVM backend in iOS8 Safari runs asm.js code very well, and Safari on iOS8 adds WebGL support

- the web is a the only open software distribution platform without gate keepers (seriously, this is starting to get ridiculous: https://developer.apple.com/app-store/review/guidelines/)

- web apps don't need all the code-signing and certification hoopla that native mobile apps need to go through

- app shops are becoming saturated and have the same or worse visibility problems as the web even though they are 'curated'

- you don't pay the 30% platform tax on the web (or rather: you're free to choose your store front-end)

- in the end, most successful mobile games need so little CPU and GPU performance that it really doesn't make a difference whether they run native or in BASIC, WebGL or Metal

I think that the advantages that a single centralized app-shop offered in the past over the web have already or will erode very fast once they have to manage a very high number of apps, basically modern AOLs but with shitty search engines. The open web is the only way out, even if it just means that multiple, decentralized app shops will be built on which compete with each other.

[edit: formatting]

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

#52
post #36

I really wish we had a proper 'web assembly' instruction set to compile to. JavaScript has proved itself to be a surprisingly adequate language over the years, but there is only so much optimization you can do with its language specification.

There is a proper 'web assembly' instruction set. It's Google 's Portable Native Client [1]. The problem with this solution is that Google is the only one supporting it. But there other players in the web. Creating such a standard making all of the vendors happy might be impossible. ASM.js might not be the perfect solution, but it has the huge advantage of being compatible with all major browsers. Practicality beatin…

The real-world differences between asm.js and PNaCl are really not that big (basically only whether threads are true POSIX threads, or WebWorkers). Here's a (shameless plug) demo page which has the same demos as emscripten and PNaCl compiled from the same C++ code (warning: most of the PNaCl demos need the latest Chrome Canary): http://floooh.github.io/oryol/

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

#53

Earlier quoted context omitted.

There is a proper 'web assembly' instruction set. It's Google 's Portable Native Client [1]. The problem with this solution is that Google is the only one supporting it. But there other players in the web. Creating such a standard making all of the vendors happy might be impossible. ASM.js might not be the perfect solution, but it has the huge advantage of being compatible with all major browsers. Practicality beatin…

The sandboxing provided by NaCl is nice, but I'm not sure binary portability is really a worthwhile goal -- I think we really want cross-compilation, native binaries and the OS providing most of the sandbox. That way we get maximum performance on the hardware we're targeting (not the "lowest common denominator" of common bytecodes), an ability to run self-modifying code if we want to send a JIT down the wire...

A bit off-topic, but I would really like to see (P)NaCl apps directly supported on Android outside the browser, no need to mess with the NDK or Java. One can dream, right? :)

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

#54
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,…

> _infested_ with memory leaks and UAFs Really? That doesn't match my experience -- the full Firefox test suite is run through ASAN on every check-in. (See the "Linux x64 ASAN" results at https://tbpl.mozilla.org/?tree=Mozilla-Inbound , for example). So I'd be interested to know what you base this claim on.

I wonder how many functions are suppressed from issuing error reports, if any.

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

#55
post #36

I really wish we had a proper 'web assembly' instruction set to compile to. JavaScript has proved itself to be a surprisingly adequate language over the years, but there is only so much optimization you can do with its language specification.

The history of the web is very much a series of mad hacks and patchups cobbled together to keep the whole thing progressing and evolving - the ultimate "legacy application" if you will; the endearing zaniness of asm.js is just another milepost in this well-trodden road.

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

#56

There's a couple of points going around in my head which I find interesting / relevant when it comes to emscripten/asm.js, the web and mobile platforms: - asm.js code runs faster then Java code running through the Dalvik VM on Android ( https://blog.mozilla.org/javascript/2013/08/01/staring-at-th... ) - porting and cross-compiling code to JS with emscripten is (arguably) easier then setting up and working with the An…

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/Apps-Solidify-Leadership-Si...

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

#57

There's a couple of points going around in my head which I find interesting / relevant when it comes to emscripten/asm.js, the web and mobile platforms: - asm.js code runs faster then Java code running through the Dalvik VM on Android ( https://blog.mozilla.org/javascript/2013/08/01/staring-at-th... ) - porting and cross-compiling code to JS with emscripten is (arguably) easier then setting up and working with the An…

"- web apps don't need all the code-signing and certification hoopla that native mobile apps need to go through"

You mean that's a good thing? I'd prefer a clear signing process for software to a web service running its backend on some random server where it's impossible for me to establish trust.

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

#58

There's a couple of points going around in my head which I find interesting / relevant when it comes to emscripten/asm.js, the web and mobile platforms: - asm.js code runs faster then Java code running through the Dalvik VM on Android ( https://blog.mozilla.org/javascript/2013/08/01/staring-at-th... ) - porting and cross-compiling code to JS with emscripten is (arguably) easier then setting up and working with the An…

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.)

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

#59
post #57

There's a couple of points going around in my head which I find interesting / relevant when it comes to emscripten/asm.js, the web and mobile platforms: - asm.js code runs faster then Java code running through the Dalvik VM on Android ( https://blog.mozilla.org/javascript/2013/08/01/staring-at-th... ) - porting and cross-compiling code to JS with emscripten is (arguably) easier then setting up and working with the An…

"- web apps don't need all the code-signing and certification hoopla that native mobile apps need to go through" You mean that's a good thing? I'd prefer a clear signing process for software to a web service running its backend on some random server where it's impossible for me to establish trust.

You can have offline, signed web apps as well. It's just that with web apps, it's optional.

For example, see how Firefox OS handles it: https://developer.mozilla.org/en-US/Marketplace/Options/Pack...

Post reply on HN