141 points · by gjvc · 4y ago · 67 comments
I also thought the deterministic GC would mean lower memory usage but it's actually worse than V8 (which has all the intermediate bytecode, and the JIT-ed machine code as well in memory, plus the dangling objects).
Still impressed that someone could write an EcmaScript-compliant engine from scratch, but looks more like a proof of concept (the fact it didn't get any updates in a year doesn't help either).
1. Sciter.JS, with QuickJS, mainstream version now.
2. And former Sciter.TIS - uses my own TIScript. TIScript uses moving/compacting GC (close to V8).
We have several products ported [2] from TIS to JS already. I am not registering increased memory consumption but quite contrary sometimes.
In some cases deterministic reference counting schema is beneficial in UI, like:
function Foo() {
var nobj = new NativeObject();
nobj.dosomething();
}
// QuickJS will destroy nobj at exit from the function
[1] https://sciter.com
[2] https://terrainformatica.com/2022/02/19/freeconferencecall-a...Tried it a while ago, pretty decent.
Data sizes almost always exceed the size of the code itself. I wouldn't consider it surprising that the IR would fade away into the noise.
V8 can also make tradeoffs that QuickJS probably cannot. For example, v8 internally represents strings as 1-byte latin-1 characters rather than 2-byte UCS-2. This halves memory consumption, but adds a lot of code to the implementation that a microcontroller running QuickJS may not have room for.
I found an opposite sort of performance profile (few small values on the stack, shallow stack size) with lots of calls back and forth between C and JS worked really well. Or, a lot of situations outdid V8 and ChakraCore for me (with JIT disabled). I didn’t dig into the exact reasons why though.
In this case it is not that surprising as the same single person (Fabrice Bellard) also built ffmpeg, qemu, and tiny-c compiler.
AFAIK the JS code is not converted to C, but the compiler produces bytecode which is bundled with C code.
This is interesting because it means it's possible to execute JS code from languages that have C interop. So for example you can do SSR rendering of Svelte components in a Go server application. At least in theory, I've never tried this.
$ echo 'console.log("hello world\n");' >hello.js
$ zip o//third_party/quickjs/qjs.com hello.js
adding: hello.js (stored 0%)
$ o//third_party/quickjs/qjs.com /zip/hello.js
hello world
Just add your source code to the qjs.com executable using InfoZIP and you've got a single file releasable binary that'll run on seven operating systems. It's also about 700kb in size. git clone https://github.com/jart/cosmopolitan
cd cosmopolitan
make -j8 o//third_party/quickjs/qjs.com
Build it on Linux but it runs anywhere. https://github.com/jart/cosmopolitan/tree/master/third_party... Here's a prebuilt binary https://justine.lol/qjs.comQJS is a lot smaller than V8. Granted, it doesn't have JIT, but for certain stuff it's ok.
https://github.com/justjake/quickjs-emscripten#quickjs-emscr...
I believe Figma uses QuickJS for their plugin system.
Not sure how they exactly compare - seems QuickJS supports a newer JS standard?
Over the past few years I slowly built a small JS runtime using QuickJS as the engine and libuv as the platform layer, amongst other things, in case anyone wants to take a look: https://github.com/saghul/txiki.js
1) adjective . strange or unusual, especially so as to cause interest or amusement.
By requiring a .patch file to be sent via a mailing list, the sort of "burden of effort" shifts away from "log into Github and click the pencil icon in the preview for README.md" and towards a slightly-heavier-weight minimum threshold -- one that shouldn't be so bad as to discourage folks making earnest valuable changes, but might be enough to make low-effort spam more annoying for the spammer than the spam-ee.
I think if the world ends, it won't be due to Fire or Ice. I think the name of doom is "Convenience".
†Yes, most people use webmail, not native desktop email clients, and no, it is not reasonable to expect people to switch for this.
(I've seen terminal jockeys do things that blew my mind, emitting continuous streams of characters that seamlessly switched between terminals and functions, orchestrating their machine like some virtuoso pianist, moving so fast it was impossible to follow. GUIs offer such folk nothing and I wouldn't be surprised if Fabrice Bellard was of this ilk.)
And I'm continually astounded whenever I bring up any GitHub criticism and get in response folks so hurried to try and "but Hillary!" me while leaping to the conclusion that I like mailing lists—even here in this case where I deliberately took special effort to start off by outright saying they suck. Let me be emphatic (again): mailing lists _really_ suck.
> This workflow inefficiency is multiplied by the number of patches you have
On the topic of things that suck: Git's CLI. Having said that, I'm not going to lie about it being worse than it is. You've moved your thumb off the scale. You're now saying things that aren't true.
Git's native workflows should be better. So should GitHub's.
> There is no good reason for it other than nostalgia for the old days of Unix
Go nerd-strawman someone else. I'm not Drew DeVault. I'm not the easily-take-downable bogeyman that, for your own convenience, you wish you were engaging with. I'm saying GitHub sucks because it does.
(As further data points: it's been only since, like, sometime after COVID lockdowns began that GitHub's site was finally fixed so that when you visit on mobile now, you don't get a horizontal scrollbar anymore. And this is the pre-eminent, tech-oriented platform that people can't stand to see being heralded as anything other than the thing that makes doing technical work feel like normal and approachable for normal people? Their "wikis" aren't even wikis, for fuck's sake.)
1. https://web.archive.org/web/20090202140249/http://www.bengoo...
As I have mentioned elsewhere, activity is not a proxy for quality, but many other factors are, including the author, whose name I included in the submission but for some reason has been removed.
So, there -- we've both got complaints!
...
QuickJS is around 600kb. v8 is around 28,000kb.
You couldn't even fit v8 in a lot of the places where QuickJS is designed to run.