5

Possible duplicate: Tiny javascript implementation?

I have searched around for a C implementation of Javascript, but I couldn't find one. I need this for an ultra-portable application that will run on platforms without a C++ compiler.

Here are my requirements:

  • ANSI C (C89 compatible if possible)
  • Minimal dependencies
  • Embeddable (not stand-alone)
  • Open Source (GPL v2 compatible)

I don't care about speed, but correctness is an issue. I would prefer for it to support ECMAScript-262 v5, but v3 is good enough for now.

Does something like this exist? If not, are there any implementations that would be relatively simple to port?

DMDScript is the simplest that I've found, so I may end up porting that. Apparently there is no reference implementation, so this may be the best way to go.

Note:

I also found tiny-js, which is meant to be small and simple, but it doesn't seem to be standards compliant. It is actively developed it seems...

Community
  • 1
  • 1
beatgammit
  • 19,817
  • 19
  • 86
  • 129

3 Answers3

3

Spidermonkey 1.8.0 RC1 and the previous releases are in C. You can use that.

They introduced C++ in their latest release as of 11 Feb 2013 in 1.8.5 release

rahulg
  • 2,183
  • 3
  • 33
  • 47
2

The SpiderMonkey wiki claims it is C/C++, however, from looking at the source package, it seems to be pure C actually.

The official download link is http://ftp.mozilla.org/pub/mozilla.org/js/js-1.8.0-rc1.tar.gz

If that doesn't turn out to be pure C, try the older versions. Their FTP (http://ftp.mozilla.org/pub/mozilla.org/js/) currently hosts spidermonkey 1.8.5 down to 1.4, and Rhino 1.7 down to 1.4.

The documentation for Spidermonkey API seems good as well.

John Dvorak
  • 26,799
  • 13
  • 69
  • 83
1

have you tried http://www.duktape.org/? I've been looking around for the same for a while, and this one just got me a wink. I'll test it and see how it goes, but to start, looks promising