News for hackers. Stuff that matters.
Re:We replaced our React front end with Go and WebAssembly by notpushkin on Monday February 10, 2025 @11:10PM (#43008859)
I was slightly worried it would be one of those “render to canvas” frameworks (which are an accessibility nightmare and are ever so slightly broken), but that’s not the case here! Looks like WASM – DOM interop is finally fast enough for this to work.

32 MB binary is a big no-no though.

Re:We replaced our React front end with Go and WebAssembly by kolanos on Monday February 10, 2025 @11:42PM (#43009049)
Looks like it was compressed to 4MB, but still.
Re:We replaced our React front end with Go and WebAssembly by nicoburns on Monday February 10, 2025 @11:53PM (#43009113)
Yeah, but with most JavaScript frameworks (and even Rust compiled to WASM), 4MB (at most!) would be the size of the uncompressed bundle.
Re:We replaced our React front end with Go and WebAssembly by aledalgrande on Tuesday February 11, 2025 @01:19AM (#43009587)
Figma is much more than that and lots of people use it daily
Re:We replaced our React front end with Go and WebAssembly by theanonymousone on Tuesday February 11, 2025 @02:00AM (#43009821)
Coincidentally, I just checked the LinkedIn page of a colleague, and Vivaldi said it was loading ~30MB of data for that.
Re:We replaced our React front end with Go and WebAssembly by golergka on Tuesday February 11, 2025 @12:31AM (#43009319)
Not a fan of this bundle size, but it's not a web store landing page — it's a professional application, and it's users are likely to use it extensively through their day, and all hundreds of navigation events and new tabs will (if handled correctly) hit the same cached bundle.
Re:We replaced our React front end with Go and WebAssembly by notpushkin on Tuesday February 11, 2025 @02:12AM (#43009897)
It’s a good point, but keep in mind that’s 32 MB of code: you can cache it, but you still have to parse and initialize it for every tab. (It might not be as bad as it sounds, WASM is lighter in this aspect than JS; but it’s still a good proxy for startup performance IMO.)

It should work well for applications with longer session size, like Figma: you open a project one time and work on it for hours. I’m not sure if that’s the case with Dagger Cloud: you might be looking at a single trace, or compare dozens of builds throughout the day. The post only claims “better overall performance and lower memory usage”, but without any numbers it’s hard to tell anything.

Re:We replaced our React front end with Go and WebAssembly by gedw99 on Sunday February 16, 2025 @03:32AM (#43066388)
I use golang WASM and use web workers and shared workers with a service worker.

This means that a new tab does not reload the whole thing each time.

Once you get it going it’s easy to build large complex systems.

Re:We replaced our React front end with Go and WebAssembly by whitehexagon on Tuesday February 11, 2025 @01:13AM (#43009555)
I also struggled with the binary output size of Golang WASM, and that it was growing with each version. Someone recommended TinyGo, and although I haven't needed it for a couple years now, at the time the WASM binary output size was much better.

Now I am settled on Zig/WASM, which gets me pretty close to C/WASM combo i.e. tiny. The JS bridge has some overhead, but I've rewritten most of that and it works good enough for canvas 2D/3D or even DOM. It would be nice to ditch the JS bits, and I suspect the compositors all-the-way down are probably hitting my 2D performance.

Re:We replaced our React front end with Go and WebAssembly by notpushkin on Tuesday February 11, 2025 @02:17AM (#43009928)
I’ve been looking at Zig for some time, too. Perhaps I should give it a go!

Any particular tricks on making bridged DOM fast?

Re:We replaced our React front end with Go and WebAssembly by qvq on Tuesday February 11, 2025 @07:28AM (#43012018)
Re:We replaced our React front end with Go and WebAssembly by whitehexagon on Tuesday February 11, 2025 @09:57AM (#43013456)
I use a custom API on the JS side, and making the most of the shared memory for strings. For widget creation within DOM I have small API wrappers on the JS side to avoid too much bridge crossing with attribute sets/gets.

For 2D/3D moving the canvas animation loop to the JS side helped.

So far the html (inc custom JS API) comes in at 20KB, and my wasm around 80KB (SVG based UI with a small embedded font).

Not sure how the latest Zig compares, but I'd be quite happy stuck on this older version for this project because it seems very stable.

Re:We replaced our React front end with Go and WebAssembly by J_Shelby_J on Tuesday February 11, 2025 @01:17AM (#43009575)
i swear, some people hate rust as much as the comment sections claim rust people are fanatics
Re:We replaced our React front end with Go and WebAssembly by WhyNotHugo on Tuesday February 11, 2025 @05:03AM (#43010937)
I had the same worry: that they'd be rendering everything into a canvas. It's very neat to see that the WASM<>DOM interop is there now, and they render actual native elements. Even inspecting the DOM it's quite readable (far easier to read that I've seen React produce).

OTOH, Rust solutions have been pretty disappointing so far; usually relying on macros (which are a pain to write, debug or maintain in any way) and lots of DSLs (which negate the value of any development tools).

The binary size for this approach is a big issue, but assuming that it can be decreased, I'd think that go can end up being a very viable candidate in this space.