Search code examples
javaclojureembedded-languageioke

What is a good embeddable language for an existing Java application?


I want to embed a dsl or existing full language within my application. It should be a simple, full Turing complete language but simple and light enough that the code can be interpreted without too much overhead.

Also the other "processes" can't effect any other process.

I was considering using Clojure and invoking the Clojure interpreter/runtime compiler on Clojure code but the Clojure runtime takes a lot longer than I would need. Also, I am not overly excited of using the Clojure language for this project. I was thinking more procedural and C-like.

I considered Ola Bini's Ioke language. http://ioke.org/index.html

Also, I considered writing a DSL in Scala ? Or using an existing DSL.

Updated: It looks like Rhino is a good example embedded language.

http://www.mozilla.org/rhino/tutorial.html


Solution

  • Groovy's dynamic nature is ideally suited to writing DSLs. Indeed there are a large number of Groovy DSLs implemented by the Grails web framework, and plenty of tutorials and books that teach how to write DSLs with Groovy.

    Also, Groovy's syntax is almost a superset of Java's, so it should be relatively easy to pick up (compared to Clojure). Calling between Java and Groovy code is seamless, so you can easily use all your favourite JDK classes within Groovy code.

    I'd be inclined to avoid IOKE on account of it's immaturity and for the purpose of a DSL, I think a dynamically typed language like Groovy or JavaScript is a better choice than Scala.