Hacker News new | ask | show | jobs
by kodablah 3035 days ago
> Go’s garbage collection is fully supported. WebAssembly is planning to add its own garbage collection, but it is hard to imagine that it would yield a better performance than Go’s own GC which is specifically tailored to Go’s needs

I don't think it's hard to imagine reading the GC proposal. The JS collector that might be reused could be off thread, something WASM can't (yet) do.

> Most file system operations are mapped to Node.js’ “fs” module. In the browser, file system operations are currently not available.

Please please abstract this. As a maintainer of a non-JS WASM backend, I'd love to use Go too.

> Especially a “goto” operation in WebAssembly would be very helpful.

I didn't look into the Go use case enough, but curious how much better this would be than the current labeled block and labeled break approach in WASM. WASM has fairly strict stack/frame rules/types, so arbitrary gotos wouldn't work.

2 comments

> WASM has fairly strict stack/frame rules/types, so arbitrary gotos wouldn't work.

kinda funny because golang follows the same idea.

So I am curious how the presence of them in WASM would help
Jump-to-arbitrary-address / labels-as-values isn't made available to Go devs by Go-the-language, but seems required by Go-the-runtime+compiler, such as for compiling Goroutines.
It sort of does via channels, though. Sending a value to a bufferless channel causes the next goroutine to run (eventually). This looks a bit like a goto if you squint.

Go needs multiple stacks and a way to switch to executing a different stack. Web assembly could provide this in a high-level way.

>non-JS WASM backend

...what's a non-js wasm backend?

WebAssembly can be used anywhere. It is not tied to JavaScript in nature. So think of it kind of like the JVM in a way (but it's not an implementation, just a spec).
So people are using wasm in a non web context ?
Yes. Not a ton of people (yet), but yes, some are.
but why, if you have plenty of good languages to do this? Wasm is good for browsers because only choice we have is js.
I'm ignorant of the details, but WASM is an assembly language that's designed from the ground up for running untrusted code. It will also have multiple independent open source implementations, which has some nice properties.
WASM can be good for other things too. It is portable and fairly easy to target. It's like asking "why emscripten of you have plenty of other languages to choose from, LLVM is good for executables"
but i'm asking what are some webasm languages/backends/use cases that aren't a JS interpreter?
There is a work ongoing to enable WASM to be used for Etherum smart contracts, replacing the custom VM/bytecode.

One could use WASM for reconfigurable on-edge computing, all the way down to microcontrollers.

WASM for Ethereum would be amazing. There are a lot of languages with much better safety stories than the current one.