3 ms·
Would it be possible to compile a nodejs app to a binary with this? If so, would performance be any better?
by heapjs 7y ago
Would it be possible to compile a nodejs app to a binary with this? If so, would performance be any better?
- mstade 7y agoI think you'd need to translate node specific APIs in order to make this work, e.g. i/o features and require function. It is probably more work than just rewriting the app to use QuickJS APIs instead, but I don't think it's impossible to make some sort of compatibility or translation layer. Couldn't say if it'd be more performant, but it'd have a killer feature over node: compilation to single binary without dependencies.
- dpacmittal 7y agoCouldn't you replace v8 with this and recompile the node binary? If it passes 100% ECMAScript tests, that should mean it's a drop-in replacement for v8. Correct me if I'm wrong.
- exebook 7y agofs/net and some other important pieces of Node.js are written as C++ addons for v8, hooking them would be very difficult I guess. Though Microsoft have been working on this for their ChakraCore engine. There was a conflict if I recall correctly, Microsoft suggested to add another abstraction layer to make hooking other JS engines easier but Node.js team refused it. I might not know that situation very well. But I have downloaded ChakraCore based Node.js once and it ran my project without problems, though the performance was about 5% slower.
- MuffinFlavored 7y agoHow could we easily expose syscalls to `qjs`? Deno is just a Rust IPC/syscall layer glued to V8 really...
- mstade 7y agoSome Node APIs could probably be implemented using the std and os modules[1], but others (e.g. networking) would probably need to be implemented via the C API[2]. [1]: https://bellard.org/quickjs/quickjs.html#Standard-library https://bellard.org/quickjs/quickjs.html#Standard-library [2]: https://bellard.org/quickjs/quickjs.html#QuickJS-C-API https://bellard.org/quickjs/quickjs.html#QuickJS-C-API
- MuffinFlavored 7y agoIt'd be super neat if he added a native `net` module. Then we could do node.js http/net vs QuickJS benchmarks.
- dariojcravero 7y agoPerhaps libuv-webserver[1] could be used for that purpose? [1]: https://github.com/springmeyer/libuv-webserver https://github.com/springmeyer/libuv-webserver
- lhorie 7y agoDoesn't look like. It uses the `os` module name for its own thing, so you'd need at a minimum to patch that (in addition to actually having to implement all of Node's APIs on top of the `std` primitives or as C modules)
- Aissen 7y agoIt would have a much lower memory and binary size impact. If your program is short-running, it could also be faster.
- mootzville 7y agoI compiled a branch and bound program to test this. Results for a 30x30 symmetric matrix processed using exact same code for both engines: NodeJS: ~20 seconds QuickJS: ~200 seconds So, from a single experiment QuickJS seems about 10x slower than NodeJS for this particular use case.