QuickJS, the Next Generation: a mighty JavaScript engine
github.com
github.com
Both languages are fairly quirky - at least JavaScript’s quirks are widely-known. But how do the implementations compare in terms of API, robustness, portability, performance etc?
Also, I’m not aware of any static typing add-ons for Lua, but presumably it’s possible to use TypeScript with QuickJS?
I don't see why not, since TS compiles down to JS. The engine doesn't know or care about what kind of transformations the code went through before it was JS. You might need to be careful about compatibility, the QuickJS intro says 'Almost complete ES2023 support", so you'd have to avoid any unsupported features.
I'd not cal TypeScript an addon to JS. It's a language that transpiles to JS (and so does CoffeScript, Elm, etc. etc.)
There are many language projects that transpile to Lua:
https://github.com/hengestone/lua-languages?tab=readme-ov-fi...
The fork is apparently in the process of re-integrating with upstream, after work on QuickJS resumed.
From the QuickJS-ng README:
> In October 2023 @bnoordhuis and @saghul decided to fork the QuickJS project
> ...
> As of early 2024 both projects agree the proper path forward involves merging both projects and combining the efforts.
Show HN: Execute JavaScript in a WebAssembly QuickJS sandbox - https://news.ycombinator.com/item?id=40896873 - July 2024 (47 comments)
Embeddable use when you need latest ECMAScript support.
> Does it have a shot of being a top class engine?
No.
A top class engine requires a JIT and that generally leads to being large and having high startup time. LuaJIT is pretty much the exception which proves the rule and 1. Mike Pall is a monster of a developer not unlike Bellard; and 2. Pall is on record (in discussions with other JIT people) that in his opinion you can’t bolt a JIT to an existing runtime and get a maximally efficient JIT. So you’d need someone of that class of skill to decide to make that their legacy.
[1] https://www.usenix.org/legacy/event/usenix05/tech/freenix/fu...
And unfortunately, making a very fast interpreter-based JS engine is a tedious and human-power-heavy work, it involves a lot of work which can't be eliminated by better skills.
It can be compiled to WebAssembly and run with the sandboxing of WebAssembly. Not just data sandboxing but sandboxing that can prevent it from slowing down the rest of the app (though it runs slower).
Post from Figma in 2019: https://www.figma.com/es-la/blog/an-update-on-plugin-securit...
This in 2023: "Either Figma hasn't updated QuickJS since, or they've moved to a different VM, because Figma's VM is missing many of the features QuickJS now supports." https://www.sam.today/blog/bumbling-the-figma-api
Even if I wanted to switch, I just don't know what I'd be running into, until I do. :)
JavaScript is great but without HTTP fetch alot of potential uses are off the table.
Excellent job on building this, and it's very readable and nice, otherwise!
I didn't find any file with that many line's yet, still searching but I doubt it exists unless it's in a different repository.
It looks like the mutex is theoretically sound.. unlocked before all returns, as long as there isn't an exception raised in between. I wonder what the parent comment's issue is.
This is solved in C usually with a goto to a cleanup routine, and avoiding early returns.