News for hackers. Stuff that matters.
Re:Missing the Point of WebAssembly by zengid on Tuesday January 09, 2024 @04:29PM (#38932360)
I think once WasmGC is finished up, that will make shipping a VM inside a VM more viable. Opening up direct access to the DOM would be cool, but if it were up to me, I'd just skip it and render everything inside a <canvas/> and avoid all of the "build an application on top of a document format" crap that makes web apps so weird to make.
Re:Missing the Point of WebAssembly by munificent on Tuesday January 09, 2024 @05:44PM (#38933355)
> if it were up to me, I'd just skip it and render everything inside a <canvas/>

That's very tempting, but you lose a lot if you do that, especially around text:

* Accessibility for screen readers, etc.

* The easy ability to select text, copy/paste between other apps, etc.

* Line splitting

* Support for multiple languages, RTL, and all their other rendering quirks.

Canvas has some text APIs, but they are fairly rudimentary. It's a hard problem.

Re:Missing the Point of WebAssembly by etimberg on Tuesday January 09, 2024 @10:05PM (#38935635)
> Canvas has some text APIs, but they are fairly rudimentary

That's an understatement for sure. `measureText` is not even close to feature parity with where windows apis were 25 years ago.

Or something like text underlines has to be done entirely manually.

Re:Missing the Point of WebAssembly by zengid on Wednesday January 10, 2024 @02:11PM (#38941963)
I completely agree, and these are required features for a full app that is planning to reach the world.

It requires a lot of extra work, but real world apps like Figma [0] are rendering directly to the canvas, and frameworks like Flutter offer support for canvas rendering (via Skia's CanvasKit) [1] [2].

I guess my point is that if someone is using WASM to ditch JavaScript, why stop there? Ditch the DOM and CSS too! Render all of the graphics with OpenGl or WebGPU!

There is a class of applications that I want to explore that would be better suited to by doing just that. I don't believe every app should do that, just that for what I want to build, that's where I'm looking at going (hence my "if it were up to me" comment above).

[0] https://www.figma.com/blog/building-a-professional-design-to...

[1] https://docs.flutter.dev/platform-integration/web/renderers

[2] https://skia.org/docs/user/modules/canvaskit/

Re:Missing the Point of WebAssembly by noman-land on Tuesday January 09, 2024 @04:45PM (#38932582)
Not a very accessible solution.
Re:Missing the Point of WebAssembly by zengid on Tuesday January 09, 2024 @05:42PM (#38933321)
It can be! I think that's the number 1 response when anyone wants to actually make a better platform. Projects like AccessKit are a really great step in the right direction https://github.com/AccessKit/accesskit
Re:Missing the Point of WebAssembly by noman-land on Tuesday January 09, 2024 @06:16PM (#38933729)
Cool, thanks for the share. I will check it out.
Re:Missing the Point of WebAssembly by 0x457 on Tuesday January 09, 2024 @09:05PM (#38935239)
> render everything inside a <canvas/> and avoid all of the "build an application on top of a document format" crap that makes web apps so weird to make.

We tried this with flash already. It has the same issues. Browsers provide _a lot more_ than just rendering your html+css. There are cases where it makes sense, but generally, it's a terrible idea. It will be like trying to make a visual novel using youtube in-video links.