Jump to content
  • Advertisement
Sign in to follow this  
choffstein

Which is better suited for me: Python or Lua?

This topic is 4843 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!