javascript 微小的javascript实现?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5384762/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 17:01:29  来源:igfitidea点击:

Tiny javascript implementation?

javascriptcembedding

提问by Dhaivat Pandya

I need an extremely tiny implementation of (maybe a subset of?) Javascript. Code size and memory usage are extremely important (speed isn't in the question, it can run as slow as it likes). It must be written in C (not C++), and that too, ANSI C (GCC extensions are okay). If it runs on a VM would be best, because I will have to write a compiler for it. Any suggestions?

我需要一个非常小的实现(也许是一个子集?)Javascript。代码大小和内存使用非常重要(速度不是问题,它可以随心所欲地运行)。它必须用 C(不是 C++)编写,也必须用 ANSI C(GCC 扩展可以)。如果它在 VM 上运行会是最好的,因为我将不得不为它编写一个编译器。有什么建议?

EDIT: Both of the responses I have seem good, except:

编辑:我的两个回答似乎都很好,除了:

SpiderMonkey concentrates a lot on making it faster, I don't care if its fast at all.
Quad-Wheel sounds good, except the activity on it, and code comments are few (I will be porting this to another architecture if that helps).

SpiderMonkey 非常专注于让它更快,我根本不在乎它是否快。
Quad-Wheel 听起来不错,除了它的活动,而且代码注释很少(如果有帮助,我将把它移植到另一个架构)。

So, any other responses would be great. Or, I could roll out my own simplified version of JS (but that doesn't sound fun at all)

因此,任何其他响应都会很棒。或者,我可以推出我自己的 JS 简化版本(但这听起来一点也不有趣)

采纳答案by Samuli Pahaoja

Duktape is written in C, with a focus on portability and compact footprint: http://duktape.org/

Duktape 是用 C 编写的,重点是可移植性和紧凑的占用空间:http://duktape.org/

回答by Coder of Salvation

I just discovered this ruby: https://github.com/gfwilliams/tiny-js

我刚刚发现了这个红宝石:https: //github.com/gfwilliams/tiny-js

I've been looking quite some time for this, since spidermonkey/v8 usually is pretty big and comes with several dependancies. Tiny-js is a portable 'run make and your done'-linux c-class. Perfectly for if you are only looking for simple bindings and prefer javascript/c-syntax over lua/other awesome scriptinglanguages.

我已经为此寻找了一段时间,因为 spidermonkey/v8 通常非常大并且带有几个依赖项。Tiny-js 是一个可移植的'run make and your done'-linux c-class。非常适合如果您只是在寻找简单的绑定并且更喜欢 javascript/c-syntax 而不是 lua/其他很棒的脚本语言。

回答by Bj?rn

An ANSI-C engine for ECMA-262: http://code.google.com/p/quad-wheel/

ECMA-262 的 ANSI-C 引擎:http: //code.google.com/p/quad-wheel/

Mozilla SpiderMonkeyis written in C as well, but probably to complex and large for you?

Mozilla SpiderMonkey也是用 C 编写的,但可能对您来说复杂而庞大?

回答by Robert Harvey

SpiderMonkey is Mozilla's C implementation of JavaScript.

SpiderMonkey 是 Mozilla 的 JavaScript 的 C 实现。

http://www.mozilla.org/js/spidermonkey/

http://www.mozilla.org/js/spidermonkey/

回答by CyberFonic

muJSfrom Artifex Software might be another option for embedded JS/ES implementation.

ArtifexSoftware 的 muJS 可能是嵌入式 JS/ES 实现的另一种选择。

回答by pcmacdon

You should look at Jsi, which was just released. It is very small, is a subset of javascript, and is in C (derived from quadwheel).

你应该看看刚刚发布的Jsi。它非常小,是 javascript 的一个子集,并且是用 C 语言编写的(源自 quadwheel)。

回答by Alfgaar

I think the jsi he's talking about is this: http://pdqi.com/cgi-bin/cgiwrap/pdqi/jsi.cgi/doc/tip/jsi/www/usingjsi.wiki

我认为他正在谈论的 jsi 是这样的:http: //pdqi.com/cgi-bin/cgiwrap/pdqi/jsi.cgi/doc/tip/jsi/www/usingjsi.wiki

(Don't blame it is not... hehe)

(别怪不是……呵呵)

回答by Peter MacDonald

http://jsish.orgwill redirect you to the host site.

http://jsish.org会将您重定向到主机站点。

回答by valenok

https://github.com/cesanta/v7is designed for embedded systems. Has very small footprint.

https://github.com/cesanta/v7专为嵌入式系统设计。占地面积非常小。

回答by user835611

Have you looked at JerryScript?

你看过JerryScript吗?