3 ms·
With access to DOM it could run with no (or just very little) js, no ts-to-js transpiler, no web-framework-of-the-month wobbly frontends perpetually reinventing
by tpm 1y ago
With access to DOM it could run with no (or just very little) js, no ts-to-js transpiler, no web-framework-of-the-month wobbly frontends perpetually reinventing the wheel. One could use a sane language for the frontend. That would be quite the revolution.
- 3cats-in-a-coat 1y agoYou already can do that. You need a tiny shim and you can forget it's JS and use all WASM.
- tpm 1y agoCan you point me to a howto/tutorial?
- 3cats-in-a-coat 1y agoThis is wasm-dom for Rust: https://crates.io/crates/wasm-dom https://crates.io/crates/wasm-dom There's also web-sys. Those are Rust centric, I'm sure there are others, but basically you only need the whim once, and then you write in your language of choice and compile to WASM, you never have to think about JS. Although... I may question the purist attitude. But you can do it. Think of it like HTMX, the way people say it "avoids working with JS" (HTMX itself is written in JS). Same principle.
- tlb 1y agoYou can just interpolate bits of Javascript inside C++ to access the DOM, like so: #include <emscripten.h> void sayHello() { EM_ASM( let foo = document.getElementById('foo') foo.innerHTML = 'hello'; ); } See https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html#calling-javascript-from-c-c https://emscripten.org/docs/porting/connecting_cpp_and_javas...