News for hackers. Stuff that matters.
Re:WebAssembly Threads ready to try in Chrome 70 by Waterluvian on Monday October 29, 2018 @09:22PM (#18333263)
What's a solid language choice for targetting wasm if I want to kick the tires? Go?
Re:WebAssembly Threads ready to try in Chrome 70 by willglynn on Monday October 29, 2018 @09:29PM (#18333313)
Rust has a pretty great WebAssembly story:

https://rustwasm.github.io/book/

Learning Rust at the same time as Rust+WebAssembly might be a bit of a reach, though.

Re:WebAssembly Threads ready to try in Chrome 70 by jake_the_third on Tuesday October 30, 2018 @12:41AM (#18334047)
Is there documentation on Rust+WebAssembly that is presented more like a conventional book or tutorial?

I don't do well with example-driven documentation like these. Resources like the original rust book are excellent though.

Re:WebAssembly Threads ready to try in Chrome 70 by hencoappel on Tuesday October 30, 2018 @05:25AM (#18334987)
I'm going to have to be that guy and say, did you try googling it?

Here's one guide: https://hackernoon.com/compiling-rust-to-webassembly-guide-4...

Re:WebAssembly Threads ready to try in Chrome 70 by jake_the_third on Tuesday October 30, 2018 @08:05AM (#18335715)
I was under the impression that the wasm emscripten target was deprecated in favor of the rust-specific wasm target. Am I wrong?
Re:WebAssembly Threads ready to try in Chrome 70 by steveklabnik on Tuesday October 30, 2018 @08:40AM (#18335932)
You're not. Well, it's not officially deprecated, but it pretty much is, yeah.
Re:WebAssembly Threads ready to try in Chrome 70 by singularity2001 on Tuesday October 30, 2018 @03:31AM (#18334505)
Is there really that much to learn?

You can just target WebAssembly like this:

cargo +nightly build --target wasm32-unknown-unknown

Re:WebAssembly Threads ready to try in Chrome 70 by majewsky on Tuesday October 30, 2018 @05:06AM (#18334903)
Okay, then how do I run that? How do I interface with the JS/DOM world? (Those are rhetorical questions. I just mean to show that there is, in fact, more to learn.)
Re:WebAssembly Threads ready to try in Chrome 70 by v_lisivka on Tuesday October 30, 2018 @11:32AM (#18337554)
Try (after installing of rust and cargo via rustup):

  # Install support for "wasm" command for cargo:
  cargo install cargo-wasm
  # Install wasm target and wasm-gc tool:
  cargo wasm setup
  # Create new wasm project:
  cargo wasm new hello_world
and then in hello_world directory:

  # Build and run wasm project:
  cargo wasm run
Re:WebAssembly Threads ready to try in Chrome 70 by markdog12 on Tuesday October 30, 2018 @06:43AM (#18335299)
Re:WebAssembly Threads ready to try in Chrome 70 by sureaboutthis on Tuesday October 30, 2018 @06:10AM (#18335149)
C or C++. Everything started with C and the first language for everything will be C.

https://webassembly.org/docs/c-and-c++/

"WebAssembly is being designed to support C and C++ code well, right from the start..."

Re:WebAssembly Threads ready to try in Chrome 70 by enneff on Monday October 29, 2018 @10:12PM (#18333541)
I just started playing with Go's WebAssembly support last night. Support is still nascent but I was able to get up and running very quickly, and the API is dead simple: https://github.com/golang/go/wiki/WebAssembly
Re:WebAssembly Threads ready to try in Chrome 70 by justinclift on Tuesday October 30, 2018 @12:03AM (#18333947)
On the Go front, TinyGo (a subset of Go targeting embedded dev) recently added Wasm support:

https://github.com/aykevl/tinygo

It's output files are very small (~1kb for the toy examples), as it does dead code elimination, which is missing from the mainline Go approach (for now).

Both Go and TinyGo are in very early stages of their Wasm support though, so things are changing and updating fairly quickly. :)

Re:WebAssembly Threads ready to try in Chrome 70 by bloomer on Tuesday October 30, 2018 @02:39AM (#18334367)
The go compiler does dead code elimination. I'm not familiar with TinyGo but from the readme one thing it does do differently is drop the whole scheduler if there are no blocking go routines.
Re:WebAssembly Threads ready to try in Chrome 70 by justinclift on Wednesday October 31, 2018 @06:41PM (#18349817)
> The go compiler does dead code elimination.

For Wasm output? It really doesn't seem like it. Output binaries from the mainline Go compiler (atm) are ~2MB. Most of which is dead code.

Re:WebAssembly Threads ready to try in Chrome 70 by lytedev on Monday October 29, 2018 @09:26PM (#18333284)
Rust or C++ were easiest when I tried it last.
Re:WebAssembly Threads ready to try in Chrome 70 by eksemplar on Tuesday October 30, 2018 @01:52AM (#18334224)
.Net with Blazor.net is pretty neat.

C# doesn’t get a lot of love on HN, but we’re launching our first Blazor app in production this week and it’s been pretty easy to use.

Re:WebAssembly Threads ready to try in Chrome 70 by legulere on Tuesday October 30, 2018 @02:00AM (#18334248)
Blazor is (currently) using the mono .net interpreter compiled to WebAssembly. This seems to me more of a proof of concept than something you would really want to use.

With garbage collection support landing in WebAssembly we might see compilation of .net IL to WebAssembly, but that’s still out in the future.

Re:WebAssembly Threads ready to try in Chrome 70 by mattferderer on Tuesday October 30, 2018 @09:45AM (#18336371)
The really cool thing about Blazor is currently with a couple small changes, you can switch it to a server side "Razor Components" app. The idea behind the server side concept is that it uses Web Sockets to tell the browser what changes to make. All the logic happens on the server side.

There are a lot of pros & cons here to this way. Some pros are a fast initial render & small amount of bytes needing to be sent. Cons are you need internet access & render changes aren't as fast as client side.

This biggest pro I see though is being able to develop a front end app that you can later switch to Blazor/Web Assembly with the client taking over part of the logic when Blazor & Web Assembly are less experimental. For internal apps, or apps where you know the internet/network connection should always be good, this is a great way to go.

Re:WebAssembly Threads ready to try in Chrome 70 by eksemplar on Tuesday October 30, 2018 @02:16AM (#18334289)
We found it good enough to build internal apps. Better than our current JS setup because it’s far more productive.

It’ll make its way into .net core 3.0, so I think it’s more than just a poc.

It’s early of course and not very flexible, if you want to build something it wasn’t meant for, it breaks.

Re:WebAssembly Threads ready to try in Chrome 70 by singularity2001 on Tuesday October 30, 2018 @03:32AM (#18334512)
what's the performance penalty of the mono VM?
Re:WebAssembly Threads ready to try in Chrome 70 by eksemplar on Tuesday October 30, 2018 @04:34AM (#18334757)
Performance is fine, but it’s still too big for slow internet. A simple form for turning in signed data and starting an internal service is easily a few MB. Which isn’t a problem for internal solutions that never leave the administrative network, but we’ll keep doing vue and graphql Apollo for our apps that have to function on mobile networks for the time being.
Re:WebAssembly Threads ready to try in Chrome 70 by mathw on Tuesday October 30, 2018 @04:58AM (#18334858)
We had a look at Blazor at work the other week. My colleagues liked it, but on my computer the tooling crashed when asked to build the standard template project.

Like a lot of things these days, Blazor has a website way more polished than the actual product. It's very interesting, but I'm surprised you find it ready for use in production.

Re:WebAssembly Threads ready to try in Chrome 70 by tapirl on Monday October 29, 2018 @10:17PM (#18333565)
Currently, the c++ wasm tool chain is the most mature one.
Re:WebAssembly Threads ready to try in Chrome 70 by singularity2001 on Tuesday October 30, 2018 @03:29AM (#18334496)
Go has a large footprint with 2.5MB hello world wasm and some glue dependency.

Rust has a similar footprint at first sight but can be shrinked significantly:

wasm-gc test.wasm # 1.7MB -> 100 bytes

IMHO the rust language is quite ugly, so you might take a fresh look at c++ which became surprisingly readable with its new features (auto, initializer_lists, nice for loops, ...)

Re:WebAssembly Threads ready to try in Chrome 70 by kodablah on Tuesday October 30, 2018 @10:21AM (#18336677)
I wrote a PoC tool the other day that can shrink the Go emitted WASM by a little bit: https://github.com/cretz/go-wasm-bake
Re:WebAssembly Threads ready to try in Chrome 70 by kartan on Tuesday October 30, 2018 @10:58AM (#18337087)
C++ is already used in production by big companies. It currently is deployed as asm.js. But you can use an equivalent toolchain to create WebAssembly.

This way you can create production-ready code and be ready to move to WebAssembly as soon as it gets feature ready.

The fine control that C++ offers will help you to understand the underlying architecture and put its performance to test.

Re:WebAssembly Threads ready to try in Chrome 70 by ctcherry on Monday October 29, 2018 @09:29PM (#18333316)
Re:WebAssembly Threads ready to try in Chrome 70 by natorion on Tuesday October 30, 2018 @02:26AM (#18334323)
C++
Re:WebAssembly Threads ready to try in Chrome 70 by justincormack on Monday October 29, 2018 @11:33PM (#18333845)
Go doesn’t have thread support yet AFAIK.
Re:WebAssembly Threads ready to try in Chrome 70 by kodablah on Tuesday October 30, 2018 @10:22AM (#18336696)
While it may not support atomic ops yet, it still supports all language concurrency via suspend points throughout the WASM.
Re:WebAssembly Threads ready to try in Chrome 70 by stesch on Tuesday October 30, 2018 @05:19AM (#18334953)
Depending on what you are doing you shouldn't dismiss Unity3D and C#.

Adding multi-threading support for WebAssembly is on the roadmap for 2019.1