

2019 年新开源的 JavaScript 引擎 QuickJS
source link: https://www.tuicool.com/articles/QBBvI3E
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

QuickJS 2019年7月9日 Fabrice Bellard 开源了一款 JavaScript 引擎,使用 MIT 协议。 Fabrice Bellard 是一位计算机奇才,著名的多媒体播放器 FFmpeg 就是由他发起,一生中开源了很多项目,比如 QEMU 等。
QuickJS 是一款小巧的可嵌入 JavaScript 引擎,它支持 ES2019 规范,包括模块,异步生成器和代理器。 主要特征有:
1.Small and easily embeddable: just a few C files, no external dependency, 190 KiB of x86 code for a simple hello world program.
简单而方便地嵌入,只需几个 C 文件即可搞定,无需其它额外的依赖,一个简单 hello world 程序,运行在 x86 机器上只需 190 kiB;
2 .Fast interpreter with very low startup time: runs the 56000 tests of the ECMAScript Test Suite in about 100 seconds on a single core of a desktop PC. The complete life cycle of a runtime instance completes in less than 300 microseconds.
启动速度极快的解释器。
3 .Almost complete ES2019 support including modules, asynchronous generators and full Annex B support (legacy web compatibility).
几乎支持 ES2019 中所有的特性,包括模块、异步生成器和完整的Annex B支持(传统Web兼容性)。
4.Passes 100% of the ECMAScript Test Suite.
通过 100% 的 ECMAScript Test Suite。
5.Can compile Javascript sources to executables with no external dependency.
可将 Javascript 源代码编译成无需外部依赖的可执行文件。
6.Garbage collection using reference counting (to reduce memory usage and have deterministic behavior) with cycle removal.
使用引用计数做垃圾回收和循环删除。
7.Mathematical extensions: BigInt, BigFloat, operator overloading, bigint mode, math mode.
支持数学扩展运算,比如大整数,大浮点数,运算符重载,bigint模式和数学模式。
8.Command line interpreter with contextual colorization implemented in Javascript.
用 Javascript 实现了带有上下文着色的命令行解释器。
9.Small built-in standard library with C library wrappers.
带有使用 C 语言库包装的小型内置标准库 。
使 用 QuickJS 执行一段 JS 代码(代码保存在一个 hello.js 文件中):
var lefe = function log() {
console.log("超越技术公众号,关注一下吧,数据结构和算法,计算机通用技术")
}
lefe()
function sum(a, b) {
return a + b
}
console.log(sum(3, 6))
用 QuickJS 执行这段代码需要安装 QuickJS,在 https://github.com/horhof/quickjs 上下载代码,执行 make install 后即可。 安装完后执行,使用命令行执行上面的 js 代码:
➜ quickjs ./qjs /Users/lefe/Desktop/hello.js
超越技术公众号,关注一下吧,数据结构和算法,计算机通用技术
9
也可以在线上执行 JS 代码:
源码也不太多:
如果你对 JS 解释器比较感兴趣,可以看看源码,学习下 JS 是如何被执行的。最近在学习前端,看到这个项目比较好,推荐给大家,可以关注“素燕”这个公众号,一起学前端。QuickJS 文档也值得一读,超越技术公众号后台回复: qj ,或者直接前往 https://bellard.org/quickjs/quickjs.pdf 获得官方文档。
参考:
https://github.com/horhof/quickjs
https://bellard.org/quickjs/
推荐阅读:
图解数据结构和算法
Recommend
-
91
讨论良久,将会加入到 emoji v11.0 的新成员终于在正式揭晓了!其中最注目的是加入红发人种、超级英雌、卷发的黑人、海盗旗帜... 以及肥皂?超级英雄和超级坏蛋都会备有不同性别和肤色的版本,另外也有试管、盐、腿(?)、秃头和白发的人。Unicode 表示他们正进行...
-
38
据 AppleInsider 报道,天风国际旗下知名的分析师郭明錤的最新报告指出,苹果正在秘密测试全新的设...
-
109
QuickJS Javascript Engine News 2019-07-09:First public release Introduction QuickJS is a small and embeddable Javascript engine. It supports the
-
146
前几天,一个叫 Fabrice Bellard 的大牛程序员发布了一个新的 JS 引擎:QuickJS,引起了业界轰动。QuickJS 的主要特点是小,嵌入式,完整支持 ES2019 语法,和其他小型嵌入式 JS 引擎比起来,速度也很快。 登上大...
-
62
这些年规则的变动基本上出于两个原因:增加比赛流畅度/净时间,以及减少判罚争议(虽然多半没什么卵用)…
-
46
QuickJS 是一个完全由C语言编写的极小型JavaScript引擎,作者是大名鼎鼎的FFmpeg和QEMU的创建者Fabrice Bellard以及C专家Charlie Gordon。 QuickJS采用开源MIT协议,不限制商业用途。它是一个“小而完整的JavaScript引...
-
48
README.md QuickJS Javascript引擎 目录 1 简介
-
13
缘起 研究ART JVM的时候,我一直有一个遗憾,总感觉对Java语言的理解不深刻,从而我个人觉得自己对JVM的理解还处于相对初级的阶段——只能顺着代码里的执行流程去看。这个水平的话,改点小bug或许没问题,但如果将来Java加了新的语言...
-
13
QuickJS 引擎一年见闻录doodlewind雪碧 | github.com/doodlewind时间过得真快,转眼间...
-
8
作者 / Edward Cunningham, Android 安全和隐私团队 读过《持续提高 Android 应用的安全性与性能》一文...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK