Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have some legacy code, which uses Lisp as it's scripting language. To broaden, ease and accelerate scripting I'd like to replace Lisp by Javascript. In order to be able to built on all present scripting files, I first need to translate all lsp to js.

Now I found parenscript but am not yet sure what it is good for (seems to modify Javascript to be able to run lisp, which is not what I want). Also there are some converters on the web, which seem to work quite well. Has anyone already done this and can share some experiences, best pracises and tools?

share|improve this question

closed as not constructive by Robert Harvey, Glenn Nelson, Dynamic, gnat, Jim G. Dec 25 '12 at 5:21

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

If you're looking for a button that just converts it all, you're out of luck. Language translation isn't something that can be automated. – SomeKittens Dec 24 '12 at 22:48
@SomeKittens That's entirely untrue - compilers do exactly that all the time. Now, language translation while maintaining human readability, there's something that can't necessarily be automated. – Tacroy Dec 24 '12 at 22:55
@Tacroy I agree but in this case it may not be so hard. Lisp and JavaScript are structurally extremely similar. – Jimmy Hoffa Dec 24 '12 at 23:04
@JimmyHoffa I guess so, but seeing as how it's legacy Lisp I imagine there will be a great deal of hairiness in the JS version - legacy codebases tend to explore all of the weird and wonderful edge cases of a language, and those end up translating very poorly (e.g, Lisp macros). I definitely would prefer to maintain the Lisp version myself. – Tacroy Dec 24 '12 at 23:11
@Tacroy I don't have a problem if I have to fix 5% of the codebase as long as 95% of scripts are converted correctly. E.g. I know that I have to handle usage of dash in variable names – abergmeier Dec 24 '12 at 23:46

Common Lisp is huge, and writing a compatible compiler / runtime is out of question for a novice. Parenscript is probably your best bet for direct running of your Lisp code on a JS target.

For simpler versions, like Scheme, there's a ready-made interpreter.

If you understand basic Lisp, take also at look a Clojure, a Lisp variant. Chances are you might port significant chunks of Lisp code to Clojure without a major rewrite. Then apply their JS compiler and see if it works for you.

JavaScript has quite Lispy internals (despite the bolted-on OOP features), so efficient translation of moderate amounts of simple Lisp code (e.g. without macros) to JS is not impossible to do by hand.

The bottom line is: there's no silver bullet. You'd better learn some Lisp to handle your task. (Try it; it's well worth it, and also forever changes the way you see programming.)

share|improve this answer
Ahem, I do know Lisp, or I would not even try. – abergmeier Dec 25 '12 at 8:28

Not the answer you're looking for? Browse other questions tagged or ask your own question.