I recently used emsdk to build interpreters for languages like Python. Then I wrote an online code editor based on WebAssembly that supports languages such as Python, Lua, and Ruby. No backend is needed, the code runs directly in the browser. Therefore, apart from the initial loading of WASM resources, there are no other network delays, and the results are displayed almost instantly. It can generate shareable links, so now I include the link when posting code online, and clicking it shows the results.
Web Site:https://shift.js.org/
Source:https://github.com/hubenchang0515/shift
Example:
In addition, this project provides an NPM package and CDN links. Everyone can load the project's WASM resources to run the code online.
This is an example:
<html>
<body>
<!-- HTML Element to show the result -->
<pre id="output"></pre>
<script type="module">
// load js
import python from "https://shift.js.org/wasm/python.js";
import makeConfig from "https://shift.js.org/wasm/common.js";
// condo to run
const code =
`import platform
import sys
print(sys.version)
print(platform.platform())
`;
// callback to get result
const fn = (stdout) => document.querySelector("#output").innerText = stdout;
// run the code
python(makeConfig(code, fn));
</script>
</body>
</html>

