Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tiny javascript implementation? [closed]

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?

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).

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)

like image 458
Dhaivat Pandya Avatar asked Mar 21 '11 23:03

Dhaivat Pandya


4 Answers

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

like image 192
Samuli Pahaoja Avatar answered Nov 03 '22 07:11

Samuli Pahaoja


I just discovered this ruby: 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.

like image 28
Coder of Salvation Avatar answered Nov 03 '22 06:11

Coder of Salvation


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

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

like image 4
Björn Avatar answered Nov 03 '22 06:11

Björn


SpiderMonkey is Mozilla's C implementation of JavaScript.

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

like image 2
Robert Harvey Avatar answered Nov 03 '22 05:11

Robert Harvey