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]
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.
This 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?
Record-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.
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.
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.
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.
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.
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.
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.
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].
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'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?
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.
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.
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?
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.
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.
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.
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.
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
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.
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.
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.
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.
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.
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.
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`.
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.
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."
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.
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.
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.
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...
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
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.
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.
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.
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.
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.
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:
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.
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.
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.
The operator overloading is potentially huge. Along with the BigInt/Float extensions, it makes it a great target for scientific computing applications.
> 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.)
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 shou...
> 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.
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.
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.)
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!),
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).
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.
279 comments
[ 4.5 ms ] story [ 307 ms ] threadFor 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
[1] https://github.com/dflemstr/rq
[1] https://github.com/immunant/c2rust
Also - Yay! Another awesome target for ClojureScript - capable of producing standalone binaries!
As an Emacs programmer, I much prefer working in one 10kloc file than 20 500loc files. The later I find pretty overwhelming.
"Please don't post shallow dismissals, especially of other people's work. A good critical comment teaches us something."
https://news.ycombinator.com/newsguidelines.html
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.
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.
[1]: https://bellard.org/quickjs/quickjs.html#Standard-library
[2]: https://bellard.org/quickjs/quickjs.html#QuickJS-C-API
[1]: https://github.com/springmeyer/libuv-webserver
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.
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).
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:
I don't know what I did wrong – anyone else try it yet?[1] https://bellard.org/quickjs/quickjs.html#qjs-interpreter
Really cool stuff!
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/
[0] https://en.wikipedia.org/wiki/Ludvig_Strigeus
I’d argue it is a whole lot more than most PhD thesis.
Fabrice is a wizard.
Just to learn that it is indeed the same guy (plus Charlie Gordon) :D
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/
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.
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.
https://en.wikipedia.org/wiki/Metafont
I referenced this document a lot when writing my own Telnet stack.
[1] https://datatracker.ietf.org/doc/rfc1143/
There’s probably an interesting story hidden in there.
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...
Definitely a legend!
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.
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.
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.
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.
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.
https://www.amazon.co.uk/You-Are-Not-Gadget-Manifesto/dp/014...
He has a few chapters about problems (rarely mentioned) with GNU / GPL and Stallman himself.
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.
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.
With how things are going now, V8 code is the de-facto "upstream spec"
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
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'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.
EDIT: tombert beat me to it[0] by a couple minutes.
[0] https://news.ycombinator.com/item?id=20413498
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.
https://github.com/jerryscript-project/jerryscript
Granted, the targets aren't exactly the same (micro-controllers vs very small lib), but benchmark differences are impressive:
https://bellard.org/quickjs/bench.html
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.
Here is an alleged UAF in this library https://twitter.com/qwertyoruiopz/status/1149424025111801858
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 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.
If you have any questions or suggestions, write to fabrice at bellard
https://git-send-email.io/
Hopefully QuickJS won't discourage the author of Duktape from making future releases of his incredible small low-memory JS engine.
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.
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.
https://git-send-email.io/
EDIT: https://bellard.org/qemacs/
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
> 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.)
If you don't want the person you are distributing the software to be able to make modifications and adapt it just don't use GPL licensed software.
How difficult can this be?
As to the ethical dimension, I am sure you are as impressed by the ethics of John Deere as much as their customers are.
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 shou...
https://news.ycombinator.com/newsguidelines.html
Damn.
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.
https://wapm.io/package/jsc
Online demo of JSC.js
https://mbbill.github.io/JSC.js/demo/index.html
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
https://github.com/jterrace/js.js/
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.
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).