Sign up ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am thinking about giving a go to one of my ancient ideas for a game. The core point of this game would be the possible level of functional customization of the game environment and objects (such as modifying the behavior of a space ship weaponry). For this the game would need to be scriptable. Also I don't aim to commercialize it, it is merely an interesting programming challenge for me.

As I am mostly a .NET guy I will use XNA/C# for the game itself. For the scripting I think about going with Python or Lua. I have previous experience with Python and have nothing against it as a language. Lua on the other hand is almost completely new to me, besides some minor World of Warcraft addons modifications I did here and there, and it looks promising. So here is my question:

What are the pros and cons of Lua vs. Python as a scripting language for XNA/C# platform?

Is one of them considerably easier to use with XNA/C#? Has one of them some specific advantages or disadvantages when used with XNA/C#? Why would you recommend one over the other for XNA/C#?

share|improve this question

closed as primarily opinion-based by Byte56 Sep 10 at 15:13

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise.If this question can be reworded to fit the rules in the help center, please edit the question.

I know you're not asking for alternatives, but just in case you don't know, C# is also a valid scripting language, and since you're using C# it's very low maintenance. –  William 'MindWorX' Mariager Jan 5 '12 at 15:02
Why do you even need a scripting language? Which bennefits are you expecting? –  Peter Ølsted Jan 5 '12 at 15:04
Both of them are popular, professionally used and definitely capable of doing the scripting part. It's just a matter of taste for 99% of the applications. Python has a better standard library and in my opinion is more user-friendly language. –  Cloudanger Jan 5 '12 at 15:50
Along the lines of 'have you considered?' Have you considered Boo? It's designed for scripting, instead of so happening to become a scripting language. Similar to IronPython it has built-in helpers for hosting (and can even interpret for targets like the XBox). –  Jonathan Dickinson Jan 6 '12 at 14:15
Also, don't neglect visual scripting (similar to the Staredit - the Starcraft 1 editor). –  Jonathan Dickinson Jan 6 '12 at 14:17

2 Answers 2

up vote 11 down vote accepted

I can't compare the two, as I've only had experience embedding IronPython in a C# game so far. Here's what I like about it though:

1) It's easy! Download the IronPython DLLs, add reference in project,

 using IronPython.Hosting;

 var engine = Python.CreateEngine();
 var product = engine.Execute<System.Numerics.BigInteger>(@"
 print ' '.join(['hello', 'from', 'ironpython!'])
 a = 123456789
 b = 10
 Console.WriteLine("a**b={0}", product);

2) As you can see from the above example, IronPython actually converts to BCL classes where it can. the result of the script is a System.Numerics.BigInteger rather than a PyObject

3) The dynamic keyword in C# was made for interop situations where you don't have the static type available:

    dynamic example = engine.Execute(@"
class Example(object):
  def __init__(self):
    self.breakfast = ['ham','spam','eggs']
    self.lunch = 'BRAIINNNZ'
Example() # return an example");

    foreach(string item in example.breakfast)
share|improve this answer
+1 for the good example which shows how easy it is to get iron python runnning.... although that was not was OP was asking for ;-) –  tobsen Jan 5 '12 at 19:50

IronPython and C# go well together, IronPython can be added to C# to give it boost in performance. So if your writing games then Python calls within C# are an advantage. Python itself can't make use of XNA but can make use of Directx something C# can't do directly.

share|improve this answer
FWIW, Python can't make use of DirectX "directly" either -- it interacts with it via wrappers based on the fact that D3D is a C/COM API. This is exactly how you can access DirectX from C# as well. –  Josh Petrie Jan 22 '12 at 18:00

Not the answer you're looking for? Browse other questions tagged or ask your own question.