分享

c#

 quasiceo 2014-01-21

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?

asked Apr 10 '12 at 12:22
thund
9216


 
This is not really a programming question. –  lhf Apr 10 '12 at 12:52

 
Apple restricts apps from running external scripts. This is mostly so you don't sell one app, then when it runs it becomes another app - in my opinion at least. Write your app legit, don't try and game the system. –  sylvanaar Apr 10 '12 at 16:21

 
With all due respect, I'm really not sure what "write your app legit" means, and nor does anybody else I've asked. But putting in months of painstaking work to have my app rejected in 3 mins for ambiguously worded and ill-defined reasons isn't terribly appealing. If the system's not clearly defined, then "gaming" it isn't clearly defined either. –  thund Apr 11 '12 at 12:56
add comment

1 Answer

up vote 1 down vote accepted

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++.

answered Apr 13 '12 at 16:58
Mud
9,5751737


 
Thanks very much. But are you allowed to download new lua code to modify your app's content? eg, suppose you wrote an interactive newspaper app, where the interactive articles were defined by lua. Could you update your lua? Or would your app be limited to showing a single day's news? That would be a bit pathetic. –  thund Apr 13 '12 at 18:54

 
If it adds new content? Then yes. If it provides radically new behaviors? Then no. Both scenarios are outside the scope of what you said you needed it for (end user scripting), right? –  Mud Apr 13 '12 at 19:13

 
No, it's in the scope of what I said - in the newspaper example, say end users could upload articles. To upload interactive articles they'd use end user scripting. So I think you're saying that's permissible if the new lua scripts don't behave 'radically differently' from the old ones. That's horribly vague. Would it mean particularly creative end users wouldn't be allowed to upload content, whereas duller ones could? Or that the whole app might be shut down if its content became too elaborate? –  thund Apr 13 '12 at 19:31

 
I was referring to the scope from your original question ("power user scripting"), not your newspaper example. "end user could upload articles" would be completely forbidden, AFAIK. Apple's policy is worded somewhat broadly, more broadly than they actually enforce, so it's possible you could run afoul of the policies if you were pushing it, but allowing end user scripting is allowed by several published apps. Codea is pretty much all end user scripting. –  Mud Apr 13 '12 at 19:35

 
Right. I think that uncertainty in what's allowed pushes me reluctantly toward rolling my own language. Also, lua on c# doesn't seem very active - eg I can't find anything at all about running it on silverlight as opposed to WPF. –  thund Apr 14 '12 at 0:06

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多