Live data from Hacker News

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

tbfleming.github.io

171–180 of 318 posts

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

#171
post #12

Earlier quoted context omitted.

clang is pretty big. There's about 55 MB of binaries on that page. When served from localhost, it takes about 10 seconds to load and compile a source file on my machine.

This gets us to two caching-related problems: What if you're offline and how do you decide what you want to be cached? But browser vendors will solve this.

Isn't this solved with progressive web apps? On the other hand I'm not aware of any UI that allows you to explicitly choose if a PWA should be cached or not.

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

#172
post #156

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 don't think so, not when my native game needs 50GB of install space. There is no way I'm waiting for that progress bar to download in a webassembly version game. This is one area where native will always have an advantage. The network is no match for the local bus.

Downloading it from steam takes just as mush time.

But that 50GB is probably for more then 100 hours of playtime, which amounts to a persistent 145kb/s. With some caching up front, I think this could actually work. There literally is no need to have everything on disk before starting. Maybe a few hundred megs before starting, but even that is less then a few minutes on most connections, which is a lot faster then downloading the full game before starting.

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

#173

Cool! Now I just need the JVM as a clang target, and then I'll never have to use anything other than C++ ever again!! :D Webassembly has a tad more promise than ActiveX.

Perhaps you could use node.js to compile your C++ code into a native WASM module?

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

#174

Earlier quoted context omitted.

Yes. You can build WebAssembly bytecode from C++ and it will run in the browser like JavaScript.

Thank you. In that case is it possible to access DOM elements within a C++ program the way we do in Javascript.

Not yet, but AFAIK it will eventually.

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

#175

So the web browser is pretty much a mini operating system. Firefox and Chromium seriously feel like they have the longest compile time out of any package in Gentoo, except maybe Libreoffice. It has tons of embedded packages that it doesn't pull from the system/native (jpeg and png decoders and such). So with a lot of these neat things where we compile stuff or run a Linux kernel in the browser, we've pretty much come…

It's been a long time coming, of course, but when I saw vim[1] ported to Javascript it really hit home. There's no denying it, your web browser is now an OS. Not a mini OS, an actual honest to goodness OS multiple vendors add features to on a 6 week release cadence.

[1] https://github.com/coolwanglu/vim.js/

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

#176
post #41

So the web browser is pretty much a mini operating system. Firefox and Chromium seriously feel like they have the longest compile time out of any package in Gentoo, except maybe Libreoffice. It has tons of embedded packages that it doesn't pull from the system/native (jpeg and png decoders and such). So with a lot of these neat things where we compile stuff or run a Linux kernel in the browser, we've pretty much come…

I have been thinking about why we have ended up here, and why not just native apps. The obvious answer is that it makes applications portable, which is great. The other key component I think is delivery. You don't ever install anything, it just exists when you ask for it. That is something native applications have never done, and not even something like JVM has done even though it addresses portability too. It is als…

>I have been thinking about why we have ended up here, and why not just native apps.

In my opinion its because operating-system design wasn't sexy after browser-companies came and ate the OS-guys lunches with all that big bubble fuss. So the OS guys went all apathetic and forgot that a majority of their OS is a freakin' browser, and .. here we are. Inception.

Its great we can compile C++ to 'native' assemblies now. We've always been able to do this, btw. The only difference is the delivery mechanism ..

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

#177

So the web browser is pretty much a mini operating system. Firefox and Chromium seriously feel like they have the longest compile time out of any package in Gentoo, except maybe Libreoffice. It has tons of embedded packages that it doesn't pull from the system/native (jpeg and png decoders and such). So with a lot of these neat things where we compile stuff or run a Linux kernel in the browser, we've pretty much come…

> we've pretty much come full circle?

If want to play old classic games like Heroes3, AoE2, Diablo 2 on Windows you have to install it using WINE.

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

#178
post #41

Earlier quoted context omitted.

I have been thinking about why we have ended up here, and why not just native apps. The obvious answer is that it makes applications portable, which is great. The other key component I think is delivery. You don't ever install anything, it just exists when you ask for it. That is something native applications have never done, and not even something like JVM has done even though it addresses portability too. It is als…

The answer is that browsers provide something that users desperately need and no operating system has ever provided: a sandbox strong enough to run completely untrusted code. The success of browsers is an indictment of the entire field of operating systems research. They have either failed to recognize the need or simply failed to deliver that kind of security. For one example take WebGL. For decades OpenGL had been…

> The answer is that browsers provide something that users desperately need and no operating system has ever provided: a sandbox strong enough to run completely untrusted code. The success of browsers is an indictment of the entire field of operating systems research. They have either failed to recognize the need or simply failed to deliver that kind of security.

The JVM more-or-less managed it. Modern hypervisors do it - you could use something like Qubes and run completely untrusted code in its own isolated VM. It's not that academics weren't working on this stuff, adoption is where it fell down.

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

#179
Having some random thoughts about the comments here, some of which talk about having a "browser" drive large parts of what we consider today an "operating system". I agree that certain aspects of what most modern operating systems do today can be abstracted away behind a unified, convenient (and perhaps browser-accessible) API. The entire user-experience stack comes to mind immediately, but there are counter examples as-well. The answer to non-unified execution environments (as in different operating systems and architectures) was the rise of high-level, interpreted languages (in addition to corresponding VMs), and runtime environments which exposed a platform-independent set of APIs. We've been exploring the possibilities of implementing bytecode VMs in hardware (https://en.wikipedia.org/wiki/Java_processor), or running a managed code operating system (Microsoft's Midori) for a while now, so the concept itself isn't particularly new. What is WASM's advantage over, say, Java's bytecode? Did we really have to go through so many hoops (reinvent another instruction set and a VM that can execute it across multiple platforms)? Why wasn't an existing technology re-used here to achieve the same/similar goals?

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

#180
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…

Something like that needs to be built into Github or a similar site. Along with fork and download, 'compile to web' should be an option.

Keeping code alive would also make long-term archiving of obsolete software viable, more so than just putting the code online, anyway. This is important because so much of our culture has been expressed by and tied up in software.

Post reply on HN