Hi, As I was recently looking into a scripting language feasable for Android. Scripting in this context means having your android-app execute parsed code, like if you want user-supplied AI scripts in your game.
There exists a scripting-layer implemented at http://code.google.com/p/android-scripting/, but the popular language Lua seems to not be supported. So I went ahead and put Lua's Java-port into my android-project and gave it a try. Performance is of course slow compared to a computer, but I think it's still very exciting to have the functionality into my games. A quick a rough performance estimation: lua, c/c++, desktop: 18ms luaj, java, dekstop: 180ms kahlua,java,desktop: 219ms luaj,java(dalvik), HTC desire,2000ms *Note* that time elapsed includes parsing & compilation-time. My LuaJ that goes into my android-project is 240k, but this can probably be stripped of a lot of things (like the lua console). The test-script i used was: -- mytest.lua -- --------- function isprime(n) if n % 2 == 0 then return false end for i = 3, math.sqrt(n), 2 do if n % i == 0 then return false end end return true end x = 999999919 for i = x, x + 100, 2 do if isprime(i) then print(string.format("%17s is prime", i)) end end -- ------------- Also, I have an idea on performance improvement, but lack knowledge of Groovy & Dalvik, and it's a little "out-there". If I have understood Groovy (http://en.wikipedia.org/wiki/Groovy_ %28programming_language%29) correctly, it takes it's code and makes .class files which can be run from Java? If we could run convert such class-files to dex dynamically, and run them, would we not get much better perfomance? specially with JIT on android 2.2 perhaps? Could this be even possible? Anyway, have fun with Lua, Kris -- unsubscribe: [email protected] website: http://groups.google.com/group/android-porting
