Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support bun as an alternative to nodejs for the server runtime environment #19

Closed
williamstein opened this issue Jul 25, 2022 · 5 comments
Labels
enhancement New feature or request

Comments

@williamstein
Copy link
Contributor

Currently we use node.js for tooling and running python-wasm on the command line.

However, there is a new project https://bun.sh/ that is similar to Node.js, but written using Zig instead of C/C++. Since (1) we're also using Zig and typescript extensively for python-wasm, and (2) bun is very fast and modern with native typescript support, it would be natural to use bun for python-wasm, at least optionally. It might me faster startup times, faster execution, etc., and also easier to read code if we want to dive into the runtime itself. A blocker prerequisite for this is WebWorker support, which bun.sh does NOT have. It's on the roadmap here:

oven-sh/bun#159

@williamstein
Copy link
Contributor Author

WebWorker support might not be a blocker at all. I can instead write a native extension module and use that to get input from stdin. I don't see any reason why that wouldn't work...

@williamstein
Copy link
Contributor Author

WebWorker support is definitely not a blocker, though of course there will be limitations (only a single webassembly process can possibly run at once for subprocess.Popen). Regarding the native extension module, it looks like I should instead have a version of our posix-node package that instead is written using Bun FFI, which fully supports using Zig.

@williamstein
Copy link
Contributor Author

Here's the webworker thread: nodejs/node#43583

Also, it would be interesting to see how's bun's event loop, etc., deals with just forking/execing via bun ffi (and stopping it). Maybe it behaves differently than node.js, which randomly crashes!? If os, we might not need webworkers for our use case, and can rewrite to use them later when they are implemented.

@williamstein williamstein changed the title keep an eye on bun.sh (as an alternative to node.js) support bun as an alternative to nodejs for the zython server runtime environment Oct 7, 2022
@williamstein williamstein added the enhancement New feature or request label Oct 7, 2022
@williamstein williamstein changed the title support bun as an alternative to nodejs for the zython server runtime environment support bun as an alternative to nodejs for the server runtime environment Oct 30, 2022
@williamstein
Copy link
Contributor Author

The first step would be to port the debug package

https://www.npmjs.com/package/debug

to work with bun, since we use it everywhere and it is very helpful with debugging. Currently it doesn't import because process.stderr doesn't exist with bun, but it is assumed to exist by debug.

@williamstein
Copy link
Contributor Author

I may revisit this in a year or so, but for now the focus will be 100% on node.js, due to wide support and integration with electron.js, and no compelling advantage for cowasm to use something else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant