Hacker News new | past | comments | ask | show | jobs | submit login
QuickJS JavaScript Engine (bellard.org)
948 points by apaprocki on July 11, 2019 | hide | past | favorite | 261 comments

Is 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.

I have two question in my mind.

1. Are there anyone on HN knows him in real life?

2. Does anyone have other people in their mind who is in the same league as this man? Mike Pall's LuaJIT sort of make him at this level but that is only one thing. Fabrice create things that everyone are using it one way or another, and if it wasn't HEVC patents mess we would have his bpg [1] replacing jpeg.

[1] https://bellard.org/bpg/

> 1. Are there anyone on HN knows him in real life?

Do you ask this to know if he's a real guy or an AI or a pseudo for group of persons like https://en.wikipedia.org/wiki/Nicolas_Bourbaki ?

I know Fabrice a little. He's definitely real, smart and humble.

Visited him at his workplace about ten years ago when he worked at Netgem.

We also have a common friend we visit with spouse and kids, where we discover and discuss new gadgets (physics-based, drones, mechanical puzzles, etc). One day we played with a kind of padlock where the lock procedure implied to move a sort-of 4-direction joystick. The trick was: you could do any number of moves to lock it. It seemed like it allowed to store an arbitrary long sequence of numbers in a finite mechanical system. Fabrice arrived, heard us explain, thought, and said "the mechanics probably implements some sort of hash algorithm". That was the answer.

I've met him as well, a few times, but do not know him personally like you.

He is definitely very humble and a very good listener. When he told us about this side project he was working on about a year ago, he made it seem like it wasn't a big deal, just a small js engine, would never compete with v8. After a few questions, it was clear that the goal was to implement the latest ECMAScript spec, with all the goodies. It will never be in the v8 league, but it's on a league of its own.

The question is how one would compete with V8 if you can't catch up with the tempo with which JS spec changes?

With how things are going now, V8 code is the de-facto "upstream spec"

Dan Bernstein. Researched curve 25519 and provided reference implementations of x25519 & ed25519. Invented chacha20, such that it never branches on user secrets to minimize side channel leakage. Along with poly1305, these form the foundation of almost all “modern crypto” from Signal to TLS v1.3. He wrote qmail as a superior MTA to the incumbent Sendmail. He’s even beat the US government in court.

And unless there's another software engineer named Daniel J. Bernstein out there, he also authored RFC 1143 documenting the Q Method of TELNET Option Negotiation [1], which prevents negotiation loops and nails down (in the shape of a state machine) exactly what behavior is good and proper for a Telnet peer.

I referenced this document a lot when writing my own Telnet stack.

[1] https://datatracker.ietf.org/doc/rfc1143/

>…when writing my own Telnet stack.

There’s probably an interesting story hidden in there.

That probably depends more on the listener than on the story!

I played MUDs for several years, at the same time that I was learning the ins and outs of programming. I developed some plugins for a popular third-party client called MUSHclient. The game I played also had a somewhat proprietary first-party client, and they used a spare Telnet option (one left unassigned by IANA [1]) to pass data from the server to the client to drive some extra graphical widgets on their client. I got involved in developing plugins that made use of that data, which led me to learning how to negotiate that option with the server and get the data I wanted.

I eventually started developing my own MUD client, which is where the Telnet stack came in. Now, writing a Telnet stack is just something I do when I learn a new language. It's just large enough of a project to exercise some architectural and API-level concerns.

[1] If you're curious, all of the formally allocated Telnet options are documented here: https://www.iana.org/assignments/telnet-options/telnet-optio...

djb also wrote daemontools, ucspi-tcp, dnscache, djbfft, kicked off the field of post-quantum cryptography (pqcrypto), wrote the spec for `redo`, and came up with `find -print0 | xargs -0`.

Definitely a legend!

It’s almost frightening that all modern crypto is converging on one persons work.

Richard Stallman is mostly known for his activist/politics stuff at this point, but he was also a heck of a developer. He wrote Emacs, GCC, GDB and glibc. I'm not sure if he was a total lone wolf, but my understanding is that in the early days he was overwhelmingly the main person responsible for those projects.

It's hard to get a sense of how smart RMS is, because he seems to be anti-showy about it. But I've seen him talk in different venues, and calibrate how much he says to the venue. I've also seen him ramp up how much detail he goes into, and what kinds of arguments he can make, when someone with a background in some area is challenging him on some point. I can't tell how smart he is, but I suspect that most people talking with him underestimate him.

It hard to get a sense of how Smart RMS is, because he invents his own terms or he repurposes existing well understood terms (such as the term free) to confuse the issue.

It is something I have little respect for and tbh it doesn't matter how clever it is when he spends most of that effort on for want of a better term intellectual wankery.

Saying "free software" drives me crazy, today.

Possibly in his defense, I suspect it made more sense at the time. He'd just tell other hackers "this is free software - free as in...", and they'd say "OK, that's an interesting idea that resonates with what we know and see", or "OK, that's some hippie stuff, but we've been benefiting from that kind of sharing in computing, so you might have a point". They'd hear that in-person, or on the Internet, or in the text files when they went to compile and install the software. Now most people never get the introduction, or it's drowned out in all the massive noise that everyone is exposed to on the Web.

Though maybe saying "free" still works for him, because, when he's giving a talk, he can say "this is free software - free as in..." and people are there, paying attention.

Also, it's in the brand name.

A wild speculation possibility is that he's still thinking decades ahead, and maybe we go back to trying to say substantive things, and paying attention when others say substantive things, and then saying "free software" makes more sense again. (Some other instances of thinking ahead are the reason behind a subreddit name: "https://old.reddit.com/r/StallmanWasRight/")

In any case, I think it's unfortunate if people dismiss RMS's speech without listening, because of quirks and things we don't immediately understand.

I don't agree at all. From day one he been using intellectual wankery.

Regarding lists like r/stallmanwasright, I work with plenty of smart people who couldn't care less about free software some of them aren't even tech savvy and they can spot all the problems with a lot of the services we have today.

I think it is more an exercise of throwing shit at a wall until and seeing what sticks. Which btw is a perfectly valid method of seeing how your message gets across but it doesn't make you a genius.

That combined with awful manners, hygiene and the fact that he has some disgusting opinions about child abuse. I can't stand the man. The fact that this guy has any importance past "Well he was the founder of the GNU project and he wrote a text editor" seems ludicrous to me.

I think the difficulty for me in responding here is that your comment contains both assertions about intellectual merit (which could be interesting to explore), and more broad aversion to the person (which might be relevant to intellectual merit, and/or to the meta of dialogue about that, but is a manners minefield).

This thread is pretty tangential to the post to start with, so there will be better occasions to discuss these things. And maybe it helps to separate them out differently.

Fair enough. If you are interested I suggest you read:


He has a few chapters about problems (rarely mentioned) with GNU / GPL and Stallman himself.

Guy L. Steele - no proper language design can go without him. I think he is the only person who enjoys writing language reference manuals and is able to explain every language detail mathematically and linguistically everyone can understand. He was behind C, Java, Scheme, Common Lisp, ECMA, Fortan...

Perhaps you mean behind standards and reference manuals for, rather than behind the languages? Behind Scheme and Common Lisp, okay. But he contributed to standardisation and documentation of the others after their creation, rather than being one of their designers.

Yes :)

Incidentally, Steele has an anecdote of perhaps an early instance of pair-programming with someone else mentioned in these HN comments, Richard Stallman (at the end of this chapter): https://www.oreilly.com/openbook/freedom/ch06.html

John Carmack is the immediate one that comes to mind.

Truly. JC literally largely made gaming what it is today. I remember reading that virtually every game users code he has written, because almost every game engine uses his code in some form.

He was also behind quite a few innovations at Oculus for their Rift headset, including their Time Warping tech.

I get a similar "is this by some kind of super-human intelligence?" feeling reading stuff from Oleg Kiselyov. http://okmij.org/ftp/

Oleg used to post things like this on Usenet: http://okmij.org/ftp/Scheme/macros.html#dirty-macros

Linus Torvalds? He created Linux and git. Arguably the two most successful open source projects ever.

Linus has demonstrated incredible long-term effectiveness as a software developer, both creating and then shepherding two of the most important pieces of software of the last 50 years. But he seems qualitatively different than Ballard.

I'm trying to put into words what the difference feels like. Git and linux demonstrate, for Linus, great intelligence but not genius, the way Ballard's works do. And on Linus' side, git and linux demonstrate leadership, pragmatism, and a tremendous understanding of how to actually drive a large project forward over time, which Ballard's works don't.

Torvalds is like Brahms, who published relatively few works, but polished, refined, and winnowed them until they were of very high quality. He wrote his duds, but he knew enough not to publish them. Ballard is like Bach: an unbroken series of gems, mostly small- to medium-sized, each one an immaculate work of craftsmanship wedded to incandescent genius. Nothing in the entire hoard is inferior work --- there's nothing you can point to and say, "Bach screwed up here."

Rob Pike and Ken Thompson: UNIX, Plan9, UTF-8, Golang.

Rob Pike was born in 1956 so he didn't have anything to do with the original Unix. Maybe you're thinking of Dennis Ritchie?

Pike's account of how UTF-8 was invented is a fun read: https://www.cl.cam.ac.uk/~mgk25/ucs/utf-8-history.txt

Wikipedia says "was a member of the Unix team". Not completely sure what that implies.

perhaps John von Neumann

Can't speak to 1, but I kind of feel like TJ Holowaychuk in the Node.js community started getting close to Fabrice's level (until he left Node). Express, Stylus, Koa, Formidable, etc...

TJ has created a large number of popular software packages, but I don't consider the depth of the software to be close in complexity of the type of software that Fabrice is capable of - basically anything he puts his mind to.

bellard.org - has the most impressive portfolio of software created from a single developer I've ever seen. It's more astonishing how varied each of his accomplishments are - covering some of the hardest programs in different computer science fields.

He's by far the best programmer in my book, I'm not sure who I'd put at #2, there's a number of contenders, but anyone else I can think of are experts in their respective fields, I don't know of anyone who has compiled such a broad list of complex software covering that many different fields.

Yeah, it's the breadth that gets me. There are several very impressive expert programmers in their area, but Fabrice seems to be able to step into any subfield he finds interesting, work on it for a couple years, then leave something behind that others are willing to spend years of their lives maintaining and extending. I could see QuickJS quietly running on a Mars rover 10 years from now. Not because JS. Because Fabrice. Always bet on Bellard.

Donald Knuth is certainly in the same league.

No doubt a brilliant academic and mathematical mind with invaluable contributions to field of comp-sci and algorithms and author of the iconic TAOCP, but in terms of software works he's single-handedly produced? He's most famous for TeX typesetting system and inventing Literate programming, but his other software have had a lot less impact.

But that's mostly by choice as he's predominantly a professor who spends most of his time teaching so he's obviously going to have created a lot less body of digital works than a full-time developer is going to have.

He also designed and implemented METAFONT.


Take it easy on the insults ;)

Also Pug (Formerly Jade)

>FFMpeg is almost a PhD thesis

I’d argue it is a whole lot more than most PhD thesis.

Fabrice is a wizard.

That's probably true; FFMpeg almost single-handedly created an entire cottage industry in video production. The amount of elaborate image-processing it allows you to do probably does overtake most PhD papers you're likely to read.

One thing to note... he doesn't bother himself with pretty websites, community building of any kind, splash pages... It's just plain html. Not even github as far as I could tell. He just works on the tech and puts it out there with benchmarks as proof of his claims.

His humility (and general lack of "marketing wank" on his site) is certainly another aspect I admire. There's far too much "look at my absolutely amazing $trivial_app with best-in-class X and high-quality Y and gorgeous Z and ..." out there, that just seeing the equivalent of "This is a JS engine I wrote." and a simple enumeration of features without all that embellishment feels very refreshing.

Yes that's true in general, but ... I hate to be the party pooper here, but ....

What makes this JS implementation deserve the name "Quick"?

I noticed it doesn't appear to do JIT compilation or any of the fancy optimisations V8 does. So whilst it may start up quickly, and may interpret quickly, it won't actually execute JS quickly relative to V8, unless I missed something huge in the linked web page.

I got the sense there are several performance claims here that sound impressive but won't actually matter for nearly every JavaScript user.

It seems to be relatively very fast in the space of small javascript interpreters meant for embedding. That's a different niche with different constraints.

But "embedding" is a very vague term. You can embed V8 too. It's just a C++ library, it can be linked into other programs. It can run on relatively small devices. If you're going to say, but what about even smaller devices than that then sure, maybe this implementation can squeeze into a certain class of rare device that can't run V8. But then why would such a constrained device be running JavaScript at all. That would seem to be the issue there!

You certainly can embed V8, but it's a more involved affair. It's not the use case that's prioritized.

It's not at all my field of expertise, but my guess is that problems with V8 are that it's an order of magnitude larger, that it's written in C++ rather than C89, that it's more likely to make large changes to the way it works, and that it uses more memory.

All of those are good decisions to make for a component of Chrome that helps run webpages. But sometimes you'll only want to make it possible for users of your less than massive technical application to script its behavior using a language they might already be familiar with, and then those properties are undesirable.

"Quick" calls to mind something that's not just fast, but nimble.

QuickJS also compiles to machine code.

Also the x86 emulator in JS that can run windows 2000 on a browser canvas.

Wow... I didn't pay attention to the URL and when I open this site I thought 'Who does an insane project like writing a new JS/ES interpreter all by himself (in C). Almost as insane as the guy who wrote that x86 emulator for the browser...'.

Just to learn that it is indeed the same guy (plus Charlie Gordon) :D

Before that, there even was a third party demo of QEMU running in the browser using PNaCl. Right after PNaCl died, jslinux popped up to continue the legacy, but with even more awesomeness.

Yeah this is just crazy. I think he and ludde together are responsible for like 90% of software I like and use very frequently. ;-)

ludde who?

Probably Ludvig Strigeus [0].

[0] https://en.wikipedia.org/wiki/Ludvig_Strigeus

ludde together

the rapper Ludacris, duh.

You forgot LZEXE...

That was my first "introduction" to Bellard.

The second project of his that I came across was https://en.wikipedia.org/wiki/Bellard%27s_formula and his page on π: https://bellard.org/pi/

I didn't even know about that one!

How do you become like this?

Hard work, math, learning and hard work again. Definitely not by drinking at various networking and social events as some people think. :)

Wow. 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.

>> 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.

> Why would you have a distaste for JavaScript based on how others use it?

Languages don't exist in a vacuum. The way libraries are written and the way coworkers write code has a huge effect on us.

> proven over time its flexibility and adaptability to become probably the single most used language

Its usage has nothing to do with its quality. The web has a low barrier to entry, and well web devs have to use JS because browsers handcuff us to it.

If JS were so great, we wouldn't have increasing TypeScript adoption or a million compile-to-JS languages.

I've been writing JS for 20 years. I use bleeding-edge features, TypeScript, and Babel. I've done front and back end. It still sucks (which is sometimes the fault of V8, but not always).

> I know you're not meant to ask why the downvotes, but I do wonder in this case

I'm not a JavaScript hater - these days it's my main language - but your comment was pedantic and interpreted his words uncharitably. By "distaste for JS" he clearly just meant vague negative emotions surrounding it, not that he thinks it's an invalid language. He even specifically says his distaste is circumstantial.

JS is the new PHP. It's really popular (i.e. lots of n00bs) and not at all elegant, so the programmer elite regard it with derision.

I also notice people often conflate the problems of overzealous browser-based scripting with JavaScript the programming language. This is pretty understandable since JavaScript has been the only browser scripting option for 2 decades, but those problems would exist no matter what options were available for browser scripting. It's a safe bet to assume that the problems would actually be much worse if JavaScript wasn't the only browser scripting language available since that would mean browser-based scripting would be more accessible to more programmers.

In another 6-8 years when WASM targeting alternatives become more mature we will see a new explosion of browser scripting.

> not at all elegant, so the programmer elite regard it with derision

Having both programmed PHP and Javascript extensively, PHP when it was first designed was absolute junk, functions were bucketed by strlen. Javascript at least had some semblance of sanity even with the wonky comparison mess and ===.

> JS is the new PHP. It's really popular (i.e. lots of n00bs) and not at all elegant, so the programmer elite regard it with derision.

I would love to find a language I consider more elegant than modern JS/TS. Haven't seen anything yet though. I also question your claim that it's the "elite" who regard JS with derision. Fabrice is presumably fine with it considering he spent valuable time writing an engine for it.

I don't think JS/TS is that bad, but it's certainly pretty far from elegant. TS adds decent type support which helps tamp down on dynamic complexity but rust, go, kotlin, c#, swift, ocml even java are all much more elegant languages. I realize that elegance is largely subjective so I won't belabor the point, but it's a pretty widely accepted subjective assessment.

check out ocaml

The comment you are replying to gives the reason of disliking the abuse, to weaken the point on the dislike of Javascript, not to fortify it.

The amount of JS I come across on sites that is purely superfluous and serves to irritate, manipulate, or simply waste resources far outnumbers the actually useful, efficient, and purposeful use of it in webapps. I'm talking about things like loading several MB of it with half a dozen frameworks and libraries, just to render a few KB of text. Don't even get me started on popups/popunders/popins/clickjacking/scrolljacking/historyjacking and all that other crap that JS gets used for far more often.

Observe that Bellard's own site, despite having a few JS-based projects and demos, and now himself being the author of a JS engine, has not succumbed to the "JS everything!!!1" fad.

(FYI I didn't downvote.)

Ok, so this comment is so cliche it's getting hard to ignore. Yes, JavaScript is abused but the problem is that people by large enjoy these types of site.

I've never heard my parents or non-developer friends complain about a site using too much JavaScript, but if I show them Hacker News or old.reddit.com, they'll complain it looks ugly and hard to read/use and really do lose interest in it immediately.

Anyway, I fail to see how this is a problem of JavaScript. Replace JavaScript with any other language in the browser and you'll see exactly the same abuse happen.

If you really dislike JS so much, do what I do and disable JavaScript in the browser. If a site doesn't work I don't use it. People on Hacker News seem to want the web to revolve around themselves but it never has done and never will.

> I've never heard my parents or non-developer friends complain about a site using too much JavaScript

How can they? They don't know what it is. They are complaining about it a lot of times you don't hear about it; every time they have to fill an abomination of a form, every time they hard-close their browser because it's stuck, every time they just wait for a page to load, every time 'something' happens they did not ask for but it happened anyway.

That's not the fault of JS but it is the problem of the ecosystem, the ease of use etc. Messing things up and 'good enough' are very popular things it seems. The thing is that, on the internet, good enough can go wrong in many ways. And the ways it does just tired people out in reporting it. Besides the billion $ sites (and still there , but less), there are so many bugs in the average website; we just ignore them and start over or go somewhere else because it's just not worth burning your energy on; no-one is going to change. And a lot of that is broken JS. Again, not the fault of the language JavaScript, but of the fast and loose usage of the language.

Anecdotally, but I am sure this resonates with people who sometimes do not order only from Amazon, I tried to order some impossible meat from a site here and when it was time to pay, there was a JS undefined error and it emptied my shopping cart. This happens a billion times a day all over the place.

JavaScript is vilified by 'the elite' because of it and that's unfair, but the ecosystem promotes it. Everyone is focused on 'process' (CI, deployment, many irrelevant unit tests; a lot of busy work basically) and 'beautiful code' (style, linting, things a beautifier can do for you automatically) and ego (github stars), but robustness or longevity is just not really a focus of many.

Everyone is focused on 'process' (CI, deployment, many irrelevant unit tests; a lot of busy work basically) and 'beautiful code' (style, linting, things a beautifier can do for you automatically) and ego (github stars), but robustness or longevity is just not really a focus of many.

You just summed up the entire web development ecosystem in general. There's also the trendchasing and continual churn of breaking things that used to work just fine, replacing them with even more inefficient and complex solutions. In the area of the software industry that I work in, doing things that way would quickly make customers disappear.

The "inelegance" or otherwise "lack of purity" of JS doesn't really bother me; a lot of languages have parts like that, and I've written some JS myself.

> I stand by these comments - JavaScript is a flawed but great language

I like my languages a bit less flawed, thank you very much.

This 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

yes! he has been one of my favorite programmers over all these years. so happy that he continues to dispel the 10x programmer myth. at least, as far as i am concerned. we should all take note. it's less about productivity but more about focus and hard work.

this project seems to have started in 2017. from a quick glance at the code, they used c (his favorite language) -- which by the way people are still there convincing us not to use. many of us would have been discouraged, distracted, or simply fazed by the pace of our field.

that is so inspiring.

> from a quick glance at the code, they used c (his favorite language) -- which by the way people are still there convincing us not to use.

Here is an alleged UAF in this library https://twitter.com/qwertyoruiopz/status/1149424025111801858

that's an excellent point. kudos for that hacker!

> so happy that he continues to dispel the 10x programmer myth

What do you mean by that? The only way I see him dispelling that myth is that he's a 100x programmer instead of a 10x.

I think OP was saying the myth of the myth was dispelled.

if anything he's proving the 10x programmer. You will have a tough time hiring 10 different average programmers to build that.

Ha! Fabrice is prolific enough to where two people felt that they had to exclaim it to the world.

He's probably worth $300-$500/hr if not $1k...

There's at least two years of work in there as Fabrice Bellard's side project. This would mean about ~10-15 man-years of full-time work for a small team of experienced engineers, which is about what it took for jerryscript:


Granted, the targets aren't exactly the same (micro-controllers vs very small lib), but benchmark differences are impressive:


That's a pretty standard range for high level consultants. Bellard can definitely bill well above that, if there are tasks that require his talent.

How much higher above $1k/hr can he bill?...

Someone like him wouldn’t be billing by the hour, but rather as a portion of overall value created. For the kind of non-trivial jobs worth his time, six figures at least.

Any FAANG would happily pay him a 7 figure salary if he was interested.

Normally I'd consider this hyperbole, but if I had the means I would absolutely offer it. He's a generational talent.

Can you really put a number on this level of skill and productivity?

The problem with putting a $ figure on it is that people who create free software create emmense amounts of value but don't capture even a tiny fraction for themselves. OTOH to montize their genius they need to help corporates do things that are not neccesarily great for society. Also a coporate situation may hamper their genius, although at this level he probably gets to call the shots.

Also a lot of useless consultants would earn that much, as would people doing shady shit, as well as many talented people so the $ comparison is kind of insulting.

Yeah... his current employer already does.

You assume he's optimizing for money.

Do you know who his current employer is (if any)?

He has his own company now with another partner (https://www.amarisoft.com/) where they work on and distribute the LTE software he wrote.

Well, the scrolljacking is evidence no one is infallible. ;)

Well, not all lazy HN commentary, like criticisms of 'scrolljacking' should be taken seriously. ;)

It seems like he works here: https://www.amarisoft.com/about-us/

Worth 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.)

2019+ will Atwood's law compiled to WASM.

My co-worker Jason wrote a JS engine in Rust, 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

Ah yup this was the only one I had seen before, and looks really promising! Didn't know about the others posted so thanks all!

Could these be able to do SSR for Vue from a Rust web server?

Would 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

Definitely not the first JS VM compiled to the browser. Aside from JSC as another comment mentioned, there was also js.js which is SpiderMonkey compiled to JS (around 2012!),


This shouldn't be surprising - many VMs have been compiled to the Web, like Lua, Python (both CPython and PyPy!), etc., and JS is just another VM.

Safari's JavaScriptCore has been available on WASM for some time:


Online demo of JSC.js


You should talk to the guys at Wasmer: https://wasmer.io/

Qt has built for webassembly for quite some time and comes with an ES7 engine

Have you looked at https://github.com/Agoric/SES ? (Not production yet.)

The 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

I have a small, CPU-intensive benchmark which shows the performance of QuickJS to be comparable to other interpreters written in C. It's on par with MicroPython and recent versions of Ruby, and a little faster than CPython and Lua.

However, it's still 2-3x slower than the optimized, CPU-specific interpreters used in LuaJIT and V8 (with their JITs disabled), and 20-100x slower than the LuaJIT, V8 and PyPy JIT compilers.

Thanks, those were the numbers I was really interested in.

I figured there's no way it would be as fast as say V8 who has Google+others working for years to make it as fast as possible.

Not that it's a bad thing! They just have different purposes.

On 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

If 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.

We usually forget the purpose of scripting languages.

Main purpose of them is to be a glue between native calls: take output of one native function and pass it as input to other. So instead of writing ray-tracer in JS you should write it as a native function (not even in webasm).

In my Sciter (https://sciter.com) I had the similar dilemma:

Either to use a) some compileable language (of V8 with JIT) or to use b) something small but to provide easy ways to extend script by custom native functions.

I've chosen b) and so the engine that does HTML/CSS and scripting is 6 times more compact than just only V8 binaries. For an embeddable engine that is clearly better.

For browsers, where running JS and no real ways for native code execution... they MUST have V8 and the like. That also leads to Electron problems... browser engines are simply not suitable to be used as embeddable UI engines, by design.

It 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.

From 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

[2]: https://bellard.org/quickjs/quickjs.html#qjsc-compiler-1

The 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.

Note that Bellard already wrote a (small) HTML/CSS engine for his Emacs clone. So we're only a small step away from Bellard-Browser.

Wait, he has an Emacs clone, too?

EDIT: https://bellard.org/qemacs/


Please don't start license flamewars on Hacker News, or any flamewars.


The 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.)

> GPL is unethical

No. You think that GPL is unethical. It does not make it unethical.

After thorough reading, your blog post did not convince me and here is why:

> Proponents argue that the GPL has a long-term goal of making more software free for all, by limiting short-term freedoms of some, for the sake of encouraging the propagation of the GPL via software, like a virus. That’s why it’s called a viral license.

This is a faulty comparison [1]. You do choose to use a code under GPL and make your code under GPL as a result. You don't choose to catch a virus. See also [2].

> they are using a system they fundamentally disagree with, in order to promote and propagate a new system, and they are doing this from within the new system, which they would replace the old system with from without if they could.

What is your suggestion? They live in our world by its rules. How do you want them to achieve their goal? Also, what is wrong with doing this?

> So the authors of software have rights, a fact which proponents of the GPL agree with. But they argue that the users of software have rights which should, in an ideal system, trump those of software authors.

> This is a clear contradiction. In an ideal legal system, either the software authors should have the absolute right of licensing their software as they see fit, or the software users should have the absolute right of accessing and modifying the software regardless of the software author’s wishes and intent.

Sorry, I don't understand the contradiction here.

> Experience shows that most people see nothing wrong with the current system: let authors distribute their work with whatever licenses they want, and let the market decide whether an author’s requirements are reasonable enough to cooperate with.

Great. If "experience shows", you must have a reference, right? Anyway, this is an argumentum ad populum [3]. "[it] is a fallacious argument that concludes that a proposition must be true because many or most people believe it" [which does not make it right].

Also, I don't want to "let the market decide". I want good behavior to be enforced, not some hazardous process that might end up producing a good behavior. The "market" is not necessarily right. There is no guarantee here. But I agree this is personal opinion. Anyway: choosing to use GPL is indeed a way to participate in this free market, if such a thing exists, and "let it decide".

> Practical philosophical systems agree with this. When someone creates a work, they have the absolute right to do what they want with it, as long as they themselves do not break the law, and as long as the existence of the thing itself doesn’t violate the law either.

Oh, there we seem to agree. So authors of GPL software do not want to see their code used in proprietary software.

> Thus, the heart of the GPL goes against common sense, experience, and the just liberty of creators over their creations.

It goes against your common sense, not mine. Talk about common sense now.

> But that actually brings up an interesting point: the GPL actually limits people’s freedom.

This is the point of the GPL. To prevent people from reusing the code without forwarding freedom to users. If you make a code that is proprietary, you are the one who is "actually" limiting freedom of other people.

One person's freedom ends where another person's freedom begins. Freedom is nothing like an absolute graal.

If you are pissed off because you can't reuse some interesting GPL code in your proprietary software or your permissively licensed software, well, you are free to not use it. Nobody forces you to do it. You are also free to (re)consider setting your program under GPL. It is your choice, and one of the goals of the GPL too.

Thing is: there is no absolute truth. Some people think that the right way to write free software is to use permissive licenses. Some, to use copyleft. Some people think they should be free to produce proprietary software. Some people think that proprietary software is unethical and have given many solid arguments for that. Common sense on this question is apparently non existent (yet?).

[1] https://www.logicallyfallacious.com/tools/lp/Bo/LogicalFalla...

> Tip: Comparisons of any kind almost always are flawed. Think carefully before you accept any kind of comparison as evidence.

[2] https://en.wikipedia.org/wiki/Argumentum_ad_populum

[3] https://en.wikipedia.org/wiki/Viral_license#Criticism_of_the...

Wait, QEmacs was written by Bellard, too? I stumbled across it a while ago but I didn't pay attention to the author.


If it's the same QEmacs as the one on Amiga, I think I'm going to faint.

qwertyoruiopz already found a use-after-free bug: https://twitter.com/qwertyoruiopz/status/1149424025111801858

There 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. :)

This 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.

This 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

I'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.

This is super impressive!

Also - Yay! Another awesome target for ClojureScript - capable of producing standalone binaries!

Yeah, interesting..

I 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.

... 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

I 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?

I 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.

> Ideally someone would just do an "stb"-style JavaScript interpreter that would fit into a single .c or .h file.

DukTape is already that.


Thank you for your example!

Does the the application basically pass data to a user script (the user knows JS so it is useful for them?), and then the JS returns the data after processed?

Amusingly I asked the question and remembered that I actually worked on (supported) a hardware product that did this to some extent. It was a disaster as the scripting language would eat memory / cpu and crash the box ;)

Correct, the application acquires data from hardware and allows the user to access it from their own JavaScript code. This is useful for automated test, report generation, debugging, things like that. Crashing is bad for customer relations. :) V8 has performed well in that regard, no complaints there. I just don't see why it has to be so massive.

You 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.

Thank you!

I'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?

Apparently the garbage collection algorithm is reference counting with cycle removal: 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).

Curious what ”The cycle removal algorithm only uses the reference counts and the object content” means in practice. Is it based on some well known algorithm?

From the description it's probably a Bacon cycle collector. The basic idea is that it checks to see whether reference counts for all objects in a subgraph of the heap are fully accounted for by other objects in that subgraph. If so, then it's a cycle, and you can delete one of the edges to destroy the cycle. Otherwise, one of the references must be coming from "outside" (typically, the stack) and so the objects cannot be safely destroyed. It's a neat algorithm because you don't have to write a stack scanner, which is one of the most annoying parts of a tracing GC to write.

This 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).

Would 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.

quickjs.c is a 47,842 line C file. I think that sets the record for the largest handwritten file I've seen.

Although decomposition into corresponding files is the norm, it’s so satisfying to say “hey, check out my JS engine” and point people to a single work-of-art uberfile. LOL.

"Don't be snarky."

"Please don't post shallow dismissals, especially of other people's work. A good critical comment teaches us something."


It wasn’t sarcasm. I was being sincere.

I believe you, but a comment like that is going to pattern-match to the internet default, which is snark, in nearly every reader's mind.

I think you are overreacting here, his comment was definitely not interpreted as sarcastic. Quite the opposite, it was showing appreciation for what an achievement QuickJS is.

I was not being sarcastic!!

Is it hand-written as a single file, though? I'm assuming the release is the output of some script that does concatenation.

Some editors, like Emacs, make it very easy to work with one huge file, because you can have multiple independent views ("windows" in Emacs parlance) into the same file. It is - or maybe has been - quite common to work like this in LISP communities.


As an Emacs programmer, I much prefer working in one 10kloc file than 20 500loc files. The later I find pretty overwhelming.

To bring some balance to the universe - as a vim user, I tend to prefer doing the same.

From a cursory glance, it doesn't look like it's a bunch of files concatenated together.

It'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.

You 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.

Not 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.

Any chance he has a super loooong screen? XD

I 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.

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.

> 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.

Both can decompress tarballs. No idea if mobile ever crossed their mind.

Windows 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.

Can 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)

other 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)

Now finally, kernel space JavaScript is in reach! ;-)

That's horrifying

Wait til someone hijacks the nfs driver repo on npm. That's where the real fun begins.

Why are we ignoring the second author? :)

Actually, 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.

who is this Charlie Gordon ?

Seems like a pseudonym; Charlie Gordon is the name of the protagonist in Flowers for Algernon.

> 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.

I suspect that too. Note that FFmpeg was also published under a pseudonym Gérard Lantau.

Will the source of this be published to github (or similar) for contributing?

Not my site, but a recommendation:


Well, you can always email patches.

How does one keep track of Fabrice Bellard's work? I couldn't find a Twitter profile, GitHub profile, or RSS feed from his website.



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.

He 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.

When he creates something, you will know.

I 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?

Try 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

Ah yes of course – thanks, works as advertised now! :o)

Really cool stuff!

Heads 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.

similar 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.

   ifndef CONFIG_WIN32
   # force 32 bit build for some utilities
   # CONFIG_M32=y
find it here.

Try ./qjs -m examples/hello_module.js

He does it again. The other small footprint engine used to be Jerry

Freaking impressive and incredibly performant.

Imposter syndrome kicks in when I see how much Fabrice has accomplished.

What a legend.

I 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!

I'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/example...

    import * as std from "std";
    import * as os from "os";

    std.printf("%d\n", 1);
    std.printf("%s\n", os.platform)

Awesome thanks!

I'm curious - what is/was the intended application of this?

I 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.

A 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).

Right - 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.

also can be embedded in a microcontroller

Very nice repl with syntax highlighting.

Would it be possible to compile a nodejs app to a binary with this? If so, would performance be any better?

I 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.

Couldn'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.

fs/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.

How could we easily expose syscalls to `qjs`? Deno is just a Rust IPC/syscall layer glued to V8 really...

Some 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

[2]: https://bellard.org/quickjs/quickjs.html#QuickJS-C-API

Perhaps libuv-webserver[1] could be used for that purpose?

[1]: https://github.com/springmeyer/libuv-webserver

It'd be super neat if he added a native `net` module. Then we could do node.js http/net vs QuickJS benchmarks.

It would have a much lower memory and binary size impact. If your program is short-running, it could also be faster.

Doesn'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)

I 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.

Is it possible to contribute a patch? How should I do it?

My recommendation for getting started:


from https://bellard.org ...

If you have any questions or suggestions, write to fabrice at bellard

> 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?

I wonder how different jslinux (obviously) would behave on it.

Does 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.

Would this be a suitable replacement for SpiderMonkey as an embedded JS engine for a Desktop Application?

Many projects use duktape (https://duktape.org/)

There'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.

So 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.

I have question. Do you think that this could be used as a brick to build an alternative web browser?

  Undefined 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?

Yeah, 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.

Thanks! That solved it for me.

How fast is it compared to V8?

by linking c modules, comparing it with v8 is no longer meaningful

Does 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

It's not x86 specific.

Curious too. Anyone help pointing a way how to verify the possibility?

quickjs.c is 47,842 lines of non-generated code. :mindblown:

The 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/comp...

Heh, and I work where some complain about 5k line Java files.

5k line Java files sounds awful

The thing about a 5,000 line Java file is that it's Java, so it's probably also 5,000 columns.

Oh it is.

The operator overloading is potentially huge. Along with the BigInt/Float extensions, it makes it a great target for scientific computing applications.

At the bottom of the page there is this the mention of "Charlie Gordon". Who is he ?. Any place to find the works of him.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact