Live data from Hacker News

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

tbfleming.github.io

301–310 of 318 posts

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

#301

Earlier quoted context omitted.

I'm not sure why you are down voted as all that is true and easily verified.

It's not comparable for one simple reason - all the listed techs worked in the browser, but they didn't come with the browser (or, at least, with all browsers). WebAssembly does - and because most browsers auto-update these days, users get on the bandwagon without doing anything at all.

I don't think there were many mainstream browsers without Flash, ActiveX was included in IE when it was the dominant browser.

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

#302
post #298

Earlier quoted context omitted.

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 advert…

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

No you can't since netcode.io authenticates packets with a public/private key pair and a sequence id. If either the sequence id has been seen recently or key sig fails it won't accept the connection.

Netcode.io was built by someone who dealt with millions of clients and shipped many high volume games so this isn't anything new.

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

Nope, nope and nope.

For one, packet drops tend to happen in bursts so your multiplexed TCP/IP clients just means you're resilient to N+1 drops. Detecting a packet drop is not trivial and you need to go through a whole syn/syn-ack/ack if you recreate. Dropped TCP/IP sockets also don't clean up immediately so you can easily exhaust your available socket resources with this technique.

I played the game that you mentioned and if you seen in the comments the netcode was not ideal. It was pretty obvious that there was some head-of-line blocking even with multiple sockets. Compare that to something like Subspace that ran on a single 250-400ms 56K connection seamlessly back in '99.

Look, I'm sure you're an expert in WebRTC but you don't understand the technical requirements for a realtime netcode. Rather than trying to tell us how we're 'wrong' try listening instead. Games have a pretty unique set of requirements which is exactly why you haven't seen off the shelf solutions like WebRTC gain any traction.

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

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

Most users spend >80% of their time in the browser. It's probably that simple. If you have a thing and you need users, are you really going to deliver it as a Qt app? Unless you're bitcoin, it's hard to think of a case. I'd say "or a game," but many are webapps. And at this point some of the hollywood-grade games might figure out a way to be coming to browsers soon. Unreal did it.

> I'd say "or a game," but many are webapps.

Not yet, the though I think this will be true eventually

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

#304
post #298

Earlier quoted context omitted.

> 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 advert…

> 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. No you can't since netcode.io authenticates packets with a public/private key pair and a sequence id. If either the sequence id has been seen recently or key sig fails it won't accept the connection. Netcode.io was built b…

> No you can't since netcode.io authenticates packets with a public/private key pair and a sequence id. If either the sequence id has been seen recently or key sig fails it won't accept the connection.

How exactly do you think netcode.io knows that I own (or don't own) 151.101.193.67?

What exactly do you think prevents me from modifying my own netcode.io server at 151.196.182.212 from listing that IP address as one of the game servers?

It's a legitimate connection as far as the client is concerned, and that's what I have a few billion of.

Why do you think the public/private key or sequence ID has anything to do with this? Why do you think for a denial of service attack I care if the "server" 151.101.193.67 accepts the "connection" or not?

> Netcode.io was built by someone who dealt with millions of clients and shipped many high volume games so this isn't anything new.

If it helps you, I've built software with an install-base over a billion, in a place where high latency and bugs don't just mean a dissatisfied customer, but loss of real money.

However talking credentials at this point doesn't help me. It is probably best you respond specifically to what you think is wrong with my thinking instead of bringing up how smart you think your friends are.

> packet drops tend to happen in bursts so your multiplexed TCP/IP clients just means you're resilient to N+1 drops.

If you want to send datagrams at 20hz, and your RTT is 200ms, then 10 connections is equivalent in throughput and latency to UDP: Simply send datagrams down the channel. One side detect a stall? Tear down the channel and move to the next one. Even if you lose 10 packets in a row, the 50msec timer tick means you still recover at least one channel before the 200msec mark.

It's the same as UDP because it's the same number of packets. You can convince yourself of this with tcpdump, and subtract the TCP connect/teardown packets (which aren't blocking anything).

> Look, I'm sure you're an expert in WebRTC but you don't understand the technical requirements for a realtime netcode.

Accepted, at least for these discussions.

One of the principal authors of netcode[1] says that he doesn't understand WebRTC. He says it's too complex.

I have given several examples of things it does better than the published version of netcode if it were immediately adopted by browser vendors, and unless those specific things are addressed, you are going to have a hard time convincing Google and Mozilla to include netcode.io JavaScript bindings.

I appreciate you don't think network address translation is important, and I realise you don't understand the denial of service attack vector I'm describing yet. I think these things are important because I am experienced with their impact, and I know how WebRTC protects users from these things.

You can put your energy into understanding this attack vector, and what others might lay around also hidden from view, or your can put your energy into solving the problems that might make WebRTC a poor fit for game developers. In either case, you probably need to learn WebRTC.

[1]: https://gafferongames.com/post/why_cant_i_send_udp_packets_f...

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

#305

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.

For every step towards browser-based apps there seems to be a step back again - e.g. React Native, Electron and Android Play on ChromeOS.

Back when the first iPhones debuted without an app store, Apple claimed that everyone could just use web apps. That didn't last long.

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

#306
post #172
post #156

Earlier quoted context omitted.

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 dow…

Browsers are pretty terrible at downloading more than a few hundred MB. They can't compare to native download managers like Steam or Blizzard's, or even wget.

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

#307
post #249

Earlier quoted context omitted.

> HTML is a pain for things that aren't documents. Indeed it is but there seem to be no relevant alternative. The only thing that is better [for apps] is XAML (WPF) but it is Windows-only.

No, there are other XAML variants, like Avalon and Xamarin.Forms. JavaFX also follows the same design ideas. And there is QML as well.

Xamarin.Forms is cool but still doesn't work on Linux so it seems the same story as XAML to me - cool but of little use, unlike to HTML which is less cool but absolutely useful as it works everywhere. JavaFX - doesn't work on mobiles/tablets (there was a prototype in 2011, seemingly abandoned), sadly it seems to be about as dead as Flash and Silverlight now. As for QML - search results suggest it works everywhere but still hardly a popular choice for some reason, worth taking a closer look perhaps (but I still doubt it can compare to HTML as using Qt means producing binary builds for every platform to support AFAIK).

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

#308
post #257

Earlier quoted context omitted.

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

C++ Widgets are focused on desktop applications, for mobile and embedded devices, QML is the only way to go.

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

#309
post #249

Earlier quoted context omitted.

No, there are other XAML variants, like Avalon and Xamarin.Forms. JavaFX also follows the same design ideas. And there is QML as well.

Xamarin.Forms is cool but still doesn't work on Linux so it seems the same story as XAML to me - cool but of little use, unlike to HTML which is less cool but absolutely useful as it works everywhere. JavaFX - doesn't work on mobiles/tablets (there was a prototype in 2011, seemingly abandoned), sadly it seems to be about as dead as Flash and Silverlight now. As for QML - search results suggest it works everywhere but…

Avalonia (which I mistyped as Avalon) works in Linux, so XAML works on Linux.

JavaFX surely works on mobile.

http://gluonhq.com/

HTML is useless without a binary build of a running browser, that doesn't expose platform specific APIs.

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

#310

Earlier quoted context omitted.

Replace “WebAssembly VM” with “JVM” and you will see how it’s already available, and why it won’t catch on.

The JVM doesn't compete with C or C++.

JVM Bytecode is not a low level bytecode. It doesn't support value types or aribtrary pointer manipulation within a sandboxed memory area. It has a lot of java semantics baked in. Performance in most cases is better than javascript but it still is in the same order of magnitude because you have little control over the memory layout.

Webassembly solves a problem that existing low level bytecodes like LLVM IR do not intend to solve. LLVM IR is not stable across LLVM versions and usually is optimized for a specific architecture.

JVM bytecode is stable but high level. LLVM IR is unstable and low level. WebAssembly is stable and low level.

They all solve different problems.

Post reply on HN