4 ms·
Figma is built using WASM, sees significant benefit from it, and is pretty popular. But absolutely there are a lot of of less demanding web applications out th
by matthewowen 3y ago
Figma is built using WASM, sees significant benefit from it, and is pretty popular.
But absolutely there are a lot of of less demanding web applications out there that don’t need this. And in the case of Figma, it’s the core of the application that uses WASM, with the more webby UI bits outside of it for all the devex reasons you’d expect.
In truth it’s a medium deal in the sense that it enables use cases that simply aren’t feasible without it, but is arguably irrelevant for most “conventional” web dev problems.
In that vein I’d argue it is more relevant for use cases that currently aren’t on the web at all versus as an improvement for those that are.
- 3cats-in-a-coat 3y agoI can’t stand Figma, it’s limited, slow and in general, demonstrating nothing at all for its wasm use so that’s kind in support of my point. Something like Figma would get a lot more performance out of using WebGL. Which is only accessible through JS, and the emscripten bindings for it go through JS calls. So WASM is kind of a dead weight in this scenario.
- paulgb 3y agoThe company was last valued at $20B so they are doing something right. They are using WebGL. Using WebGL from WebAssembly has some nice advantages; with Wasm you can use languages that are more accommodating to the sort of densely-packed data that you need to send to GPU buffers. Here’s an interview I did with a raster graphics editor that touches on why they use Wasm for GPU. https://digest.browsertech.com/archive/browsertech-digest-how-modyfi-is-building-with/ https://digest.browsertech.com/archive/browsertech-digest-ho...
- 3cats-in-a-coat 3y agoAccommodating how? Everything goes through JS, what they share is basically an ArrayBuffer (if we're talking command buffers) which you can build directly in JS with the same JIT backend that powers WASM. I went through your article but it doesn't describe how is WASM more "accomodating" to this. One way or another, the command buffers are an encoding process. They're not WASM code nor JS code, they're GPU code. You need to build them from one platform for another platform. There's no any direct correspondence between WASM and WebGPU, let alone WebGL.
- paulgb 3y agoAccommodating in the sense that in a language where you control the memory layout of objects, you don’t have to explicitly do an explicit encoding step, you can just specify a memory layout that the GPU can understand. This makes it a lot nicer to work with in my experience. Here’s an example of a Rust object with a layout that can be sent directly to a GPU buffer: https://github.com/paulgb/webgl2-glyph/blob/ef5a64a708856d67fe8222da69f6b7754cdd5321/src/vertex.rs#L7 https://github.com/paulgb/webgl2-glyph/blob/ef5a64a708856d67...
- 3cats-in-a-coat 3y agoI wonder if you have an object whose state has that same schema tied to a DataView offset if it'd be much different tbh.
- paulgb 3y agoYou could create a JS object with accessor functions that stores an offset, but the object itself still takes up heap space. In Rust, it would just be a (typed) pointer to the position in the buffer and wouldn't require an allocation.
- 3cats-in-a-coat 3y agoIt's trivial to fix with an ECS layout, but the point is does it matter.
- robertlagrant 3y ago> so they are doing something right That doesn't mean it's a technical thing they're doing right, particularly.
- paulgb 3y agoSure, but it was meant to refute a pretty weak point that basically boiled down to “I don’t like it so it’s bad”. Enough people do like it and find it fast, and while I can match anecdotes, pointing out the success of the company seemed more compelling.
- o1y32 3y agoPeople bring up Figma in almost any discussion related to WebAssembly. I tried to dig into this and understand why they chose this, what kind of benefit they are getting from this and how it compares to alternatives. Turns out that there is no comparison in performance because the alternative (doing everything in JS) was never done, and the choice of going WebAssembly is more due to their history and stack than anything else. In other words, if they rewrote the whole thing with modern JavaScript ecosystem (e.g. TypeScript with strict typing, typed array), it is unclear that the product would be any worse than the current implementation, because nobody ever tried that. Therefore, "Figma is built on WebAssembly so WebAssembly is good" is weak argument.
- matthewowen 3y agoI work at Figma. Mostly not in that part of the codebase, but close enough to say that it would be worse if we did what you are describing.