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

I want to embed dsl or an existing complete language in my application. It should be a simple, complete, complete Turing language, yet simple and lightweight enough that the code can be interpreted without unnecessary overhead.

Also, other "processes" cannot influence any other process.

I have considered using Clojure and invoking the Clojure interpreter / runtime compiler in Clojure code, but Clojure's runtime is taking a lot longer than I need. Also, I don't like using the Clojure language for this project too much. I was thinking about more procedural and C-like ones.

I reviewed the Ola Bini Ioke language. http://ioke.org/index.html

Also, I decided to write a DSL in Scala? Or using an existing DSL.

Updated: Rhino looks like a good example of an embedded language.

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

+2


source to share


6 answers


Groovy's dynamic nature is perfect for writing DSLs. In fact, there are a large number of Groovy DSLs implemented by the Grails webmap, as well as many tutorials and books that teach you how to write DSLs with Groovy.

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



I would tend to avoid IOKE due to its immaturity and from a DSL perspective, I think a dynamically typed language like Groovy or JavaScript is a better choice than Scala.

+9


source


How about JavaScript?

http://java.sun.com/javase/6/docs/technotes/guides/scripting/programmer_guide/index.html



It is built in Java 6.

+14


source


I suggest Java. These are: well known, fast, easy to integrate with Java, stable, statically typed, easy to port, etc. Etc.

+2


source


Check scripting.dev.java.net for a list of Script Engines for embedding other languages ​​into your Java applications. Note that some of the referenced languages ​​now come with their own JSR 223 integration, so there is no need for a third party library.

+2


source


If you want to get a DSL, then you really don't want to implement an existing language, you want to create a "Domain Specific Language". To me this means a lot more than just changing some keywords, rather than using parentheses.

For example, right now I'm working on TV scheduling right now. When we create fake guide data for a test, we always add a comment that looks like this (cut directly from the test I'm working on):

 * TIME:8.....30....9.....30....10....30....11....30....12....30....
 * 4FOX:____________[Spotlight.............][Jeopardy..]____________
 * 6CBS:[Heroes....][Heroes....][Heroes....]________________________
 * 8HMK:xx[A.River.Runs.Through.It....][Blades.Of.Glory...]_________

      

If I need to create more reference data, I will directly interpret these comments as DSLs (making them a long string or string array instead of comments).

This will be a suitable DSL.

If you've just introduced a flexible language, Groovy or JRuby are created for it, just like BeanShell.

There is actually a whole API based on pluggable plugins with pluggable scripts so you can ditch whatever JVM language you want and change the code a bit.

+1


source


The little BrainF * ck interpreter should be ok as per your spec :)

If this is not exactly what you meant, then think about what exactly you want to decide. What's your research? Can he add new code later without reinstalling the new version of your application?

-1


source







All Articles