News for hackers. Stuff that matters.
Re:Learn WebAssembly by writing small programs by Philip-J-Fry on Tuesday September 05, 2023 @06:25PM (#37398649)
It's not the goal from what it seems. But it's definitely what would make it the most interesting to a lot of people, and it's what I think most people expected at some point.

For a lot of companies the only place JavaScript is ever used is on their website frontend. And it makes you wonder, why does it even still need to be JavaScript? With the rise of SPAs and the fall of normal document based websites, browsers are basically just becoming their own platform like Windows Desktop, Mac, Linux, Android, iOS, etc. You could say it's been that way for a long time, but more and more apps are becoming web based only because the browser is now powerful enough to run what used to be a desktop application.

Browsers are literally just a VM with an address bar. We go to a URL and run a program, except right now there's basically the limitation that the program has to be written at least partly in JavaScript. Being able to deploy an entire website as WASM is just the next logical step from what I see.

Re:Learn WebAssembly by writing small programs by math_dandy on Tuesday September 05, 2023 @10:08PM (#37400604)
The two language problem is, indeed, awkward.

DOM bindings in WASM would be awesome. I would be a happy nerd if I could do all of my web dev in OCaml.

In the meantime, WASM has real, just not for front end dev.

The two language problem is hardly unique to web dev. It’s also ubiquitous in the machine learning/data science space with Python and C/C++/CUDA playing the roles of JS and WASM, respectively.

Re:Learn WebAssembly by writing small programs by catlover76 on Tuesday September 05, 2023 @11:02PM (#37400884)
> I would be a happy nerd if I could do all of my web dev in OCaml.

You don't like Bonsai? Or do you just want something that doesn't "transpile" to JS at all?

Re:Learn WebAssembly by writing small programs by math_dandy on Wednesday September 06, 2023 @12:14AM (#37401281)
I find that these compile-to-JS languages are great until you want to bring in other JS libraries. Then you’re stuck writing bindings which is annoying, and often brittle if you’re not really careful.
Re:Learn WebAssembly by writing small programs by catlover76 on Wednesday September 06, 2023 @01:15AM (#37401558)
Oh I didn't even think of that--that sounds like a huge pain in the ass lol
Re:Learn WebAssembly by writing small programs by ReleaseCandidat on Wednesday September 06, 2023 @03:13AM (#37402150)
> DOM bindings in WASM would be awesome. I would be a happy nerd if I could do all of my web dev in OCaml.

DOM is not enough for that. You almost certainly would like to be able to communicate with your backend ;)

Here is a list of the "usual" web APIs: https://developer.mozilla.org/en-US/docs/Web/API And everything that needs network access or access to local resources (file system in the worst case) will never happen to WASM because of security considerations.

Re:Learn WebAssembly by writing small programs by xigoi on Wednesday September 06, 2023 @03:41AM (#37402337)
How is allowing WebAssembly to use the network any less secure than allowing JavaScript to use the network?
Re:Learn WebAssembly by writing small programs by ReleaseCandidat on Wednesday September 06, 2023 @04:06AM (#37402476)
Don't ask me :).

At least WASM will get DOM access (and hopefully access to similar web APIs) as soon as the GC is stable and usable.

   Once GC is supported, WebAssembly code would be able to reference and access JavaScript, DOM, and general WebIDL-defined objects.
https://webassembly.org/docs/web/
Re:Learn WebAssembly by writing small programs by lxgr on Wednesday September 06, 2023 @09:44AM (#37405037)
The issue here is the same-origin principle, which rules out most low-level networking (since you could just bring your own SOP-ignoring HTTP client).

Personally I think that enforcing the SOP at all cost (and even when no cookies or other authentication headers are injected by the browser) is misguided at this point and holding back modern webapps.

Re:Learn WebAssembly by writing small programs by sebastianz on Thursday September 07, 2023 @02:55AM (#37415590)
But you will be able to do network access though the fetch API, and fs access though its own API.
Re:Learn WebAssembly by writing small programs by zarzavat on Wednesday September 06, 2023 @02:16AM (#37401840)
You can certainly bridge the DOM to WASM with a virtual DOM. The problems with WASM are not just interoperability.

The biggest problem is tooling. You cannot build tooling for in-browser WASM because it runs in a browser sandbox. JS has the same problem but the difference is that JS has a known object model that the browser can provide good tooling for.

Whereas with WASM the browser has little insight into what those opaque Memory objects contain. So you need to bring your own tooling and run it inside the sandbox, and the sandboxing does not make this easy.

Let’s say for example you want to pause execution, inspect the object tree, and run a REPL while it’s paused.

Re:Learn WebAssembly by writing small programs by yieldcrv on Wednesday September 06, 2023 @02:31AM (#37401908)
If it was the JavaScript killer it will attract JavaScript devs and they’ll make it just like JavaScript

not syntax-wise just community wise, where the package and package managers are a mess and why there is demand for a JavaScript killer