Live data from Hacker News

A small but complete JavaScript engine

bellard.org

21–30 of 151 posts

Re: A small but complete JavaScript engine

#23
post #19

Earlier quoted context omitted.

I realize you're joking, but a company called Samsung actually did something similar already: https://nodejs.org/

Serious question, why is this a joke? Couldn't javascript be just another language to replace bash?

People typically write small, short scripts in bash, not web applications. The same goes for JavaScript, but in reverse. They were designed for different things.

Re: A small but complete JavaScript engine

#24

Could this potentially be used in a browser? How complete is “complete”? Browser diversity is top of mind for me...

As far as does this implement enough JavaScript features for websites to run, https://test262.report/ looks really promising! You would have to hook it up to DOM and network and all sorts of other APIs normally provided by browsers, though. One reason you might not want to build a general-use browser on QuickJS is performance. QuickJS is one of the fastest JS interpreters in its weight class, but engines like V8 achi…

Also QuickJS only gets security research done on it for fun: https://twitter.com/qwertyoruiopz/status/1150490648275034112

Re: A small but complete JavaScript engine

#25
post #19

Earlier quoted context omitted.

I realize you're joking, but a company called Samsung actually did something similar already: https://nodejs.org/

Serious question, why is this a joke? Couldn't javascript be just another language to replace bash?

bash is a domain specific language. It has many features to easily launch programs, setup stream redirects to files or to other programs. JavaScript is a general purpose programming language. It might be a better choice for general purpose programs, but when you need to glue some programs together, nothing comes close to shell scripting languages.

Re: A small but complete JavaScript engine

#28
post #26

Pretty cool, but cant print basic objects const m = {year: 2019, month: 12}; console.log(m); // [object Object] Compare with Node: { year: 2019, month: 12 }

The spec leaves that up to the implementation: https://console.spec.whatwg.org/#log

Node does some custom fanciness, but Object.prototype.toString() is equally correct.

Re: A small but complete JavaScript engine

#29
post #11

> Can compile Javascript sources to executables with no external dependency. Is QuickJS a viable way to write command-line apps in JavaScript? In particular, does it have enough of a standard library to work with, or would it be a struggle because (I assume) it can’t use packages from NPM? I know there’s the alternative of bundling Node.js and V8 into an executable, but the resulting binaries are large - it feels lik…

It has a very small standard library:

https://bellard.org/quickjs/quickjs.html#std-module

It would be enough for a good number of CLI tools, I'd think. But one big issue is going to be that every library on NPM is hardcoded to use Node's modules (e.g. fs) so you're not going to be able to use any external modules at all.

Re: A small but complete JavaScript engine

#30
QuickJS is a really, really interesting engine because it's only ~200KB. Fits a lot of cases where you want to add scripting ability but without bulking out size unnecessarily.

Unfortunately because it lacks stuff like JIT it'll never rival the likes of V8 in performance. But in terms of bang for buck it's unbeatable.

Post reply on HN