23 ms·
QuickJS JavaScript Engine
- writepub 7y agoFrom the documentation [2], compilation of js to c looks very interesting. If variable types are well known/defined (like Uint8Array, ..), this effectively presents a way to derive performant binaries from js For those who don't know, the author is one of the most prolific programmers/creators of our time. Please check his bio [1] [1]: https://en.wikipedia.org/wiki/Fabrice_Bellard https://en.wikipedia.org/wiki/Fabrice_Bellard [2]: https://bellard.org/quickjs/quickjs.html#qjsc-compiler-1 https://bellard.org/quickjs/quickjs.html#qjsc-compiler-1
- Nicksil 7y agoNon-mobile URL: https://en.wikipedia.org/wiki/Fabrice_Bellard https://en.wikipedia.org/wiki/Fabrice_Bellard
- sdegutis 7y agoThe fact of its author and its extremely recent release date give this library significantly more credibility than any other similar "embedded JS" library. It may possibly be the best one available to date.
- molsson 7y agoVery impressive!
- stcredzero 7y agoThis is fast enough, it could be used to write command line utilities in Javascript! What about a Javascript OS in the style of the Lisp machines or early Smalltalks?
- kybernetikos 7y agoRecord-query [1] embeds v8 for its query language, which seems to add a significant amount of heft. I know that couchdb uses js for querying as well. It seems like this could be another option for something like that. [1] https://github.com/dflemstr/rq https://github.com/dflemstr/rq
- xvilka 7y agoConvert the QuickJS code into Rust using c2rust[1], then reuse in rq. [1] https://github.com/immunant/c2rust https://github.com/immunant/c2rust
- divs1210 7y agoThis is super impressive! Also - Yay! Another awesome target for ClojureScript - capable of producing standalone binaries!
- vim-guru 7y agoYeah, interesting..
- vkaku 7y agoHe does it again. The other small footprint engine used to be Jerry
- pcwalton 7y agoquickjs.c is a 47,842 line C file. I think that sets the record for the largest handwritten file I've seen.
- munificent 7y agoIs it hand-written as a single file, though? I'm assuming the release is the output of some script that does concatenation.
- saagarjha 7y agoFrom a cursory glance, it doesn't look like it's a bunch of files concatenated together.
- krferriter 7y agoIt's C so it's harder to tell than other languages, since it doesn't have separate namespaces for everything. You can just write a bunch of functions and global variables in separate files and then act like they're all in the same file, and there's really no difference.
- saagarjha 7y agoYou could, but I'm not seeing any code duplication across files so that would mean that he's not included the files that make up the "mega file", which would be rather strange.
- mantap 7y agoNot really that strange. You can have one C file that #includes the separate files that make up the big translation unit. The compiler will give you an error if a declaration is out of order.
- fightingcat 7y agoAny chance he has a super loooong screen? XD
- agumonkey 7y agoI wonder how different jslinux (obviously) would behave on it.
- dodo6502 7y agoWould this be a suitable replacement for SpiderMonkey as an embedded JS engine for a Desktop Application?
- TAForObvReasons 7y agoMany projects use duktape (https://duktape.org/ https://duktape.org/)
- megous 7y agoThere's also XS6 engine. But I dislike the macro trickery in that one. Looks like QuickJS doesn't use setjmp/longjmp, as opposed to duktape. I really like this, as it will simplify memory management inside C functions, and allow to use gcc cleanup functions.
- megous 7y agoSo I used QuickJS for a while today and it's the easiest JS engine of those I used so far (Duktape, XS6) to embed, even without extensive docs. I can't be happier that it doesn't use setjmp/longjmp to handle exceptions. It makes memory management easier. Everything is very straightforward. You can even get ref leaks report if you use -DDUMP_LEAKS.
- heapjs 7y agoWould 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...
- 7y ago
- bobajeff 7y agoI'm curious as to how the reference counting works in this. Is it comparable to what's used in Swift? How is it compared to the methods typically used in V8 and Spider Monkey?
- dan-robertson 7y agoThis is a very broad question. Garbage collection is a large topic. The general consensus is that reference counting methods give typically lower throughput than heap scanning methods but (I think) lower total memory usage and more predictable performance. They do bookkeeping on every free whereas a heap scanning gc will typically do bookkeeping in small incremental bits on alloc and mainly on gc cycle (when space runs low).
- minxomat 7y agoWould also be interesting to see how this GC runs in threaded or multi-instance environment. For example, Nim (the language) can produce libs by having them link to one dynamic lib containing the RT. Other compilers, like Crystal, don't support this outright.
- saagarjha 7y agoApparently the garbage collection algorithm is reference counting with cycle removal: https://bellard.org/quickjs/quickjs.html#Garbage-collection https://bellard.org/quickjs/quickjs.html#Garbage-collection. Swift does pure reference counting, relying on the programmer to annotate references so that there are no cycles (which is untenable in JavaScript, due to the way the language is designed).
- iforgotpassword 7y agoNow finally, kernel space JavaScript is in reach! ;-)
- mstade 7y agoI just tried building this on my Mac and it looked initially like it all was building fine, but it eventually failed when building qjs32. Thinking this probably didn't matter much I went ahead and ran `./qjs examples/hello.js` which worked as advertised – cool! Tried `./qjsbn examples/pi.js 5` and it worked as well – very cool! Then I tried `./qjs examples/hello_module.js` and got this: SyntaxError: unsupported keyword: import at examples/hello_module.js:3 I don't know what I did wrong – anyone else try it yet?
- btmills 7y agoTry adding the `--module` flag [1]. JS now has two different grammars, script and module, and the `import` keyword is only allowed in module code. [1] https://bellard.org/quickjs/quickjs.html#qjs-interpreter https://bellard.org/quickjs/quickjs.html#qjs-interpreter
- mstade 7y agoAh yes of course – thanks, works as advertised now! :o) Really cool stuff!
- jarav 7y agoTry ./qjs -m examples/hello_module.js
- minxomat 7y agoHeads up, I had to unset CONFIG_M32=y on macOS Catalina. There are no headers or symbols for 32bit apps in macOS anymore, so this will exclude the *32 variant targets.
- swuecho 7y agosimilar here. but I did not understand where CONFIG_M32=y is set. it is uncommented and must be set in somehwhere of Makefile. did not find the position.
- 7y ago
- tombert 7y agoIs there anything that Fabrice can't do? I mean, FFMpeg is almost a PhD thesis in and of itself, and he still manages to find time to make TinyC, QEMU, and now this. To say I'm jealous of his skills would be an understatement.
- mobilio 7y agoYou forgot LZEXE...
- tombert 7y agoI didn't even know about that one!
- userbinator 7y agoThat was my first "introduction" to Bellard. The second project of his that I came across was https://en.wikipedia.org/wiki/Bellard%27s_formula https://en.wikipedia.org/wiki/Bellard%27s_formula and his page on π: https://bellard.org/pi/ https://bellard.org/pi/
- iforgotpassword 7y agoYeah this is just crazy. I think he and ludde together are responsible for like 90% of software I like and use very frequently. ;-)
- abecedarius 7y agoludde who?
- Shoop 7y agoProbably Ludvig Strigeus [0]. [0] https://en.wikipedia.org/wiki/Ludvig_Strigeus https://en.wikipedia.org/wiki/Ludvig_Strigeus
- mikedelfino 7y agoludde together
- anderspitman 7y agoThis man is a wizard. You can also thank him for ffmpeg and qemu. A company I worked for once tried to hire him as a consultant because he had implemented an LTE BTS in software. Is there anything he hasn't done? EDIT: tombert beat me to it[0] by a couple minutes. [0] https://news.ycombinator.com/item?id=20413498 https://news.ycombinator.com/item?id=20413498
- MuffinFlavored 7y agoHe's probably worth $300-$500/hr if not $1k...
- anderspitman 7y agoCan you really put a number on this level of skill and productivity?
- shsh 7y agoYeah... his current employer already does.
- MuffinFlavored 7y agoDo you know who his current employer is (if any)?
- errantspark 7y agoI can't wait to mess around with this, it look super cool. I love the minimalist approach, if it's truly spec compliant I'll be using this to compile down a bunch of CLI scripts I've written that currently use node. I tend to stick with the ECMAScript core whenever I can and avoid using packages from NPM, especially ones with binary components. A lot of the time that slows me down a bit because I'm rewriting parts of libraries, but here everything should just work with a little bit of translation for the OS interaction layer which is very exciting.
- mirekrusin 7y agoIs it possible to contribute a patch? How should I do it?
- jerome_k 7y agoI like that Bellard released the source code in old school tar format rather than on github. The world's code collaboration platform is of little use to the world's best programmer. Hopefully QuickJS won't discourage the author of Duktape from making future releases of his incredible small low-memory JS engine.
- ricardobeat 7y agoWhat's to like about it? First thing I wanted to do is look at the sources, which is now a multiple-step process - especially since I'm on windows and usually work on a Mac. Not to mention mobile.
- j605 7y agoBoth can decompress tarballs. No idea if mobile ever crossed their mind.
- penagwin 7y agoWindows can't extract tarballs unless you install the linux subsystem or install 7-zip or similar. Macos can decompress them natively without installation. > No idea if mobile ever crossed their mind. If it was released on github/gitlab/gitea/etc they wouldn't need to. It's not a big deal but it does add an extra step.
- jerome_k 7y ago> What's to like about it? First thing I wanted to do is look at the sources, which is now a multiple-step process - especially since I'm on windows and usually work on a Mac. Not to mention mobile. Such hardship. High quality software is provided for free and people are complaining about the distribution format? Code was developed just fine before github. If viewing files in a tarball is an impediment then this library is not for you.
- andyfleming 7y agoWill the source of this be published to github (or similar) for contributing?
- suhail 7y agoquickjs.c is 47,842 lines of non-generated code. :mindblown:
- winrid 7y agoHeh, and I work where some complain about 5k line Java files.
- t0astbread 7y ago5k line Java files sounds awful
- TheRealSteel 7y agoThe thing about a 5,000 line Java file is that it's Java, so it's probably also 5,000 columns.
- winrid 7y agoOh it is.
- billti 7y agoThe type checker for TypeScript is >33,500 lines of handwritten code in a single file, which is getting up there for a high-level language: https://github.com/microsoft/TypeScript/blob/master/src/compiler/checker.ts https://github.com/microsoft/TypeScript/blob/master/src/comp...
- kostadin 7y agoThe operator overloading is potentially huge. Along with the BigInt/Float extensions, it makes it a great target for scientific computing applications.
- mhd 7y agoNote that Bellard already wrote a (small) HTML/CSS engine for his Emacs clone. So we're only a small step away from Bellard-Browser.
- yellowapple 7y agoWait, he has an Emacs clone, too? EDIT: https://bellard.org/qemacs/ https://bellard.org/qemacs/
- sdegutis 7y agoLooks impressive, I may have to try it out. Too bad it's LGPL. I expected MIT because QuickJS was, and hoped for it because GPL is unethical[1]. [1] https://sdegutis.com/2019-06-26-why-the-gpl-is-unethical https://sdegutis.com/2019-06-26-why-the-gpl-is-unethical
- com2kid 7y agoThe strawman is strong with that argument. > But for most people, they are comfortable with this agreement. They don’t see it as a breach of freedom or liberty, but as a simple and just contract. Having people sign away something that they are not fully aware of the implications of is not the same as people not caring. If you presented software as "and at any time, this software you just paid $300 for, can be remotely disabled and you won't get your money back and you have no choice about it", people might be less willing to accept the status quo. To use (yet another!) car analogy, if I buy a car and the manufacturer goes out of business, I can still get support from independent mechanics. Heck if there are enough customers, a new company may spring to life just to make replacement parts for the car! (This in fact happens super often, non-oem parts are everywhere.) Even after bankruptcy of the original manufacturer, an entire third party supply chain can exist and people can keep driving their cars. Compare this to closed source software, where the software can literally just stop working one day, with no recourse. People are slowly coming to realize this, especially as more and more software has a requirement to ping a server somewhere. IoT devices are helping bring this issue to public awareness. GPL says "no matter what, YOU have the right to what is running on your computers, you can open it up and do what you want, or pay someone else to do the same." How is it unethical that I should have control over the software running on my PC, in my house? The same PC my webcam and microphone are connected to? The same PC I use for online banking and email? Nothing else in the world works like closed source software. Hardware manufacturers try, and there is a legal fight to try and make physical goods like software (sealed shut, unable to open, no third party parts), but traditionally anything I buy I've been able to disassemble at will. Why should software be any different? (Of course I say this as someone who has spent over a decade writing a closed source software... and I use Windows as my primary OS.)
- zerr 7y agoWhy are we ignoring the second author? :)
- simlevesque 7y agowho is this Charlie Gordon ?
- fvdessen 7y agoSeems like a pseudonym; Charlie Gordon is the name of the protagonist in Flowers for Algernon.
- lifthrasiir 7y agoI suspect that too. Note that FFmpeg was also published under a pseudonym Gérard Lantau.
- basementcat 7y ago> Seems like a pseudonym; Charlie Gordon is the name of the protagonist in Flowers for Algernon. Just had a vision of a hacker blog where the author starts out writing in the most godawful VB6 spaghetti, gets some sort of brain operation and subsequent blog postings are like Linux booting in RISC-V implemented in Conway's Game of Life. Then suddenly a mouse dies and the quality gradually reverts back to how cool the <BLINK> tag is in HTML.
- zokier 7y agoActually, why are we (mostly) ignoring Charlie Gordon? Every second comment here seems to be ready with praise for Bellard (who no doubt deserves it), but Gordon seems like the right hand man, a significant part of the dynamic duo here and very much a unsung hero barely noted.
- gfodor 7y agoWorth noting: the demo is a WASM-compiled instance of this engine. I'm not sure, but I think this might be the first example of a fully featured, potentially production-ready, JS VM sandbox running in the browser. (We're looking into safe ways to enable third party scripting of our own application, and such a sandbox would be a very nice tool to have in hand.)
- troygoode 7y agoYou should talk to the guys at Wasmer: https://wasmer.io/ https://wasmer.io/
- mythz 7y agoSafari's JavaScriptCore has been available on WASM for some time: https://wapm.io/package/jsc https://wapm.io/package/jsc Online demo of JSC.js https://mbbill.github.io/JSC.js/demo/index.html https://mbbill.github.io/JSC.js/demo/index.html
- apaprocki 7y ago2019+ will Atwood's law compiled to WASM. My co-worker Jason wrote a JS engine in Rust, Boa (https://github.com/jasonwilliams/boa https://github.com/jasonwilliams/boa) and demoed it via WASM in the browser at the recent JSConf.EU 2019: https://www.youtube.com/watch?v=_uD2pijcSi4 https://www.youtube.com/watch?v=_uD2pijcSi4
- dmix 7y agoCould these be able to do SSR for Vue from a Rust web server?
- nkozyra 7y agoWould a JS engine be able to do all the browser/dom work on its own? I'd think you'd need to bring along enough side cars that you might as well just use puppeteer
- gfodor 7y agoAh yup this was the only one I had seen before, and looks really promising! Didn't know about the others posted so thanks all!
- megous 7y agoVery nice repl with syntax highlighting.
- aboodman 7y agoI'm curious - what is/was the intended application of this?
- oscargrouch 7y agoA very small and fast javascript interpreter. It will create a small library file for the programs who depends on this and according to the benchmarks it runs faster than the other javascript interpreters. If you want a very fast javascript engine and dont have problems with binary size, memory constraints and executable memory pages, you can pick a JIT like V8, Chakra or Spidermonkey. As those JITs are pretty advanced optimizing JIT compilers and will run javascript code very fast, much faster than the fastest interpreted VM implementation can. People who tend to choose this instead of V8 for instance need to run this in a microcontroler for instance, or a OS without executable memory pages (and therefore where JIT´s are forbidden).
- aboodman 7y agoRight - I'm wondering if Fabrice had a particular embedder in mind for this JS engine. It seems like a big effort to go to just for the hell of it.
- z3t4 7y agoI think mainly as a C replacement, for added productivity. Compared to Node.JS QuickJS seems to interoperate with C. Node.JS standard library is fully async, while QuickJS use C standard lib. There's also GnomeJS which can be used to build apps that looks and feels like native apps, maybe you can also do that with QuickJS!? Being able to obfuscate the code by compiling is also considered a feature, useful when you want to distribute an application without giving away the source code.
- neop1x 7y agoalso can be embedded in a microcontroller
- ilaksh 7y agoHow fast is it compared to V8?
- wanjochan 7y agoby linking c modules, comparing it with v8 is no longer meaningful
- beagle3 7y ago... and facebook releases Hermes JS Engine the same day. Coincidence, or conspiracy? Link on frontpage at this point in time: https://news.ycombinator.com/item?id=20412588 https://news.ycombinator.com/item?id=20412588
- lxe 7y ago> An online demonstration of the QuickJS engine with its mathematical extensions is available at numcalc.com. It was compiled from C to WASM/asm.js with Emscripten. This is peak JavaScript. How deep can we go?
- thomasfortes 7y agoYour comment reminded me of this talk: https://www.destroyallsoftware.com/talks/the-birth-and-death-of-javascript https://www.destroyallsoftware.com/talks/the-birth-and-death...
- q3k 7y agoqwertyoruiopz already found a use-after-free bug: https://twitter.com/qwertyoruiopz/status/1149424025111801858 https://twitter.com/qwertyoruiopz/status/1149424025111801858
- megous 7y agoThere are other bugs, too, like: 1420 th = js_mallocz(ctx, sizeof(*th)); 1421 th->has_object = TRUE; 1422 if (!th) { 1423 JS_FreeValue(ctx, obj); 1424 return JS_EXCEPTION; 1425 } But hey, that's gonna get ironed out. :)
- littlestymaar 7y agoThis is still an important reminder that literally nobody in the world can write C code without memory issues. Even if the developer is a genius and the project isn't that big.
- megous 7y agoThis one is probably easily catchable even by a static code analysis, though. I suspect this is the result of th->has_object being added later than the surrounding code. I don't think someone would write this code on the first attempt with this bug. It's too obvious. If the code repo ever becomes available, I'll check my theory out. :D
- userbinator 7y agoI'd be curious to see the total number of bugs ever found in this code; I suspect it's going to have a far lower defect density than any other JS engine, especially the ones in the big browsers.
- andyfleming 7y agoUndefined symbols for architecture i386 I get this error when attempting to make on macOS. I don't have very much experience with C, but is there a good resource to learn how to better deal with compiler issues and such other than googling specific issues?
- pjscott 7y agoYeah, I got the same error, along with a bunch of warnings earlier in the build about how 32-bit builds are deprecated on recent macOS versions. And then when it goes to link, it can't find the 32-bit symbols for functions like sqrt() and `printf()`. Hacky workaround: comment out the "CONFIG_M32=y" line in the makefile. This will disable building the 32-bit versions of some tools. ("Edit the makefile" is, according to the docs, the canonical way to customize your build settings.) And I don't think there's any real shortcut for dealing with compiler error messages. You've just got to learn what they mean and what sort of thing tends to cause them.
- andyfleming 7y agoThanks! That solved it for me.
- londons_explore 7y agoHow long before the nodejs and npm crowd runs all their JavaScript in this, compiled to wasm, on a real browser... For no real benefit, but a whole load of slowdown...
- duxup 7y agoI have a potentially dumb question as I'm way out of my element here. What would someone....do with this? Use it to run JS on some embedded device where you can run C?
- megous 7y agoYou have a C app, and want to allow to script parts of it via JS easilly. I use engine like this inside the milter daemon for my postfix mail server, to process mail during reception.
- duxup 7y agoThank you!
- deleted 7y ago[deleted]
- CamperBob2 7y agoI have a domain-specific Windows application that uses Google's V8 engine for hosting user-written scripts. It hasn't been upgraded for several years, and when I recently took a look at updating the V8 version it's linked with, I was dismayed at how bloated and complex V8 has become. Seems like it can't be compiled down to a single DLL anymore, at least not without turning the compilation into a miniature research project in itself. So there's definitely a need for more lightweight contenders in this space. Ideally someone would just do an "stb"-style JavaScript interpreter that would fit into a single .c or .h file. This is closer to that ethos than most other candidates, and as others have noted, Fabrice's credibility as a '1337 h4x0r gives it an instant leg up on the competition. I don't have an urgent need to switch away from V8 right now, but I'll be watching this project with moderate interest.
- JCoder58 7y ago> Ideally someone would just do an "stb"-style JavaScript interpreter that would fit into a single .c or .h file. DukTape is already that. https://duktape.org/index.html https://duktape.org/index.html
- amrox 7y agoDoes anyone know is this is x86 specific? It sounds like it’s just C but I’m not at a computer right now so I can’t dig in. It seems really interesting for embedded or mobile (iOS/Android) too
- Scarbutt 7y agoThe death of Lua.
- detailyang 7y agoAgreen. If I choose the embedded language luajit or quickjs is my best options:)
- pritambaral 7y agoI'll give you Lua, but can this compete with LuaJIT?
- bakery2k 7y agoNot in terms of performance. No interpreter comes anywhere near the speed of JIT compilers such as LuaJIT, V8 and PyPy.
- deleted 7y ago[deleted]
- miguelmota 7y agoFreaking impressive and incredibly performant. Imposter syndrome kicks in when I see how much Fabrice has accomplished. What a legend.
- NuclearFishin 7y agoHow does one keep track of Fabrice Bellard's work? I couldn't find a Twitter profile, GitHub profile, or RSS feed from his website.
- userbinator 7y agohttps://bellard.org/ https://bellard.org/ https://bellard.org/projects.html https://bellard.org/projects.html He's got over 40 projects in total there, and each one of those is deep --- they would either take a very long time or be impossible for the average programmer. In contrast, many other programmers I've heard claim to have done over a dozen different projects turn out to really be "I glued several libraries together" repeated many times; very much the opposite of Bellard. In fact, I suspect one of the reasons he is so productive is because he shuns all social media.
- penagwin 7y agoHe has a drive that most people can only dream of. I have a bunch of projects, drones, 3d printers, computer clusters, a bunch of programs I want to make - I have all the tools, I already own all the things I mentioned. But I suffer from depression/other stuff, and I haven't touched them in months. Let alone this guy, who is presumably pounding away at his keyboard for hours everyday.
- nurettin 7y agoWhen he creates something, you will know.
- userbinator 7y agoWow. The core is a single 1.5MB file that's very readable, it supports nearly all of the latest standard, and Bellard even added his own extensions on top of that. It has compile-time options for either a NaN-boxing or traditional tagged union object representation, so he didn't just go for a single minimal implementation (unlike e.g. OTCC) but even had the time and energy to explore a bit. I like the fact that it's not C99 but appears to be basic C89, meaning very high portability. Despite my general distaste for JS largely due to websites tending to abuse it more than anything, this project is still immensely impressive and very inspiring, and one wonders whether there is still "space at the bottom" for even smaller but functionality competitive implementations.
- andrewstuart 7y ago>> Despite my general distaste for JS largely due to websites tending to abuse it more than anything Why would you have a distaste for JavaScript based on how others use it? JavaScript has evolved into an extremely powerful and flexible language which is taking many great lessons from other languages. Sure its not perfect but its a real workhorse. EDIT: I know you're not meant to ask why the downvotes, but I do wonder in this case - the comment is a reasonable one, I guess it's the many JavaScript haters piling on - "Haters gonna hate". I stand by these comments - JavaScript is a flawed but great language that has only proven over time its flexibility and adaptability to become probably the single most used language - the people who don't like it are those who don't use it/understand it.
- _pmf_ 7y ago> I stand by these comments - JavaScript is a flawed but great language I like my languages a bit less flawed, thank you very much.
- schwartzworld 7y agoWhich languages would those be?
- smt88 7y ago
- deleted 7y ago[deleted]
- duchenne 7y agoI have question. Do you think that this could be used as a brick to build an alternative web browser?
- a_lieb 7y agoThe benchmark scores [1] he gives only stack it up against other embeddable engines. It cuts those to ribbons, but can someone who's familiar with JavaScript performance weigh in on how it competes with the most popular engines like V8 and SpiderMonkey? It would be interesting if this is so fast that you could re-implement Node using QuickJS instead of V8, or even make a WebKit- or Gecko-based browser with QuickJS under the hood. Presumably a lot of the headaches with swapping in a new JS engine have to do with dependencies, and this has none. [1] https://bellard.org/quickjs/bench.html https://bellard.org/quickjs/bench.html
- ccheever 7y agoOn my computer, running the v8 benchmarks from the QuickJS source: -- QuickJS -- PROGRESS Richards RESULT Richards 445 PROGRESS DeltaBlue RESULT DeltaBlue 424 PROGRESS Encrypt PROGRESS Decrypt RESULT Crypto 633 PROGRESS RayTrace RESULT RayTrace 271 PROGRESS Earley PROGRESS Boyer RESULT EarleyBoyer 771 PROGRESS RegExp RESULT RegExp 180 PROGRESS Splay RESULT Splay 923 PROGRESS NavierStokes RESULT NavierStokes 1979 SCORE 549 -- v8 (node) -- PROGRESS Richards RESULT Richards 31083 PROGRESS DeltaBlue RESULT DeltaBlue 51056 PROGRESS Encrypt PROGRESS Decrypt RESULT Crypto 36692 PROGRESS RayTrace RESULT RayTrace 63343 PROGRESS Earley PROGRESS Boyer RESULT EarleyBoyer 50309 PROGRESS RegExp RESULT RegExp 7910 PROGRESS Splay RESULT Splay 22964 PROGRESS NavierStokes RESULT NavierStokes 35214 SCORE 32307
- a_lieb 7y agoIf the scoring scheme works the same as the results he shows on the site (higher is better), then V8 is still far faster than QuickJS. Which wouldn't be all that surprising since the V8 folks have spent hundreds of thousands of man-hours on optimization and JIT magic, which is something that would be hard to duplicate, to say the least, in a ~1.5MB all-interpreted engine.
- theqoo 7y agoIt shows only 2~3% of V8 performance. But it enough for running simple embedded script. And thing is it meets JS standards. At starting you can embed it into your SW easily, and provide scripting functionality. And when your SW grow enough, and have heavy scripts, you can migrate to V8 since there is compatibility.
- deleted 7y ago[deleted]
- snappybear 7y agoCan not pass tests from armv8l, the site seems no bug report links. is anyone know how to let bellard know this ? make -j8 test ./qjs tests/test_closure.js ./qjs tests/test_op.js ./qjs tests/test_builtin.js Error: assertion failed: got |2e+1|, expected |3e+1| at assert (tests/test_builtin.js:17) at test_number (tests/test_builtin.js:307) at <eval> (tests/test_builtin.js:589)
- snappybear 7y agoother error find from android termux: InternalError: out of memory in regexp execution at test_regexp (tests/test_builtin.js:427) at <eval> (tests/test_builtin.js:594)
- steipete 7y agoThere's no issue tracker?
- arebours 7y agoThere is a TODO file
- ddalex 7y agoI was like "oh no, not another JS engine", and then I've seen it's on bellard.org... and I thought to myself, ok, this is the future!
- deleted 7y ago[deleted]
- wheresvic1 7y agoI'm asking this here because I don't really know where else to do so: I'm trying to compile a binary from a js source that uses the standard modules (they are loaded by default if you run the interpreter) so the following works: std.printf("%d\n", 1); std.printf("%s\n", os.platform); However it does not compile to a binary and doing something like: import std from "std"; import os from "os"; std.printf("%d\n", 1); std.printf("%s\n", os.platform); compiles via `./qjsc -m -o default_modules examples/default_modules.js` however does not execute: $ ./default_modules SyntaxError: export 'default' in module 'std' is ambiguous Source: https://github.com/smalldatatech/quickjs/blob/master/examples/default_modules.js https://github.com/smalldatatech/quickjs/blob/master/example...
- swuecho 7y agoimport * as std from "std"; import * as os from "os"; std.printf("%d\n", 1); std.printf("%s\n", os.platform)
- wheresvic1 7y agoAwesome thanks!
- rick22 7y agoAt the bottom of the page there is this the mention of "Charlie Gordon". Who is he ?. Any place to find the works of him.
- rick22 7y agoDoes Fabrice Bellard knows any other language other than 'c' ?. Looks all his works are in 'c'. Just trying to look if there is a correlation among the 100x programmers and the number of languages they know. Because being extremely proficient in a language is important to be highly productive.
- wanjochan 7y agoI'm a crazy fans to Fabrice Bellard. If he starts a religion, I will not doubt signing up....
- wanjochan 7y agoIf Fabrice Bellard starts a new religion, I will have no doubt signing up right away.