News for hackers. Stuff that matters.
Re:A 10x Faster TypeScript by zozbot234 on Tuesday March 11, 2025 @02:35PM (#43335639)
I think the Wasm backends for both Golang and LLVM have yet to support the Wasm GC extension, which would likely be needed for anything like real parity with JS. The present approach is effectively including a full GC implementation alongside your actual Golang code and running that within the Wasm linear memory array, which is not a very sensible approach.
Re:A 10x Faster TypeScript by maxloh on Tuesday March 11, 2025 @02:42PM (#43335690)
Yeah. If I remember it correctly, you need to compile the GC to run on WASM if the GC extension is not supported.
Re:A 10x Faster TypeScript by zozbot234 on Tuesday March 11, 2025 @02:45PM (#43335723)
The GC extension is supported within browsers and other WASM runtimes these days - it's effectively part of the standard. Compiler developers are dropping the ball.
Re:A 10x Faster TypeScript by AndrewDucker on Wednesday March 12, 2025 @09:26AM (#43343017)
The Wasm GC currently doesn't support the functionality needed by both Go and C#. (Interior pointers, for instance)

I'm hoping that a later version makes this possible.

Re:A 10x Faster TypeScript by mappu on Tuesday March 11, 2025 @05:27PM (#43337181)
The major roadblocks for WasmGC in Golang at the moment are (A) Go expects a non-moving GC which WasmGC is not obligated to provide; and (B) WasmGC does not support interior pointers, which Go requires.

https://github.com/golang/go/issues/63904#issuecomment-22536...

Re:A 10x Faster TypeScript by zozbot234 on Tuesday March 11, 2025 @07:08PM (#43338095)
These are no different than the issues you'd have in any language that compiles to WasmGC, because the new GC'd types are (AIUI) completely unrelated to the linear "heap" of ordinary WASM - they are pointed to via separate "reference" types that are not 'pointers' as normally understood. That whole part of the backend has to be reworked anyway, no matter what your source language is.
Re:A 10x Faster TypeScript by mappu on Tuesday March 11, 2025 @07:30PM (#43338260)
Go exposes raw pointers to the programmer, so from your description i think those semantics are too rudimentary to implement Go's semantics, there would need to be a WasmGC 2.0 to make this work.

It sounds like it would be a great fit for e.g. Lua though.

Re:A 10x Faster TypeScript by zozbot234 on Wednesday March 12, 2025 @04:03AM (#43340851)
I don't think Go supports any pointer arithmetic out-of-the-box? What it has in the base language is effectively references.
Re:A 10x Faster TypeScript by pjmlp on Wednesday March 12, 2025 @10:03AM (#43343369)
It does, via unsafe package, yes it does look ugly, that is on purpose.

    item := *(*int)(unsafe.Pointer(uintptr(start) + size*uintptr(i)))
A random example taken from Internet.
Re:A 10x Faster TypeScript by nasretdinov on Wednesday March 12, 2025 @10:52AM (#43343903)
The standard library uses unsafe for syscalls, for higher-performance primitives like strings.Builder, etc, so it's support is mandatory to run any non-trivial Go program
Re:A 10x Faster TypeScript by zozbot234 on Wednesday March 12, 2025 @11:18AM (#43344179)
Somehow I don't think Wasm-GC is going to support bare metal syscalls anytime soon. That stuff all has to be rewritten anyway if you want to target WASM.
Re:A 10x Faster TypeScript by nasretdinov on Wednesday March 12, 2025 @12:21PM (#43344845)
It's not just system calls. E.g. reflection package uses unsafe too: https://github.com/golang/go/blob/master/src/reflect/value.g... . Many packages from Go standard library use unsafe one way or the other, so it's not fair to say that unsafe package is separate from the rest of the language
Re:A 10x Faster TypeScript by mappu on Wednesday March 12, 2025 @03:50PM (#43346980)
For a while the GOOS=nacl port and the Google App Engine ports of Go disallowed unsafe pointer manipulation too, so there is some precedent. Throughout some of the ecosystem you can see pieces of "nounsafe" build tag support (e.g. in easyjson).
Re:A 10x Faster TypeScript by pjmlp on Thursday March 13, 2025 @07:14AM (#43352164)
Most programming languages that offer unsafe, either as language keyword, or meta package (unsafe/SYSTEM/UNSAFE whatever the name), have similar option, that doesn't make it less of a feature.
Re:A 10x Faster TypeScript by zozbot234 on Wednesday March 12, 2025 @10:44AM (#43343819)
That's not the base language, it's an unsafe superset. There's no reason why a Wasm-GC backend for Golang should be expected to support that by default.
Re:A 10x Faster TypeScript by pjmlp on Wednesday March 12, 2025 @12:26PM (#43344896)
If it is part of the language reference it is part of the language.

Usually when language reference books used to be printed, or we used ISO languages, what is there on paper, is the language.

We are only discussing semantics, if it is hardcoded primitives, or made available via the standard library, specially in case of blessed packages like unsafe which aren't fully implemented, rather magical types for the compiler.

Hence why the only thing you will see here is mostly documentation, https://github.com/golang/go/blob/master/src/unsafe/unsafe.g...

Which is nothing new since the 1960's that there are systems languages with some way to mark code unsafe, the C linage of languages are the ones that decided to ignore this approach.

Re:A 10x Faster TypeScript by mappu on Wednesday March 12, 2025 @04:08PM (#43347174)
It also has an address-of operator, you can take the address of the middle of a large array.

I suppose that would be possible with fat-pointers that are reference+offset.

Re:A 10x Faster TypeScript by yencabulator on Thursday March 13, 2025 @05:52PM (#43357582)
You can get a pointer inside a struct ("interior pointers") without pointer arithmetic.
Re:A 10x Faster TypeScript by nicoburns on Tuesday March 11, 2025 @06:37PM (#43337857)
> the Wasm GC extension, which would likely be needed for anything like real parity with JS

Well, for languages that use a GC. People who are writing WASM that exceeds JS in speed are typically doing it in Rust or C++.