Sign in to follow this  
mychii

About Embedding Lua in Android

Recommended Posts

Hi guys,

 

I've searched in the internet about embedding Lua, and they are all kind of old posts (like 2010 and 2011).

One says that it's restricted in iOS, and then a few months later it's allowed, etc. This makes me worry a bit.

 

So I just want to confirm, are we allowed to embed Lua in our application for Android (and iOS too, now)? Any experience?

 

On the other side, for you who have experience, do you think it's wise to do so in terms of performance? I mean, we're embedding a scripting language in a mobile device here, so I assume it's a little big on size and processing.

 

However, my point is I just need to embed a scripting language to fasten my game play development on top of the low level modules.

Just want to make things quick and done from scratch.

 

Thanks!

Share this post


Link to post
Share on other sites

I'm not an iPhone/Android dev, but --

Closed platforms often don't allow dynamic code generation -- e.g. JIT'ing.

So vanilla Lua should be fine, and LuaJIT with the JIT component disabled should be fine. LuaJIT with JIT enabled *might* be allowed...

 

I've used Lua on a bunch of PS3/Xb360 games, which have quite a weak PowerPC CPU in them, and performance with LuaJIT (with the JIT feature disabled to keep the gatekeepers happy) was good enough for most of the game to be written in Lua.

Share this post


Link to post
Share on other sites

Yes you can embed LUA in Android apps as well as download LUA code for that app later on.  In iOS you're allowed to ship an app with embedded LUA, but you're not allowed to download scripts later.  Basically Apple wants to test your code when you submit the app to make sure it's compliant.  If you can download new code later through IAPs then that breaks the whole idea of them validating the app.

 

As far as performance, it depends on your usage.  The best practice as far as performance is to use native code, which will in almost all cases be faster than interpreted or even JIT'ed code.

Edited by 0r0d

Share this post


Link to post
Share on other sites

Okay then, I guess I just keep them in a single pack for the code (iOS..., sigh).

 

I'm fine without JIT. The point is I want to fasten my development by not handling too much C++ code on gameplay parts.

 

I am fine to sacrifice performance for the sake of cutting my work hours, as long as it's not too much. I'll use my time to check this 'not too much' then (with confidence from Hodgman :lol:).

Then if it's a problem, I'll have to recheck my scope if it's small enough to be native only code.

 

 

Thanks guys!

Share this post


Link to post
Share on other sites

Okay then, I guess I just keep them in a single pack for the code (iOS..., sigh).

 

I'm fine without JIT. The point is I want to fasten my development by not handling too much C++ code on gameplay parts.

 

I am fine to sacrifice performance for the sake of cutting my work hours, as long as it's not too much. I'll use my time to check this 'not too much' then (with confidence from Hodgman :lol:).

Then if it's a problem, I'll have to recheck my scope if it's small enough to be native only code.

 

 

Thanks guys!

 

If you're using Lua with the intent that it will reduce your development time, you might be very disappointed.  My recommendation if you want faster development time is actually to use whatever native language you use for your engine for your game code.  So in this case if you're using C++, then write your game code in C++.  Using Lua will have upfront costs (integrating Lua with the engine) as well as backend costs in terms of debugging and profiling.  Even if we assume that performance will in no way be an issue, I would not use Lua just because I thought it might be faster to write. 

Share this post


Link to post
Share on other sites

I will definitely consider that. I'm not really eager to deal with pointers when I want to debug the gameplay code cause I need to re-iterate features as fast as I can.

If my code happens to be that small for me to handle, I'd definitely get to that.

Edited by Alectora

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this