this post was submitted on 27 Dec 2023
721 points (98.5% liked)

Programmer Humor

19512 readers
315 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] fiah@discuss.tchncs.de 22 points 10 months ago (2 children)

Can you write a website in other languages, like c# or python?

sure, as long as it compiles to javascript

[–] Bye@lemmy.world 7 points 10 months ago (4 children)

But the browser can’t handle other languages? That seems a bit silly

[–] pankkake@lemmy.world 17 points 10 months ago (1 children)

There's a push towards WebAssembly. Officially it's not supported yet, but most browsers can handle it. I don't know how mature the project is though.

But yeah, essentially everything on the web is JS.

[–] Static_Rocket@lemmy.world 15 points 10 months ago (2 children)

Even webassembly needs a JS stub loader right now. I still can't believe that's a requirement.

[–] Ephera@lemmy.ml 3 points 10 months ago (1 children)

Sure, but you can get frameworks that generate that for you. I've written whole webpages in WASM without writing any JS.

You don't get around reading JS documentation, though. Especially the DOM API is just documented as JS, and you basically hope that your framework makes it obvious enough how to write that in your non-JS language of choice.

[–] Static_Rocket@lemmy.world 5 points 10 months ago (1 children)

This is exactly the reason why I can't believe that was ever a requirement. I would have crazy respect for webassembly if it could stand on it's own as it would allow people to completely move away from JS, but if JS is still in the stack in any way it will introduce a (even if it is minimal) compatibility and maintenance cost in the long run.

[–] Ephera@lemmy.ml 3 points 10 months ago

I used to think so, too, but on the one hand, the DOM API is absolutely massive. Going through the standardization, implementation and documentation process another time would take decades.

And on the other hand, a language-agnostic API in WebAssembly would mean specifying it WebAssembly itself. And well, it's Assembly-like, so what's currently a single line for calling a JS function would turn into tens of lines of low-level code.

Ultimately, you'd want code from some other high-level language to give you a summary of how you may need to call your language-specific wrapper. In practice, that's likely even worse than translating it from JS, because the high-level call isn't standardized.

[–] lseif@sopuli.xyz 2 points 10 months ago (1 children)

i believe they plan to remove that requirement? at least i know they are trying to use a native wasm<->dom api instead of wasm<->js<->dom, which is slow

[–] Static_Rocket@lemmy.world 1 points 10 months ago (1 children)

Big if true, do you have a link to follow that development? I've been curious about some languages that compile to JS+WASM but I've been waiting for something like this to finally cut out the middle man and give me an excuse to learn WASM directly.

[–] lseif@sopuli.xyz 1 points 10 months ago

its just what i have heard.

[–] Anafabula@discuss.tchncs.de 5 points 10 months ago

If they could, JavaScript wouldn't be nearly a popular

[–] mindbleach@sh.itjust.works 3 points 10 months ago

When you see the entire world agree to one standard about anything, leave it the fuck alone.

[–] Ephera@lemmy.ml 3 points 10 months ago

There's actually in theory all the pieces in place to use a different scripting language, because in the early days, there really were multiple. But yeah, the massive DOM API is only really standardized+implemented+documented for JS, so you don't get around it in the end.

As the others said, though, WebAssembly is starting to become a thing and the JS boilerplate for calling the DOM API can be generated for you.

[–] Turun@feddit.de 1 points 10 months ago