Live data from Hacker News

Clang runs in the browser and compiles C++ to WebAssembly

tbfleming.github.io

21–30 of 318 posts

Re: Clang runs in the browser and compiles C++ to WebAssembly

#21
Clang is pretty big -- as a comparison, my Z80 IDE which uses SDCC (Simple Device C Compiler, i.e. no C++) loads about 2 MB of WASM + 2 MB of data and executes a compile/assemble/link cycle in about 0.5 sec for a small program:

http://8bitworkshop.com/v2.1.0/?platform=mw8080bw&file=gfxte...

Most of the execution time is spent in SDCC's register allocator, which was recently rewritten to generate better code but unfortunately is a lot slower than the old allocator.

Re: Clang runs in the browser and compiles C++ to WebAssembly

#22
Idea - make a website that lets you compile and test any open source program. For example, I should be able to clone, compile, and run gedit (a stagnating text editor included with many linux distros). This would let me quickly experiment with and edit a variety of programs and tools within the web browser without needing to get a development system up and running. I bet open source projects can get a ton of new hackers to continue development on their programs if everything could be worked on quickly within a web browser.

Re: Clang runs in the browser and compiles C++ to WebAssembly

#23

People might not like it but i really think native apps are going to die once everyone figures out how to optimize this crazy web stack.

I disagree. When people start using native languages like C++ for the Web, they will quickly realize they could have just used C++ to begin with.

Getting people to download and install traditional software is a substantial point of friction. Average users hate managing software installations, updating, fixing broken installations, dealing with malware, et al. The problem spans from the enterprise down to normal consumers.

Browsers as a better software platform, will significantly accelerate the rate at which software eats everything.

Most software should ideally just work, no installs, period. The browser can act as that platform and it can go a lot further than it has so far. More to the point, there is no other future outcome than the browser becoming that vehicle, nothing can stop it from moving that direction at this point.

You don't need something equivalent to maximum native performance to do what 99% of users want to do. The rare edge cases that need extreme performance will remain native.

Re: Clang runs in the browser and compiles C++ to WebAssembly

#25
post #22

Idea - make a website that lets you compile and test any open source program. For example, I should be able to clone, compile, and run gedit (a stagnating text editor included with many linux distros). This would let me quickly experiment with and edit a variety of programs and tools within the web browser without needing to get a development system up and running. I bet open source projects can get a ton of new hack…

It's hard to just apply this to an arbitrary project, which may use nontrivial linker features or native code.

Re: Clang runs in the browser and compiles C++ to WebAssembly

#27
post #22

Idea - make a website that lets you compile and test any open source program. For example, I should be able to clone, compile, and run gedit (a stagnating text editor included with many linux distros). This would let me quickly experiment with and edit a variety of programs and tools within the web browser without needing to get a development system up and running. I bet open source projects can get a ton of new hack…

It's hard to just apply this to an arbitrary project, which may use nontrivial linker features or native code.

True. I think this would be a project within the open source community. Core libs (libXYZ) would be pre-compiled to WASM, and only the lib / program being hacked in would be modified in the browser. The compilation and linking would include the core libs. Maybe I will work on such a project, I will think about it.

Re: Clang runs in the browser and compiles C++ to WebAssembly

#29
post #13
post #2

So Clang itself was compiled to WebAssembly? That's slick, even if it does take forever to load.

What about packing up web assembly into a single file container like runtime designed to run server side web applications? This .war (Webassembly ARchive) file could include the application and all dependencies in a single installable that is JITd on load. Might be useful for the next generation of "serverless" cloud runtimes.

I see what you did there.

I’d be all for this, honestly, except that the existing containers (yes, even Jetty) are too heavyweight for this use case.

What you really want is a stripped down server runtime that loads and starts your application’s archive, fires it up on a (possibly random) local port and opens a stripped down Chromium instance that loads the app from that port.

Of course, that sounds a bit like Electron.

Re: Clang runs in the browser and compiles C++ to WebAssembly

#30
post #22

Idea - make a website that lets you compile and test any open source program. For example, I should be able to clone, compile, and run gedit (a stagnating text editor included with many linux distros). This would let me quickly experiment with and edit a variety of programs and tools within the web browser without needing to get a development system up and running. I bet open source projects can get a ton of new hack…

Main issue is memory usage. Running KDE+Kate - http://vps2.etotheipiplusone.com:30176/redmine/emscripten-qt... - uses 1793MB (htop VIRT), 416MB (Chrome task manager). (Oh, and the renderer process wasn't hosting any other tabs.)

Second main issue is speed. qsterix isn't as memory-heavy but runs all Tetris game code inside KDE JavascriptCore, which as part of the KDE/Emscripten build is transpiled to JS. In other words, http://vps2.etotheipiplusone.com:30176/redmine/emscripten-qt... is JavaScript inside JavaScript, and on my reasonable-but-not-last-week-new i3 box, I experience a small pause that I can't explain when I hit the spacebar to drop a block.

Half of me wants to warn everyone from opening these on their phones or tablets, the other half wants to know how badly everything crashes. :P

Note: I tried opening the Kate demo a week or so ago on a marginally older version of Chrome, and the download phase hung. It worked this time though.

Post reply on HN