0

I have started a large project, and require some sort of scripting language that can be stored as plain text, and ran within the JVM very fast during execution. I require a language that is simple, customizable, has various Java API's/Libraries to interpret, and can be stored within a large XML file either in an attribute or the inside of a XML node.

This is required so my program can dynamically write code that it will use later, in a neural network.

DripDrop
  • 994
  • 1
  • 9
  • 18
  • you can load classes dynamically in Java. Why not write java code, run the compiler, then load your class dynamically? – Jeremy Mar 23 '15 at 01:57
  • This is not what I want to accomplish. What I am trying to do is dynamically run a script from a string defined in a separate XML file, with performance being critical. – DripDrop Mar 23 '15 at 02:01
  • So you really think writing your own language is going to be more efficient than the pros? – Jeremy Mar 23 '15 at 02:04
  • I do not think you understand what it is that I am trying to do. I am not writing the code, the program is, dynamically. What I want to do is find what language it will write it in, and then use that, storing it in an xml doc. – DripDrop Mar 23 '15 at 02:06
  • sooo then why not use java? – Jeremy Mar 23 '15 at 02:07
  • Because java must be compiled to a java class binary, and then executed as that. I want a library that will use some sort of scripting language, while remaining extendible. – DripDrop Mar 23 '15 at 02:08
  • You need to explain what you want *A LOT* better. – Hot Licks Mar 23 '15 at 02:09
  • maybe you are looking for something like LUA. see http://stackoverflow.com/questions/17333578/executing-lua-scripts-from-java – Jeremy Mar 23 '15 at 02:10
  • @HotLicks He wants an interpreted language he does not need to compile. What's not clear in that? – Tarik Mar 23 '15 at 02:14
  • 1
    @Tarik - What, for instance, does it mean to run a language "within Java"? – Hot Licks Mar 23 '15 at 02:16

1 Answers1

1

LUA is the perfect fit for an interpreted language that you want embed in Java:

http://lua-users.org/wiki/LuaImplementations

A more mainstream possibility is to call Jython from Java:

http://www.jython.org/jythonbook/en/1.0/JythonAndJavaIntegration.html

Another possibility is to use Java only and invoke the compiler at run time:

http://stackoverflow.com/questions/2946338/how-do-i-programmatically-compile-and-instantiate-a-java-class

Using an interpreted language will start the exection of the script faster but the execution itself will be slower. Using the Java compiler will cost more upfront but the execution will be faster and you will be sticking to a single language.

Tarik
  • 10,810
  • 2
  • 26
  • 40
  • Thank you. I will look into this deeply. I appreciate your understanding of my question, as it was a little too broad. This will be perfect. – DripDrop Mar 23 '15 at 02:15