r/ProgrammingLanguages • • Dec 27 '22

General Request to all Programming Language designers

It's usefull to be able to play in the browser for example nodejs webcontainer has been very welcomed Introducing WebContainers: Run Node.js natively in your browser (stackblitz.com)

Setting up nodejs locally is a pain in the ass all the more for new programming language. So would be great if you think about having a wasm version for the browser.

0 Upvotes

16 comments sorted by

5

u/editor_of_the_beast Dec 28 '22

Who implements programming languages in node?

1

u/[deleted] Dec 29 '22

you misread it's not about implementing in node.

4

u/cxzuk Dec 27 '22

Hi Lepinek,

From a project management perspective, I agree with you. Considering how to deliver the compiler toolkit and make it accessible in its early stages is really important, and I believe that web+wasm is an interesting proposition.

A word of caution however. From my experiments, WASM isn't quite ready for mainstream. The number of languages to fully support WASM output is quite low and restrictive.

One of these restrictions is with interacting with the DOM. The most reliable way I've come to see is having the wasm part just be a library that the HTML+JS calls. But this is also challenging because a HTML editor is really difficult to get working correctly.

The alternative is to use a canvas/GL to draw the interface - which is a considerable amount of work.

Kind regards,

M ✌

1

u/[deleted] Dec 29 '22

Well something like Pyodide: is a port of CPython to WebAssembly/Emscripten https://pyodide.org/en/stable/

2

u/[deleted] Dec 27 '22

Does the playgrounds send the file to a server and return the output of the compiler or do they run on the browser directly?

2

u/[deleted] Dec 27 '22

playgrounds that send file to a server exists since long. Innovation for nodejs webcontainers is it can simulate a whole server environment in the browser.

3

u/[deleted] Dec 27 '22

But what is the benefit of simulating all in the browser?

7

u/JackoKomm Dec 27 '22

If you just send the Code to your backend and run it, there are lot's of safety issues. People could write programs that never return and just use the CPU. You want to detect that or otherwise people could crash your Server. People could try to do some Bad stuff with your Server so you don't want to give the code too much rights. You could rum the Code in a virtual environment but there are ways to break out. People could send requests from your Server which you don't want. You don't want your Server be Part of a botnet or do other criminal stuff. There are lot's of things to consider. Or you just let them run their Code in their Browser so you don't have to think about all those things.

2

u/[deleted] Dec 27 '22

Nice reply. Thank you very much!

2

u/StdAds Dec 28 '22

I use rust to implement my compiler and it is insanely easy to compile to wasm. Rust also generate a JavaScript file for you so you do not need to know anything about wasm.

1

u/[deleted] Dec 29 '22

didn't know that.

9

u/Uncaffeinated 1subml, polysubml, cubiml Dec 27 '22

I did this for CubiML, but that was relatively easy because it compiles to JS. Doing it for a native language would be a lot harder because you'd need a second backend for WASM generation. It's an even bigger issue for native-ish languages like Go with a big runtime (and hence not easy to port to WASM), but with features which can't be converted to JS either.

-2

u/EmiiKhaos Dec 27 '22

Use nvm

1

u/[deleted] Dec 27 '22

you need to install.

-1

u/EmiiKhaos Dec 27 '22

Yeah, nvm makes it dramatically easy to install

-1

u/[deleted] Dec 27 '22

not true and you have to waste some space on your disk ec. that's the reason of success of online playgrounds. And discussion is not about just nodejs ;)