nothings / stb

stb single-file public domain libraries for C/C++
https://twitter.com/nothings
Other
26.38k stars 7.69k forks source link

Scripting language interpreters for other_libs.md #231

Closed dbohdan closed 8 years ago

dbohdan commented 8 years ago

On several occasions I thought it would be nice to have an interactive scripting language interpreter packaged as a drop-in pair of .c/.h files. Here are several interpreters I have looked at (ordered by how practically usable they are IMO):

There is also Duktape, a very capable JavaScript interpreter. However, much like SQLite its .c/.h distribution is an amalgamation of rather a lot of files totaling about 80 kLoC.

If this is something you'd be interested in including in other_libs.md I can create a pull request adding any or all of the above.

nothings commented 8 years ago

Wren doesn't seem to actually be a library, just a standalone program.

The other two are probably ok (but TCL?!?!? -- just let it die!), if you submit a PR for either or both I'll merge it.

nothings commented 8 years ago

Actually, it looks like Picol also isn't embeddable, it's just a standalone program? But LIL is definitely embeddable.

dbohdan commented 8 years ago

it looks like Picol also isn't embeddable, it's just a standalone program

To embed Picol you need to strip off the main() function from picol.c and include both picol.h and picol.c in your application. Now that I think of it, Picol would definitely benefit from merging the header and the implementation into a single file with stb-style preprocessor conditionals. I'll submit it once I've done that.

Wren is much the same, though unlike Picol it introduces global variables. I am not up to working on it myself but I can ping the author about refactoring it.

TCL?!?!? -- just let it die!

As someone who has used Tcl rather a lot recently, I respectfully disagree. :-)

P.S.: I have also found, but haven't tried, tiny-js. Tell me if I should include it in the PR.

nothings commented 8 years ago

tiny-js is too many files (at least if you want the std lib, which everyone would)

dbohdan commented 8 years ago

which everyone would

Fair enough.

dbohdan commented 8 years ago

(PR #234)