Fastest scripting language for Java?
I'm making a falling sand game in Java. I want users to be able to write their own engine for the game and I thought a scripting language might work for that. I've tried out a small script with jython and it's many times slower开发者_如何学Python than that java version.
I need a scripting language that has fast loops and/or fast array access since that's what the game will be doing a lot of. Or if you have any suggestions on another way to let users write their own engine for the game.
I'm also not entirely sure this can work (well). If you don't think it can please let me know why and maybe some possible alternatives.
JavaCC
You could write you're own simple game language with JavaCC. This does give's you all the flexibily you possibly want and native Java speed (well that actualy depends on you're implementation). But you need to keep you're syntax simple or else it will take some efford...
Java
Java? Yes Java! Why not let users extend you're game by Java code? In Java 6 there is a Java compiler API:
- javax.tools API.
Beanshell vs Rhino
Some performace comparison between BeanShell and the Rhino (Javascript) interpreters (Rhino is the winner):
- thoughtworker.in
- Pankaj Kumar's Weblog
You might look at BeanShell for this. In my use it's been pretty much as fast as native Java (as that is what it becomes) and is pretty accessible as it is Java, albeit locked around Java 1.4.
RelProxy is Java compiler on the fly and an automatic hot class reloader, pure Java code can be executed like a scripting language.
Because Java is faaast Java is then maybe the fastest scripting language, optionally you can use .class files like a sort of compiled cache to avoid compiling on load.
精彩评论