21

I have quite a lot of code written in Erlang, which I want to include in applications written in Objective-C, eg on the iPad. Ideally I would want to have an object that encapsulates the Erlang run-time; this could then be accessed like the standard Erlang shell, something along the lines of:

ErlangRT *runtime = [[ErlangRT alloc] init];
ErlangValue *retval = [runtime execute:@"io:format(\"hello world~n\")"];

I don't care too much about performance etc; I can see how it could work, but as I don't know too much about the way the Erlang VM is implemented I have no idea how easy or difficult it is to do, or if anybody has already done something similar. I know there are other ways of interfacing between Objective-C and Erlang, but they seem to assume an independently installed Erlang system on the target machine. I would prefer it to be like a library that you simply link in with the application.

So my question is: is this comparatively easy to do, and/or has somebody already worked on this?

RBerteig
  • 41,948
  • 7
  • 88
  • 128
Oliver Mason
  • 2,240
  • 2
  • 15
  • 23
  • 2
    The trap here is the "virtual machine". While the rule on tooling has been relax, the requirement to statically link code has not. Any sort of JITing/compiling/VM - ERL, Flash, .NET/Mono or otherwise is frowned on. While I'm sure it is "doable" given enough time/money to create an embedded version of ERL and runtime that targets iOS from Erlang source, you wouldn't be allowed to put in AppStore anything that dynamically generated code. With that as disincentive I doubt anyone has undertaken the task of porting it. – stephbu Oct 21 '10 at 19:51
  • Hmm I'll eat my words a little - seems that http://sourceforge.net/projects/erlandstaticlib/ is on that path... Not sure what state it is in. Rules still stand that to appear in the appstore it can only be static linked code. – stephbu Oct 21 '10 at 19:57
  • 2
    My understanding is that dynamically generating or downloading code is off limits, while interpreting existing (ie AppStore-vetted) embedded code is OK. – Oliver Mason Oct 21 '10 at 20:27
  • 1
    Note that Apple is allowing apps that contain Lua scripts in the store. The intent of their rule seems to be to prevent anyone from downloading executable code (other than Javascript), so as long as your Erlang VM is only executing stuff that is bundled in the app, I expect you would be OK. (But nobody knows how Apple's reviewers will rule on anything.) – Kristopher Johnson Nov 02 '10 at 22:34

2 Answers2

12

We've got Erlang working on the iPhone (and approved for the App Store) as part of our package of Apache CouchDB for iOS. The Github project is here: https://github.com/couchbaselabs/iOS-Couchbase

The Erlang we use is here: https://github.com/couchbaselabs/iErl14

More info on Mobile Couchbase: http://www.couchbase.com/products-and-services/mobile-couchbase

Enjoy!

Chris

J Chris A
  • 2,158
  • 15
  • 14
3

It looks like http://sourceforge.net/projects/erlandstaticlib/ is the best option right now.

benzado
  • 82,288
  • 22
  • 110
  • 138