Is it possible to use Java as a scripting language for java? Or maybe somehow compile java scripts into java binarries at runtime? I did tried to search but couldn't find anything comprehensive except for some hacks...
I have experience with other languages and for example for C# I used lua which was quite convenient but now I need to acheive the utmost performance as calls for scripts will be about 1.000.000 per frame.
So I figured that adapting java itself as a scripting language for java program should provide me the best performance and compatibility.
Any suggestions?
BeanShell is a commonly used scripting solution for Java. It's a scripting language which is very Java-like. Other solutions exist which use the Java infrastructure and JVM, but with a different language. e.g. Scala, Groovy and Jython (a Java-compatible Python).
A scripting language is a programming language that is interpreted. It is translated into machine code when the code is run, rather than beforehand. Scripting languages are often used for short scripts over full computer programs. JavaScript, Python, and Ruby are all examples of scripting languages.
BeanShell is a commonly used scripting solution for Java. It's a scripting language which is very Java-like.
Other solutions exist which use the Java infrastructure and JVM, but with a different language. e.g. Scala, Groovy and Jython (a Java-compatible Python). The important thing to realise with all of these is that they'll interoperate with Java libraries created using standard Java, so you could trivially use (say) Scala to drive your Java-language created solution.
The above all provide a REPL (read-eval-print-loop) so you can import, instantiate and interact with your objects in a dynamic command-line environment. That's very useful for testing and prototyping interactions, as well as testing your scripts.
You can use BeanShell for this, but Groovy, XTend, and Scala might make better choices.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With