LWN.net Logo

Python slithers into Wesnoth

Python slithers into Wesnoth

Posted Jan 18, 2009 10:56 UTC (Sun) by massimiliano (subscriber, #3048)
Parent article: Python slithers into Wesnoth

Well, I know this could cause flaming responses, and I know I'm biased because I work on the project, but...

...my personal choice as a VM to write game logic would be Mono.

It is cross platform, it's JIT is typically much more efficient than interpreters, and the languages you can use to write your game can be statically or dynamically typed according to what you need.
And in fact Mono is gaining lots of users in this area, also commercial ones, to the point of getting a wii and iphone port.

Now, I'm not saying that Wesnoth should use Mono: if they already have Python experience, and Python is already used in the project, then it's probably a better choice (switching to a different VM would cost too much).
What I'm saying is that from a purely technical angle Mono is likely the best tool around to program game logic.
And about using plain C++... surely there is a reason why every major game written since 1995 (think Quake) has its logic layer implemented in a higher level language, be it Lua, Scheme, stacless Python or a custom written interpreter of some kind.

Have fun!
Massi


(Log in to post comments)

Python slithers into Wesnoth

Posted Jan 18, 2009 20:32 UTC (Sun) by zlynx (subscriber, #2285) [Link]

I believe Quake2 used native code DLLs and .so files.

But in general you are right. Using an interpreter gives the game better security, portability and error recovery.

Python slithers into Wesnoth

Posted Jan 18, 2009 21:01 UTC (Sun) by massimiliano (subscriber, #3048) [Link]

Oh, you are right, I was forgetting Quake 2!

But for Quake 3 they got back to the VM approach... with a twist: the language was C (plain, old C), but they had a compiler from C to bytecode, and an interpreter able to execute that bytecode.
So the game was able to execute game logic either in native form (C compiled to a shared object), or in bytecode form, where the bytecode was produced from the same source files...

...which tells a lot about the fact that they really, really wanted a VM to solve the safety and platform compatibility issues for game mods. They decided to use a VM even if they preferred the C language for game logic!

Have fun,
Massi

Python slithers into Wesnoth

Posted Jan 18, 2009 20:58 UTC (Sun) by zlynx (subscriber, #2285) [Link]

Another comment I just thought of about Mono and Python.

I've played around with IronPython on Microsoft's .NET. It is impressive, in my opinion.

It's much faster than cpython and threading really works. Or so it seemed to me.

I think that even if Wesnoth wants to stay with Python, it should be possible to use Python on top of Mono via IronPython.

Python slithers into Wesnoth

Posted Jan 18, 2009 21:13 UTC (Sun) by massimiliano (subscriber, #3048) [Link]

Yes, IronPython is impressive!

I think that even if Wesnoth wants to stay with Python, it should be possible to use Python on top of Mono via IronPython.

Yes, it would be possible to do so.
There are two drawbacks (funny, the LWN code is not accetting "ul" tags...):
(1) Mono is often not as performant as the MS CLR (yet, and we're getting there...). Anyway, it should be more than enough for Wesnoth.
(2) IronPython is not compatible with the C extensions of cPython, which means that besides embedding Mono, they'd have to redo all the Python bindings they have already in place. Now, it's true that binding C code to Mono is much easier than binding it to Python, but this is added work for them that they'd not like at all.

That said, Mono would of course be usable :-)

Have fun,
Massi

Copyright © 2012, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds