views:

376

answers:

2

Hello, I would like to write a web based MMO game that will allow users to write AI and run it as part of the game. I plan to use Html5 for graphics and want this to be web based so it can be accessed from smartphones. I need to find a programming language that will support sandboxing, concurrency, hot code swapping, and a large library to make things easier.

At this time my research is turning up Erlang, Stackless Python, and Lua. Any help is appreciated.

+12  A: 

Erlang does not support sandboxing, so you probably don't want to use that, at least for your scripting language. Erlang isn't ideal for scripting anyway, so that's probably ok.

Erlang would make a good backend language for a project like this, however, and I'd highly recommend it from personal experience.

I don't think Stackless has sandboxing support either, so that's probably also off the list.

Lua, on the other hand, explicitly supports sandboxing, and has coroutines, too: http://lua-users.org/wiki/SandBoxes, http://lua-users.org/wiki/CoroutinesTutorial, so I would recommend that for your scripting language.

Lua is also extremely easy to embed as seen in this tiny tutorial: http://heavycoder.com/tutorials/lua_embed.php (and you can even get away without all the library loading stuff since you'll want to be sandboxing it anyway).

pib
+1 for the Lua links
Kornel Kisielewicz
Erlang would work great. Just make sure users only submit valid dsl language to the AI system. And make rules that the AI must follow. AI can not send to many messages in a second, and must answer on alive questions. Why would that not work?
Flinkman
Well, for starters, if they're using a DSL, it's not Erlang as an embedded language, it's a DSL. The question stated that he was looking to *find* a language to embed, not *write* a language.
pib
+4  A: 

I'd also go with Lua due to it's absurd customizability and versality (if you don't like it's syntax you can change it to a functional or a python-like one). As said in the previous answer, you've got sandboxing and strong concurrency. I personally would never even think of embedding anything else than Lua ;>.

However, Lua lacks a expanded standard library, and this is where Python wins big time :/.

Kornel Kisielewicz
For an embedded language, where the expanded standard library isn't needed, it's perfect, though. Especially in a case like this where it's untrusted code running, you want to limit the potential areas of breakage as much as possible. For a general-purpose programming language, Python is always what I reach for, for sure.
pib
JavaScript, Forth, and Lisp are among the other languages I'd consider embedding, but I'm not sure if there are any strong competitors to Lua for a task like this...
pib