I’m building a scientific/education application, and I need to provide power-user scripting capabilities. My choices are:
- Embedding an existing language such as Python or Lua
- Or creating my own language with coco/R, for example
(Initially I’m building in C#, but will probably later port to C++ for iPad & Android reach.)
Each approach has its advantages, but a big factor is that I don’t want to be shut out of app stores. Apple apparently prohibits apps that run interpreted code. I don’t really understand how this is defined – surely any app runs by interpreting its own data structures? I assume it’s some sort of “we know pornography when we see it” definition, and you just mustn’t make your system look too powerful. If this is the case, I’m thinking that if I build my own language and transmit only the active syntax tree and not the scripting source, then I’m less likely to trigger their alarm bells – it’ll look like any old data structure. Anyone know if this is right?
Apple relaxed the language in their license agrement to allow Lua a few years ago. It’s used in a huge number of iOS games (including Angry Birds, all EA games, etc.). In fact, there are many games on the App Store written in Lua, using Lua-based frameworks like Corona or MOAI (such as Crimson: Steam Pirates, a Bungie Aerospace funded game which was #1 on the App Store for a few weeks). There are also Apps like Codea, a Lua scripting environment that end users can use to build games/toys right on the device. Lua is very popular on the iOS platform.
Creating your own language would be absurd, IMO. Lua is too good, and a perfect fit for iOS: light weight, fast, hackable, user friendly, easily embedded and extended, etc. However, you may have trouble integrating it into a C# app. I don’t really know how MonoTouch works, but in the desktop world, C# is managed code, compiled to byte code, but Lua’s API is native code. Bridging that gap can be done, but it’s more work.
In short, you can use Lua and you don’t have to hide it. What you’re not allowed to do is create a “metaplatform”, where users can basically download entirely new applications (which have not been reviewed by Apple) through your app.
EDIT: Regarding “I’m building in C#, but will probably later port to C++ for iPad & Android reach”, you may want to check out MOAI. It’s an open source, cross platform (PC, Mac, iPad, Android, Chrome) framework written in C++ for writing games in Lua. Might save you time to start there rather than porting later. You can do pretty much everything directly in Lua, and if you run into something where you need bare-metal performance or access to functionality not already exposed via a Lua API, you can write it in C or C++.