Which is better suited for me: Python or Lua?

Started by
17 comments, last by Kylotan 18 years, 8 months ago
I have narrowed my scripting choices down to python and lua. The idea for my scripting language is to be able to control almost anything dealing with the script within my game -- be it unit properties, gui, or AI. I want to write the engine in C++, and write my game in the scripting language. Which means I will be making a lot of cross function calls -- the language will be accessing a lot of things from the engine, and the engine from the script. So I have dabbled in both -- and lua is easier for me to integrate, but lots of big name companies seem to be using python for the type of work I want to do. The companies using lua are requiring it to do far less. Now I hate to bring up the old "profiling too early", but I would hate to get into development and realize that the language is just too slow for what I need. Python is harder to implement (shared libraries, boost::python, et cetera), but lots of people are choosing it. I hate to turn this into a kind of Java vs. C++ thing, but can someone help me list the pros and cons, and which seems better suited for a game that is entirely scripted? Note: The game won't be graphics intensive: it will be overhead 2d with some static 3d objects and particles. And not many AI units on the screen at once (10 max). Thoughts? Thanks.
Advertisement
Neither Python nor Lua will be too slow for game logic. If it is, you can easily rewrite bits of it in C, without it having an impact on the overall structure of your code.

Python is a little more established than Lua; it's a larger language, with more datatypes and libraries. This means you have a little more functionality out of the box, but it also makes it a litle more difficult to modify for your own needs.

Seriously, flip a coin. I enjoy the elegance of Lua, but that's purely a value judgement. They're both great.
This might help you:
"Lua Wiki: Lua vs. Python"
http://lua-users.org/wiki/LuaVersusPython

btw, Lua as well as Python is used in big commercial games. To name some of them: Battlefield 2 uses python very extensive, Far Cry uses Lua.
I use Lua for my engine, I believe the Aurora engine uses it (or at least I saw some bioware job postings requiring Lua knowledge), I like it because of it's resemblance to C and because its really easy to embed (as long as you dont want to handle C++ types in it, to me using the workarounds for that seemed like too much trouble just for doing object.setpos(x,y,z) instead of setpos(object,x,y,z)).

I did some blender scripting in Python, overall it was a good experience, I am going to use it on a work related project (non gamedev), but I see no reason to switch from Lua to Python yet, nor do I see why not, so, I guess do flip the coin [smile], but you sound like you're leaning towards Lua.
Have you thought about writing the whole game in Python?

If you're worried about speed check out Psyco (for Python). It's cool. It profiles your program while it's running, works out what needs optimising and does it if possible.
Quote:Original post by petewood
Have you thought about writing the whole game in Python?

If you're worried about speed check out Psyco (for Python). It's cool. It profiles your program while it's running, works out what needs optimising and does it if possible.

Seconded. Python is a joy to use, at least in my opinion. This way, you can write it correctly te first time, then rewrite the bits that need to be fast in C/C++. The good thing about this is that sometimes you can get away with writing the entire thing in python, saving yourself a lot of time and effort.
Well, that was the idea. Write the game in the scripting language, and the engine (speed-requiring loading stuff) in C++.

Thanks for everyones input. I was leaning more towards Lua, only because Python is a pain to implement (though, I do like my object oriented style...). I think I will try to learn both, but Lua seems like the way to go for me.

Thanks everyone.
Quote:Original post by visage
...Python is a pain to implement...
Only if you're embedding it in C++. If you're extending it with C++, it's quite straightforward.
Am I the only person who thinks embedding Python is fairly straightforward?
Quote:Original post by Oluseyi
Quote:Original post by visage
...Python is a pain to implement...
Only if you're embedding it in C++. If you're extending it with C++, it's quite straightforward.


For those of us not aware of scripting language semantics, could you describe the difference between embedding and extending and how one is easier than the other in this case?

Thanks

This topic is closed to new replies.

Advertisement