9 ms·
QuickJS JavaScript Engine
- akmittal 5y agoIm am always fascinated by how a single person can build a language runtime. That too for language like JavaScript where large number of features are introduces on regular basis. https://github.com/bellard/quickjs/graphs/contributors https://github.com/bellard/quickjs/graphs/contributors
- lifthrasiir 5y agoJS is relatively easy to implement if you don't care about performance. (QuickJS does care about preformance though, which makes it more amazing.) The apparent complexity of ECMAScript specification mostly comes from lots of pseudo code written in prose, which leaves no room for different interpretation and actually makes implementor's job easier. Newer JS features also rarely introduce new concepts and can be mostly desugared into the core language, pretty isomorphic to ES5 plus some library bits like Proxy---which means you can start with ES5 (an even smaller language) and build newer features on top of that.
- jart 5y agoWould you call running a marathon easy? Anyone can run. But could you run for 26.2 miles without stopping? The ECMAScript 12 spec is 44,000 lines and it contains 269,000 words. It's enormous. It's the same way with qemu. You have to spend months doing an enormous number of things to build something like that before it's able to run even the simplest most everyday programs. Bellard is legendary for his stamina. Not many programmers can match it. Only one I can think of would probably be the SerenityOS guy.
- lifthrasiir 5y agoI like your marathon analogy. Not everyone can or does run a marathon, but there are still lots of marathoners. You do need stamina, but you don't need an inhuman level of stamina like Bellard's. If you don't stress yourself and pick your enemy wisely (like, start with ES5) it is very much doable.
- saghul 5y agoNote that the GH repo is just a mirror, development happens elsewhere. From the copyright notes there is another main developer involved, Charlie Gordon.
- selcuka 5y ago> Im am always fascinated by how a single person can build a language runtime. In this case it is not that surprising as the same single person (Fabrice Bellard) also built ffmpeg, qemu, and tiny-c compiler.
- akmittal 5y agoHe got a new fan then, I will consider myself lucky if i can reach just 1% compared to him
- playpause 5y agoOriginal discussion: https://news.ycombinator.com/item?id=20411154 https://news.ycombinator.com/item?id=20411154
- andrew_ 5y agoHow bizarre (1) that the author doesn't accept Pull Requests. I'd love to know more about why .patch files via mailing list are preferred. 1) adjective . strange or unusual, especially so as to cause interest or amusement.
- ubertaco 5y agoI wonder if it's a "raised barrier to entry" to prevent low-effort drive-by PRs. I have a couple of extremely-small OSS libs that are available in public package repos and are hosted on Github, and even those have gotten the drive-by "I slightly reworded your README" PRs that don't help. I can't imagine the volume of noise that larger projects get. 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.
- andrew_ 5y agoBarrier of entry is a good call. From my experience on some rather large OSS projects, the ratio of noise to signal on PRs tends to go along with the target audience of the project.
- londons_explore 5y agoMailing lists suffer from other kinds of spam... Actual email spam, poor moderation tools, etc.
- qbasic_forever 5y agoIt's how git was created to operate. The linux kernel, probably the largest software project in history, only operates through emailed patch files too.
- cxr 5y agoLinux uses pull requests, too, it's just that it uses them the way they were meant to be used—among a limited cohort of collaborators frequently pulling from one another—instead of GitHub-style pull requests that have little to do with Git-the-tool and that everyone gets shunted through, even when a patch (or three) would be more appropriate.
- gigel82 5y agoGave it a try a couple of years ago and it had issues with larger JavaScript bundles (passing a lot of objects on the stack requiring recompiling the entire process with an increased stack size or modifying the threads on which it runs to accommodate - even with that, reasonably deep callstacks would overflow). 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).
- 11235813213455 5y agoanother interesting proof of concept: https://github.com/engine262/engine262 https://github.com/engine262/engine262
- c-smile 5y agoMy Sciter[1] Engine has two versions 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 https://sciter.com [2] https://terrainformatica.com/2022/02/19/freeconferencecall-and-sciter-js-project-development-notes/ https://terrainformatica.com/2022/02/19/freeconferencecall-a...
- MuffinFlavored 5y agoDoes this ship an exactly pegged version of WebKit like Electron or does it use whatever the host system provides?
- sreekotay 5y ago
- pier25 5y agoOne great feature of QJS is it can create C executables or modules from JS. 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.
- silasb 5y agohttps://github.com/rogchap/v8go https://github.com/rogchap/v8go is a Go library which makes this easy to accomplish.
- pier25 5y agoYeah but how much memory does that consume? QJS is a lot smaller than V8. Granted, it doesn't have JIT, but for certain stuff it's ok.
- jart 5y agoYou can use QuickJS as an Actually Portable Executable. $ 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.
- saghul 5y agoQuickJS is awesome, simple to use and very easy to integrate. 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 https://github.com/saghul/txiki.js
- deleted 5y ago[deleted]
- madjam002 5y agoQuickJS is cool, I use it to run a JS sandbox for a WYSIWYG editor so the user can write Nunjucks templates.
- pbowyer 5y agoThat sounds amazing, can you share any more details - of your WYSIWYG editor and how you use QuickJS?
- jitl 5y agoIf you want to use QuickJS in the browser and/or NodeJS for running untrusted code, building plugin systems, etc, I have a library here that wraps a WASM build of QuickJS: https://github.com/justjake/quickjs-emscripten#quickjs-emscripten https://github.com/justjake/quickjs-emscripten#quickjs-emscr... I believe Figma uses QuickJS for their plugin system.
- AgentME 5y agoAwesome! I had actually been considering starting a library for using QuickJS+WASM for sandboxing soon.
- throwaway2037 5y agoHi @dang: Can you please update the title of this post to include the date of last release (2021)? Officially, the last release was on 2021-03-27.
- gjvc 5y agoStop obsessing about the date of items and judge them on their actual worth and usefulness, not assumed "freshness". 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!
- ramses0 5y agoI'm with you w.r.t. people on Jan 1 2022 trying to tag things as "(2021)", but can definitely understand the value of tagging as (2020/2019/...and prior).
- Klasiaster 5y agoThere is also duktape which got some traction: https://wiki.duktape.org/projectsusingduktape https://wiki.duktape.org/projectsusingduktape Not sure how they exactly compare - seems QuickJS supports a newer JS standard?
- hajile 5y agoDuktape is half the size (runs way more places), but is 2-5x slower. https://bellard.org/quickjs/bench.html https://bellard.org/quickjs/bench.html
- david2ndaccount 5y agoQuickJS is awesome. I’m using it to allow you to execute javascript in a markdown-like file format that allows you to manipulate the document tree programmatically before rendering to html. Has turned out much nicer than CPython which I was using before.
- CGamesPlay 5y agoProject seems really cool! The docs seem a little sparse, unfortunately. After reading through the calculator code I am still curious: how do you use a custom resolver for modules? I want to make something completely sandboxed.
- truth_seeker 5y agohow about using plain v8 (much faster in execution of JS code) without embedding it in NodeJS ? https://github.com/just-js https://github.com/just-js
- hajile 5y agoThat serves a different market. 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.
- sylware 5y agook, now we just need a c89 coded dynamic web engine using quickjs as a javascript engine. ...