Hacker News new | ask | show | jobs
by amadiver 5643 days ago
Any tools that work in the opposite direction? ( e.g., JS -> C )
3 comments

Red Daly has a JavaScript to Parenscript (Common Lisp) translator: https://github.com/gonzojive/js-to-parenscript

The generated code from that won't run without a JS runtime implementation in CL backing the JS-specific Parenscript forms, which currently doesn't exist to my knowledge (it's not hard to write, just not very useful). This is useful by itself for writing JS analysis and transformation tools and moving JS code to Lisp.

There's CL-JavaScript: http://marijnhaverbeke.nl/cl-javascript/

This is a translator/compiler/"simulator" (http://www.cs.aau.dk/~normark/oo-scheme.html) that provides good integration between the two languages.

Rhino does JS -> Java bytecode internally but I don't think you can grab those classes and execute them outside Rhino.

A full compiler would of course always have the problem of dynamically generated JS, i.e eval().

You can use a JavaScript engine such as V8 to run JavaScript code anywhere, but I don't know of any native compilers.