Live data from Hacker News

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

tbfleming.github.io

291–300 of 318 posts

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

#291

Earlier quoted context omitted.

I'd rather not see (offline) games in the browser, or any other online-based method, personally. I want to have control over the games' data files so i can copy them to my external hard disk, be able to run them in 10 years without hoping some server is still online and their owner gives a damn about stuff they made 10 years ago (most stop giving said damn within a couple of years, let alone 10), etc. Let's not forge…

I don’t understand why you object to browser games but use flash as an example of what could happen? First of all, tons of flash games are archived. Second, how is the web worse than a compiled binary that you don’t have source code access? Games that are made for the web are easier to preserve and run in the future than native games by a long shot. Would you rather run a browser that can play all of the games on the…

> First of all, tons of flash games are archived.

Tons of them are archived but these are a tiny minority, at its hayday there were hundreds of Flash games released per day. A lot of that stuff are or will be lost forever.

> Second, how is the web worse than a compiled binary that you don’t have source code access?

The web is worse because for the application to run it needs to be loaded off that web site and the user has no control over that. I cannot for example preserve Google Docs or any other web application i like - i just have to hope that it'll remain online, will keep working with my computer without issues like slowing down and wont change its UI to something i dislike (people often use older versions just to be able to run or because they like the older UIs better).

> Games that are made for the web are easier to preserve and run in the future than native games by a long shot.

How can you preserve a game that you have not full access to its files? Only the developer has that power and developers for the most part have shown over and over that they do not care about the games and applications they make after a couple of years or so.

I have games from companies that closed doors more than a decade ago, if those games were web games, they'd be gone the moment the company shuts down. Or more likely, the moment the company decides they do not want to pay for the bandwidth of accessing the game anymore, like what happened to several MMOs (many of whom are perfectly fine playable solo) already.

> Would you rather run a browser that can play all of the games on the web in a backwards compatible way or rely on emulators for previous operating systems or game consoles?

I'd rather rely on native OS support (above all), compatibility layers like dgVoodoo2 (for 3DFX and older DirectX compatibility in Windows) and Wine (before dgVoodoo2 it was the best way to play old 3D games for Windows) and of course emulators. Remember the games i mentioned above about companies that do not exist anymore? Several of them are for DOS and running perfectly fine in DOSBox.

As i wrote in the message you replied to, it is all about who controls the files and personally i want to have full control of them because i do not trust the developers with that control - they have proven time and time again to not be trustworthy (not necessarily because of their fault, of course, but that is little importance when you lose an game or application you like).

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

#292
post #281

Earlier quoted context omitted.

Congrats, you've just gone ahead and proved my point. Zero technical reasons other than an ad hoc attack on game development practices. Unless you have a client library that can be paired to that server which takes up less than 200kb of mem you won't see adoption. You're going to want to use one network stack across your products and a lot of the handheld and smaller platforms are really memory constrained.

> Zero technical reasons other than an ad hoc attack on game development practices. These have been brought up ad nauseam so I didn't think it was useful to go over them. The biggest reason UDPSocket doesn't just show up in browsers is that: • Browser vendors don't want to accidentally make it easy to trivially D/DoS servers • Browser vendors don't want to accidentally make it easy to trivially D/DoS clients • It's n…

DDos is already handled cleanly by something like netcode.io using access tokens.

Anything more than the most trivial NAT traversal isn't needed since any online game worth their salt uses dedicated servers in order to prevent cheating and gamestate manipulation.

The fact that you're bringing up a 1200 byte packet limit shows that you have no understanding of the domain space. Most networking stacks keep the packet size well under 200 bytes since they don't want to saturate the connection and dead-reckoning deals with state reconciliation.

Binary size also matters, so the fact that you want to bring in a whole codec when it may not be wanted isn't a great selling point either.

I'm sure there's a market out there given how RAD Tools and other middleware companies do just fine. However I don't think you know enough about the domain to be able to sell it successfully.

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

#293
post #186

Earlier quoted context omitted.

That assumes it would be impossible to download a WASM blob and run it natively, or that no one will ever provide source code for their binaries which you could potentially edit. It's not a zero-sum game.

I believe we have already enough evidence, both by the existing web applications and by the other RIA technologies available over the years (Applets, Flash, Silverlight, ActiveX, etc) that this is a very safe assumption to make. There are exceptions to this, of course (i myself made the source code of my 3D engine for Flash written in Haxe available years ago), but those are extremely rare. Besides the experience the…

Drawing inferences based on other technologies isn't really evidence.

WebAssembly is open and it's intended to be a general purpose compilation target, the technologies you listed are proprietary or only intended for a single language. Also, WebAssembly's own docs state non-web embeddings as an explicit design goal[0].

As there is no commercial need for a particular corporation to prevent it, and there is no design limitation preventing it, there's no reason to assume some sort of native WASM runtime won't be available in the future. That would make it no different than Python or Ruby or any of the multitude of C++ runtimes I have to download with games on Steam.

My point being that there's no reason to assume WASM has to run as remote code connected to a server over which the user has no control or meaningful access, as opposed to a binary you can run on your desktop. There's nothing in the WASM spec that forces such a distinction to exist, that's an architectural decision made at the application level, and one that could be made in any language.

[0]http://webassembly.org/docs/non-web/

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

#294

Earlier quoted context omitted.

I don’t understand why you object to browser games but use flash as an example of what could happen? First of all, tons of flash games are archived. Second, how is the web worse than a compiled binary that you don’t have source code access? Games that are made for the web are easier to preserve and run in the future than native games by a long shot. Would you rather run a browser that can play all of the games on the…

> First of all, tons of flash games are archived. Tons of them are archived but these are a tiny minority, at its hayday there were hundreds of Flash games released per day . A lot of that stuff are or will be lost forever. > Second, how is the web worse than a compiled binary that you don’t have source code access? The web is worse because for the application to run it needs to be loaded off that web site and the us…

If you have an HTML5 game that you own and it doesn’t require a server (it runs entirely on the client side) then there is no technical reason it can’t be archived.

You can’t run google docs offline because what would that even mean? One of the main features of google docs is the live collaborative editing. It’s a multiplayer game that requires a host server.

You can architect your game to be friendly to being archived or you can make it completely impossible by introducing a dependency on the network. This is true for native games and web games.

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

#295
post #293

Earlier quoted context omitted.

I believe we have already enough evidence, both by the existing web applications and by the other RIA technologies available over the years (Applets, Flash, Silverlight, ActiveX, etc) that this is a very safe assumption to make. There are exceptions to this, of course (i myself made the source code of my 3D engine for Flash written in Haxe available years ago), but those are extremely rare. Besides the experience the…

Drawing inferences based on other technologies isn't really evidence. WebAssembly is open and it's intended to be a general purpose compilation target, the technologies you listed are proprietary or only intended for a single language. Also, WebAssembly's own docs state non-web embeddings as an explicit design goal[0]. As there is no commercial need for a particular corporation to prevent it, and there is no design l…

I think we are talking about different things, you seem to be talking about the possibility of using WASM as a generic virtual machine in the same vein as JVM - in that case, if there is some sort of runtime that would provide the ability for a program to be made to work both in web mode and offline mode and the developer decides to make their application available through it, then yes it wont be an issue. After all people already do that with JVM, Flash and even ActiveX (which was originally meant for offline use).

But i am not talking about such a use, i am talking about using WASM to create applications that are designed to be part of a web site and meant to be accessible only online - pretty much what the majority of Flash games did previously. The original message i replied to was about web-based applications that are meant to be delivered online so my messages were with the assumption that we are talking about web-based applications pretty much in the same vein as Google Docs or games like the thousands of Flash games you'd see out there some years ago. You wrote "That assumes it would be impossible to download a WASM blob and run it natively" - the possibility to do that would be exactly the same as downloading a JS file and run it natively (in this case i take "natively" to mean running an offline local copy in a browser without any sort of external requirement, like downloading files off the web). I do not see a reason for expecting WASM to be used in any different way.

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

#296

Earlier quoted context omitted.

> First of all, tons of flash games are archived. Tons of them are archived but these are a tiny minority, at its hayday there were hundreds of Flash games released per day . A lot of that stuff are or will be lost forever. > Second, how is the web worse than a compiled binary that you don’t have source code access? The web is worse because for the application to run it needs to be loaded off that web site and the us…

If you have an HTML5 game that you own and it doesn’t require a server (it runs entirely on the client side) then there is no technical reason it can’t be archived. You can’t run google docs offline because what would that even mean? One of the main features of google docs is the live collaborative editing. It’s a multiplayer game that requires a host server. You can architect your game to be friendly to being archiv…

> If you have an HTML5 game that you own and it doesn’t require a server (it runs entirely on the client side) then there is no technical reason it can’t be archived.

If a game is fully available on the client side - it doesn't just need to run on the client side, but have everything available on the client side, data files and all - then yes you can archive it. But this is a very limited case and so far only the most simplistic games can be distributed like that. And TBH considering the DRM craze that games have, if anything i'd expect companies to try and make such archival as difficult as possible.

> You can’t run google docs offline because what would that even mean?

Having a word processor, spreadsheet, etc available offline.

> One of the main features of google docs is the live collaborative editing. It’s a multiplayer game that requires a host server.

It is a feature but i'd say that the main feature is being able to edit documents. In terms of games, it is a game with multiplayer features that still requires a host server for its singleplayer part (which is generally something that is frowned upon).

> You can architect your game to be friendly to being archived or you can make it completely impossible by introducing a dependency on the network.

You are talking from the point of view of the developer, i am talking from the point of view of the user. It should be obvious from when i wrote "How can you preserve a game that you have not full access to its files? Only the developer has that power and developers for the most part have shown over and over that they do not care about the games and applications they make after a couple of years or so". It is the user that suffers from such choices, not the developer.

Please try read my posts with the eyes of a user, with the concerns of a user's and try to avoid any developer bias.

> This is true for native games and web games.

Technically yes, but things aren't black and white - there are "natural" tendencies in each approach with the web approach leaning heavily towards network reliant applications and the native approach avoiding it.

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

#297
post #266
post #263

Earlier quoted context omitted.

Aren't browsers basically the largest attack surface on most platforms now? Have they really succeeded in doing this?

Saying browsers are "the largest attack surface" is an indication of ubiquity, not an indictment of the design or implementation of browsers (which are still worth considering separately). And we only make such remarks about browsers (or other apps that execute untrusted code like spreadsheets or PDF readers) because the state of OS security is such that any program running directly can pretty much wreak havoc even w…

It seems like most users don’t really understand that they’re really running a lot of code for every page they visit now though. IMO it’s as prevalent as it is because browsers just run code by default. If iOS and Android apps were automatically launched without explicit installation by visiting URLs, they’d probably have just as much security out of necessity.

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

#298
post #281

Earlier quoted context omitted.

> Zero technical reasons other than an ad hoc attack on game development practices. These have been brought up ad nauseam so I didn't think it was useful to go over them. The biggest reason UDPSocket doesn't just show up in browsers is that: • Browser vendors don't want to accidentally make it easy to trivially D/DoS servers • Browser vendors don't want to accidentally make it easy to trivially D/DoS clients • It's n…

DDos is already handled cleanly by something like netcode.io using access tokens. Anything more than the most trivial NAT traversal isn't needed since any online game worth their salt uses dedicated servers in order to prevent cheating and gamestate manipulation. The fact that you're bringing up a 1200 byte packet limit shows that you have no understanding of the domain space. Most networking stacks keep the packet s…

> DDos is already handled cleanly by something like netcode.io using access tokens.

I can set up a netcode.io server and cause it to list any IP addresses I want as "server addresses", then cause a netcode.io client accept that challenge token and permit traffic to that address. If netcode.io is widespread (i.e. in browsers) I can buy some advertising to knock out any client or server I want.

Unless you are in advertising, you might not be aware I can do that: I can purchase something like a million clients for something like $10. Knowing how certain formats work make it possible to purchase more traffic for even cheaper.

These attacks are well known to Google and the WebRTC designers and as such, is not possible with WebRTC: The browser does not permit traffic at volume until ICE/SDP negotiation is complete which means that signalling must have occurred.

By simply limiting the netcode.io clients size to the games that use it (i.e. games distributed with one of the non-browser implementations of netcode.io), this attack is mitigated substantially, but as soon as we try to use netcode.io as a "simpler webRTC" it falls flat on it's face.

Splat.

Perhaps we are lucky that the window.netcode browser extension isn't more popular, or that all those users have ad blockers.

Anyway. The workaround I suggested would probably be sufficient to stop this attack as stated, but it requires a netcode 1.1 or maybe a 2.0 since all clients and servers need to be upgraded. And there might also be other attacks.

> Anything more than the most trivial NAT traversal isn't needed since any online game worth their salt uses dedicated servers in order to prevent cheating and gamestate manipulation.

What Cisco calls Dynamic NAT doesn't work with this scheme. It is popular. Perhaps these people don't play games because game servers don't support their network configuration, or perhaps these people don't play games for another reason.

Non-game uses of UDP are very interested in talking to these networks however. It will be difficult to get buy-in from other parties interested in UDP unless you solve these problems.

> Most networking stacks keep the packet size well under 200 bytes since they don't want to saturate the connection and dead-reckoning deals with state reconciliation.

IP packets fragment once they go above a certain size. That size can only be discovered by experimentation, but will never be smaller than 576 bytes. Many networks block the standard discovery process (called Path-MTU discovery) for misguided reasons, but protocol developers still have to deal with it.

If your UDP packets are bigger than this size, and everything else is working, then losing either fragment will delay the receipt of the datagram and waste kernel memory. Developers who can do their own fragmentation smarter use setsockopt+IP_DONTFRAG and save everyone a potential denial of service opportunity.

If all you want to do is avoid head-of-line blocking on the player's network connection, then multiplexing several TCP connections (even websockets!) will provide the same latency and throughput guarantees that UDP will, getting correct NAT behaviour and resistance to D/DoS for free. Simply drop and reconnect any link on packet loss (trivial to detect on either side), and you only need enough connections to handle the maximum number of dropped packets you can tolerate within the time it takes to reconnect.

I've seen at least one game on HN use this trick in the last year, so I know it isn't unknown.

> Binary size also matters, so the fact that you want to bring in a whole codec when it may not be wanted isn't a great selling point either.

That statement might have been over your head. Sorry about that.

1kb of code "on the hot path" is a shorthand way of describing the code that is executing in L1 and refers absolutely to binary size. My i7 only has 64kb of L1, and anything larger than that requires memory fetch and waits. Keeping the hot path within L1 is a good way to get 1000x speedups (and is a big part of why my code tends to be so fast).

Ulrich Drepper's "what every programmer should know about memory"[1] might be good introductory material for some of these concepts, and I highly recommend you read it.

[1]: futuretech.blinkenlights.nl/misc/cpumemory.pdf

> However I don't think you know enough about the domain to be able to sell it successfully.

Perhaps, and it is a small domain: The only people who think WebRTC is "too complicated" seem to be game developers.

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

#299
post #257

Earlier quoted context omitted.

only QtQuick thiugh, Qt Widgets aren't really optimized for GL

Qt Widgets are kind of legacy, as all new development efforts are focused on QML.

are they ? the latest version has a bunch of new things: https://wiki.qt.io/New_Features_in_Qt_5.10 and the git seems relatively active: https://github.com/qt/qtbase/tree/dev/src/widgets

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

#300

Earlier quoted context omitted.

I've been thinking lately there should be a file format that's just WebAssembly along with WebAssembly-versions of WebGL, Web Audio and WebRTC. With the goal of making the runtime simpler to implement for non-browser venders. While browser vendors could add a profile to run the format.

... or to just load it up in the browser and skip the HTML part. Non-browser vendors will probably have to integrate browsers.

That completely misses the point which is a simpler format to implement and support.
Post reply on HN