News for hackers. Stuff that matters.
Re:Calls between JavaScript and WebAssembly are finally fast by bluejekyll on Monday October 08, 2018 @12:37PM (#18168923)
Very exciting! And really amazing work. It appears that WASM, at least in Firefox, is now going to be on par with JS in terms of performance when calling other JS facilities. Those comparison times are quite impressive.

I think the thing I found most exciting is at the end: “WebAssembly is getting more flexible types very soon. Experimental support for the current proposal is already landed in Firefox Nightly.” Implication being that WASM will have native access to the DOM.

I think at that point WASM could be used to fully work with the DOM with no negative costs, right?

Re:Calls between JavaScript and WebAssembly are finally fast by markharper on Monday October 08, 2018 @12:49PM (#18169021)
Almost, that will set the foundation for fully using the DOM APIs. The host bindings proposal mentioned at the end of the article should close the gap.
Re:Calls between JavaScript and WebAssembly are finally fast by benjaminjackman on Monday October 08, 2018 @12:58PM (#18169107)
Minor clarification:

The DOM builtins should be helped by the Reference Types Proposal for WebAssembly. [1]

`The host bindings proposal` is going to help speed up new and getter/setter calls. [2]

1: `Currently the only built-ins that we support this for are mostly limited to the math built-ins. That’s because WebAssembly currently only has support for integers and floats as value types.

That works well for the math functions because they work with numbers, but it doesn’t work out so well for other things like the DOM built-ins. So currently when you want to call one of those functions, you have to go through JavaScript. That’s what wasm-bindgen does for you.

But WebAssembly is getting more flexible types very soon. Experimental support for the current proposal is already landed in Firefox Nightly behind the pref javascript.options.wasm_gc. Once these types are in place, you will be able to call these other built-ins directly from WebAssembly without having to go through JS.`

-- https://github.com/WebAssembly/reference-types

2: `there are still a couple of built-ins where you will need to go through JavaScript. For example, if those built-ins are called as if they were using new or if they’re using a getter or setter. These remaining built-ins will be addressed with the host-bindings proposal.`

-- https://github.com/WebAssembly/host-bindings

(BTW I could be mistaken, just quoting the article)

Re:Calls between JavaScript and WebAssembly are finally fast by Karrot_Kream on Monday October 08, 2018 @02:25PM (#18169954)
What is `wasm_gc` all about?
Re:Calls between JavaScript and WebAssembly are finally fast by tyingq on Monday October 08, 2018 @03:13PM (#18170381)
The reason the switch is called that...

"A new proposal has been made to the WebAssembly specification committee a few months ago: to add reference types to the type system. Reference types are a new way to represent a reference to any host values. In a Web environment, this means being capable of playing with JavaScript values within WebAssembly. This is a huge difference with the existing type system, which only contains primitive types: integers represented on 32 or 64 bits, IEEE754 floating-point numbers represented on 32 or 64 bits. This is also a first step for implementing garbage collection (GC) integration within WebAssembly: since these reference values have been allocated on the GC heap in JavaScript, they need to be traced during wasm execution."

https://blog.benj.me/2018/07/04/mozilla-2018-faster-calls-an...

Re:Calls between JavaScript and WebAssembly are finally fast by singularity2001 on Monday October 08, 2018 @03:26PM (#18170523)
maybe the most important improvement will be direct memory access to the canvas bitmaps for super fast game rendering.
Re:Calls between JavaScript and WebAssembly are finally fast by bschwindHN on Monday October 08, 2018 @10:37PM (#18172937)
Wouldn't "super fast game rendering" be done by the GPU via WebGL?
Re:Calls between JavaScript and WebAssembly are finally fast by rafaelvasco on Tuesday October 09, 2018 @01:50PM (#18178181)
For 2D games it's much more convenient to pixel push directly than to deal with vertex buffers, index buffers, shaders... Unfortunately graphics cards are not optimized for that scenario.
Re:Calls between JavaScript and WebAssembly are finally fast by bschwindHN on Tuesday October 09, 2018 @09:02PM (#18181129)
Convenient, but "super fast"?

And though it's a matter of opinion, I disagree. The GPU is easier for me to use for things like screen-space shading, alpha blending, sprite transformations and distortions, and it all performs much faster than the equivalent CPU render code.

Re:Calls between JavaScript and WebAssembly are finally fast by ranwired on Tuesday October 09, 2018 @07:19AM (#18174950)
A lot of game logic also runs on the CPU
Re:Calls between JavaScript and WebAssembly are finally fast by TazeTSchnitzel on Tuesday October 09, 2018 @10:15AM (#18176131)
canvas bitmaps are only useful for rendering though.
Re:Calls between JavaScript and WebAssembly are finally fast by vanderZwan on Monday October 08, 2018 @03:50PM (#18170729)
Assuming that also implies access to typed arrays in general, then applications that involve number crunching become a lot more feasible in JS too.
Re:Calls between JavaScript and WebAssembly are finally fast by mrec on Monday October 08, 2018 @07:04PM (#18172084)
Huh? We've had typed arrays in JS for years. I think they originally went in to support WebGL, but you can use them for other stuff too.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

Re:Calls between JavaScript and WebAssembly are finally fast by vanderZwan on Monday October 08, 2018 @09:44PM (#18172750)
Direct access to typed arrays from WASM without having to copy them over whole first, or use the memory buffer of the WASM module. You can't really write a "true" generic in-place sort in WASM right now, so to speak, because there is always a copying back and forth step.