TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

A small but complete JavaScript engine

438 点作者 marcobambini超过 4 年前

27 条评论

megous超过 4 年前
QuickJS is quite a pleasure to work with, for variety of reasons. Not using setjmp/longjmp and having a nice internal resource leak debugging mechanisms are just a few of them. I've already replaced most of my duktape uses with QuickJS, and I'm quite happy with the result.
egonschiele超过 4 年前
Bellard is actually a genius, right? What's his secret? The project list at bellard.org is impressive.
评论 #24883796 未加载
评论 #24883962 未加载
评论 #24883769 未加载
评论 #24883382 未加载
评论 #24884547 未加载
tomcam超过 4 年前
A pleasant, informative, and painfully incomplete article about him can be found here:<p><a href="https:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20110726063943&#x2F;http:&#x2F;&#x2F;www.freearchive.org&#x2F;o&#x2F;55dfc9935a719fc36ab1d16567972732c2db1fd7d7e3826fd73ee07e4c3c7d0b" rel="nofollow">https:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20110726063943&#x2F;http:&#x2F;&#x2F;www.freear...</a><p>No mention of his secret sauce other than, well, things bore him and he moves on.
评论 #24888986 未加载
iamvnraju超过 4 年前
Frabrice Bellard truly works in God mode. Ffmpeg, Qemu, Tiny C Compiler ... many others .. and now this!
评论 #24882359 未加载
评论 #24882473 未加载
评论 #24884815 未加载
评论 #24883181 未加载
thamer超过 4 年前
Currently composed of 85,624 lines of C code, mostly in quickjs.c (53,575 lines in that one file alone), but also with a couple other large ones.<p>I can&#x27;t say I understand the reason for such massive files. Surely it would be easier to maintain if it was split into a few well-defined modules?<p>In addition to the maintenance concerns, a JavaScript engine has quite a few parts that could be used as individual components. One good example of this is node&#x27;s http-parser[1] that was extracted to a self-contained C file with associated headers and is a pleasure to use.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;nodejs&#x2F;http-parser" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;nodejs&#x2F;http-parser</a>
评论 #24883546 未加载
评论 #24884015 未加载
评论 #24883248 未加载
评论 #24885204 未加载
评论 #24883483 未加载
评论 #24885222 未加载
评论 #24883219 未加载
评论 #24883330 未加载
pansa2超过 4 年前
&gt; <i>Can compile Javascript sources to executables with no external dependency.</i><p>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?<p>I know there’s the alternative of bundling Node.js and V8 into an executable, but the resulting binaries are large - it feels like the command-line equivalent of using Electron.
评论 #24883112 未加载
评论 #24882600 未加载
评论 #24883225 未加载
WalterBright超过 4 年前
Here&#x27;s another JavaScript engine (written in D):<p><a href="https:&#x2F;&#x2F;github.com&#x2F;DigitalMars&#x2F;DMDScript&#x2F;tree&#x2F;master&#x2F;engine&#x2F;source&#x2F;dmdscript" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;DigitalMars&#x2F;DMDScript&#x2F;tree&#x2F;master&#x2F;engine&#x2F;...</a><p>23,906 lines of code.
untog超过 4 年前
QuickJS is a really, really interesting engine because it&#x27;s only ~200KB. Fits a lot of cases where you want to add scripting ability but without bulking out size unnecessarily.<p>Unfortunately because it lacks stuff like JIT it&#x27;ll never rival the likes of V8 in performance. But in terms of bang for buck it&#x27;s unbeatable.
评论 #24884069 未加载
评论 #24883151 未加载
评论 #24883533 未加载
seph-reed超过 4 年前
Here&#x27;s a really interesting video about speed performance of the v8 engine:<p><a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=aC_QLLilwso" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=aC_QLLilwso</a><p>The basic points: They watch functions for &quot;hotness&quot; (how often they are ran). Then, any function that is super hot, they&#x27;ll see if it&#x27;s being ran consistently (ie always receives two numbers as its arguments). Then they&#x27;ll make a streamlined interpretation of the js code which only checks the arguments and then skips pretty much all the other checks. By doing this, it makes JS significantly faster.<p>If you&#x27;re trying to compare and contrast v8 to quickjs, this is the first thing that comes to mind for me as to what they may be doing differently.
评论 #24882682 未加载
javajosh超过 4 年前
Very cool. Wouldn&#x27;t it be cool if someone wrote bindings for Linux system calls and provided an event loop for this engine - then you could write system software in JavaScript!
评论 #24882630 未加载
评论 #24883209 未加载
jitl超过 4 年前
I’ve got a typescript library wrapping QuickJS if you don’t want to do the emscripten build or figure out the C API yourself: <a href="https:&#x2F;&#x2F;github.com&#x2F;justjake&#x2F;quickjs-emscripten" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;justjake&#x2F;quickjs-emscripten</a>
benibela超过 4 年前
Here is another one: <a href="https:&#x2F;&#x2F;github.com&#x2F;BeRo1985&#x2F;besen" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;BeRo1985&#x2F;besen</a>
评论 #24883880 未加载
jiggawatts超过 4 年前
&gt; An online demonstration of the QuickJS engine with its mathematical extensions is available at numcalc.com. It was compiled from C to WASM&#x2F;asm.js with Emscripten.<p>Turtles all the way down!
评论 #24884109 未加载
zzo38computer超过 4 年前
It look like good (including there are some good features that I do not see in other implementations), although there are some things which may help:<p>- Support ISO-8859-1 encoding (true ISO-8859-1 encoding, not Windows-1252) in addition to UTF-8, for all of the functions that can read text from files and write text to files, to avoid having to implement it by yourself one byte at a time. This is useful when you want text which is mostly ASCII, but which may contain extended characters that aren&#x27;t Unicode. (There is no need to support any other character sets or encodings, though.)<p>- Document the C API better. Currently, the documentation isn&#x27;t very good.<p>- Implement WTF-8 (if it isn&#x27;t already), so that arbitrary JavaScript strings (which are strings of 16-bit characters) can be represented as UTF-8 without losing data. Often the text will be ASCII anyways, and you will want to use ordinary C strings,<p>- Add a API function to read&#x2F;write strings of 16-bit characters. (This is probably unnecessary for property names, although it is helpful for strings.)<p>- Add an option to disable use of Unicode tables, in case your program does not use them. (UTF-8, String.prototype.codePointAt, etc would still work regardless, since they don&#x27;t need Unicode tables to work. However, it would prevent Unicode properties from being used in regular expressions, remove String.prototype.normalize, and case conversion would be limited to ASCII (or perhaps ISO-8859-1) only.)<p>Additional optional extensions may be wanted, even if not enabled or even included in the executable by default (due to complexity), such as:<p>- PCRE.<p>- Option to disable automatic semicolon insertion.<p>- A &quot;goto&quot; command; you cannot jump into blocks, past declarations at the same level (in either direction), or out of functions. You can otherwise jump forward and backward within a block (including past nested blocks) or out of a block.<p>- Possibility for a function called by one JavaScript program to suspend that program while executing a different JavaScript program (which may possibly share objects with the first one), and later resume execution.
评论 #24883552 未加载
tomcam超过 4 年前
When the master race led by Fabrice Bellard takes over... I just hope I&#x27;m shown some mercy. Because I clearly have nothing else to offer the new world. Holy cow, this person is nothing short of amazing.
etaioinshrdlu超过 4 年前
I wish Bellard were here on HN to comment with us.
评论 #24883644 未加载
Wowfunhappy超过 4 年前
Could this potentially be used in a browser? How complete is “complete”?<p>Browser diversity is top of mind for me...
评论 #24882609 未加载
评论 #24882613 未加载
评论 #24882668 未加载
nt2h9uh238h超过 4 年前
Focus on speed, not disk size. We&#x27;re still in stonehenge, surrounded by extremely slow and un-optimized hardware and software.
评论 #24894890 未加载
anthk超过 4 年前
How compares this with Duktape? I can post on some JS needed sites with edbrowse just fine, even allowing me to show some shortened long comments with JS.
svnpenn超过 4 年前
Pretty cool, but cant print basic objects<p><pre><code> const m = {year: 2019, month: 12}; console.log(m); &#x2F;&#x2F; [object Object] </code></pre> Compare with Node:<p><pre><code> { year: 2019, month: 12 }</code></pre>
评论 #24883109 未加载
known超过 4 年前
<a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Fabrice_Bellard" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Fabrice_Bellard</a> FTW
mschuster91超过 4 年前
Just... wtf? How much can one person reasonably know or have the time to actually do extremely deep dives?!<p>Fabrice Bellard truly is one of a kind in the programmer world.
kelvin0超过 4 年前
Tears of joy at every post from his repo!
steipete超过 4 年前
This project has no issue tracker.
choeger超过 4 年前
That&#x27;s truly impressive.
kevinhq超过 4 年前
i wish this small and wonderful js engine will be adopted accross popular browsers (well, perhaps it&#x27;s too much even for a dream)
nt2h9uh238h超过 4 年前
so it&#x27;s 50X smaller and 30X slower than Googles V8 Engine - cool, but not that impressive. I would still use V8 on any decision, because 30MB is really not such a big deal anymore. SPEED is what matters in 2020, not disk size!<p>Try to make a JS engine than is 50X faster than Googles V8, and you become a centimillionaire! :D &lt;3 Would love to see that.
评论 #24889198 未加载