Live data from Hacker News

What makes WebAssembly fast?

hacks.mozilla.org

171–180 of 238 posts

Re: What makes WebAssembly fast?

#171

My excitement for WASM has nothing to do with speed or efficiency of the runtime. It's all about finally having a universal compile target for the web. We're finally going to be able to develop web apps in a proper language of our own choosing, without needing hacks like TypeScript. Hopefully, this will lead to real dedicated IDE tooling and standardized libraries for the web along the lines of what's available in iO…

True. I agree with it all. However, by then, TypeScript might be so darn good that people choose to keep going with it! It really does have a better type system than C# in a lot of ways.

It could be another target for TypeScript though.

Re: What makes WebAssembly fast?

#172
post #74

Earlier quoted context omitted.

> something else that offers native bindings to other languages will eventually... No it won't. This is our one chance to kill javascript; if we don't do it now, it'll be entrenched forever, and best we'll ever get is 'compiles-to-js' languages like clojurescript and typescript. Let's be realistic; who has the man power, community good will and business savvy to push an entirely new language across all platforms, mob…

> This is our one chance to kill javascript; if we don't do it now, it'll be entrenched forever, and best we'll ever get is 'compiles-to-js' languages like clojurescript and typescript. Do people really hate JavaScript that much? I've grown fond of it in recent years, especially after ES6.

I don't hate it, I just don't find it as productive as the server side language I use.

Re: What makes WebAssembly fast?

#173

Earlier quoted context omitted.

They are trying to convert current web devs. JS is the language of the browser and essentially the web, so most developers working in webdev primarily work w/ js.

Actually many of us use es6 with a compiler to turn into some dialect of js that runs in browsers. We will hardly notice if our code starts getting compiled to wasm instead..

JS will not compile to WASM.

Re: What makes WebAssembly fast?

#174

My excitement for WASM has nothing to do with speed or efficiency of the runtime. It's all about finally having a universal compile target for the web. We're finally going to be able to develop web apps in a proper language of our own choosing, without needing hacks like TypeScript. Hopefully, this will lead to real dedicated IDE tooling and standardized libraries for the web along the lines of what's available in iO…

True. I agree with it all. However, by then, TypeScript might be so darn good that people choose to keep going with it! It really does have a better type system than C# in a lot of ways.

Could you please elaborate on how TypeScript's type system is better than C#?

Re: What makes WebAssembly fast?

#175

Earlier quoted context omitted.

True. I agree with it all. However, by then, TypeScript might be so darn good that people choose to keep going with it! It really does have a better type system than C# in a lot of ways.

It could be another target for TypeScript though.

Typescript is designed to be compiled to JS. WASM is designed for staticly compiled languages. Even if there is GC and DOM access through WASM, Typescript will be better off to run for the natively JIT optimized JS path.

Re: What makes WebAssembly fast?

#176

Earlier quoted context omitted.

JavaScript is strong competition both on the front end (source ecosystem) and the back end (compiler target). For people who don't want to use JavaScript (they are using a different source ecosystem), compile-to-WebAssembly toolchains will be in direct competition with compile-to-JavaScript toolchains. It's not at all clear which ones will win. It may be different for each language. For C++ and Rust I'd expect WebAss…

To be fair, a generational mark-sweep GC algorithm doesn't take much more space over the compile-time modifications to the code itself. A reasonably performant GC algorithm suitable for most front-end work would probably only add about 10 kilobytes to 20 kilobytes of code to an executable. That can be downloaded and cached in the blink of an eye.

The problem is that you need to get all the GC root nodes on the stack. This is platform specific and must be implemented by the browser. The only crossplatform way is to create an additional shadow stack that contains only the root nodes but this means you pay an additional cost for the GC on every function invocation.

Re: What makes WebAssembly fast?

#177

My excitement for WASM has nothing to do with speed or efficiency of the runtime. It's all about finally having a universal compile target for the web. We're finally going to be able to develop web apps in a proper language of our own choosing, without needing hacks like TypeScript. Hopefully, this will lead to real dedicated IDE tooling and standardized libraries for the web along the lines of what's available in iO…

Is it possible to run an efficient garbage-collected runtime system on top of WASM? And how about a multithreaded one?

Re: What makes WebAssembly fast?

#178

Earlier quoted context omitted.

True. I agree with it all. However, by then, TypeScript might be so darn good that people choose to keep going with it! It really does have a better type system than C# in a lot of ways.

Could you please elaborate on how TypeScript's type system is better than C#?

I disagree with OP, but two interesting corollaries of TS type semantics are its strong type inference and structural typing:

Const x = [{x: 3, y: "hi"}, {x: 9, y: "bye"}];

Automatically gets you x: "Array of {x : number, y: string }". And if you declare the same type somewhere else, as long as they're "structurally equivalent" (i.e. same x and y types) you can actually use them interchangeably. You can't do that e.g. with c#, where one class will never be exchangeable with an unrelated class , no matter how similar the definitions.

This lets you do some funny stuff like"subset type detection ": https://gist.github.com/hraban/66c1778cdd31868034b12db93fcce...

All in all, it's more of an oddity than an actual strength, if you ask me. It's necessary to emulate JS semantics, but I wouldn't consider it an advantage in a new language.

Re: What makes WebAssembly fast?

#179
post #76

Earlier quoted context omitted.

> something else that offers native bindings to other languages will eventually... No it won't. This is our one chance to kill javascript; if we don't do it now, it'll be entrenched forever, and best we'll ever get is 'compiles-to-js' languages like clojurescript and typescript. Let's be realistic; who has the man power, community good will and business savvy to push an entirely new language across all platforms, mob…

Wild guess? Oracle with Java.

If Sun had not killed Hotjava and continued to develop and market it, Java instead of JS might have been the frontend web programming language today. There were millions of Java applets written in a very short time and a Java browser would have been a first class citizen for hosting those apps.

Re: What makes WebAssembly fast?

#180
post #173

Earlier quoted context omitted.

Actually many of us use es6 with a compiler to turn into some dialect of js that runs in browsers. We will hardly notice if our code starts getting compiled to wasm instead..

JS will not compile to WASM.

Eh, there isn't any reason that it couldn't at some point in the future. That won't be happening any time soon, but I'd love to see that day, personally.
Post reply on HN