🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Python or Lua

Started by
30 comments, last by QzarBaron 20 years, 4 months ago
LUA was originally designed as a configuration file language, and it really excels at that. LUA does not have many modules like Python does, but it provides a very simple and powerful table mechanism that is very easy to interface to and from c/c++ code. Therefore, anything you can write in c/c++ can be imported as a module into LUA.

I use LUA because the interpreter is small and easy to embed. There are a number of libraries out there to aid in embedding LUA, but I find they are not really needed.

The LUA interpreter’s code is very easy to hack, too, which is nice because I needed to adapt LUA’s script loading mechanism to my engine’s custom file i/o mechanism. Took me twenty minutes.

I have used both Python and LUA. My personal preference is that LUA is better for embedded scripting and Python is better for stand-alone scripting. I really like LUA’s syntax, too.


[edited by - SpiffGQ on January 15, 2004 5:03:12 PM]
SpiffGQ
Advertisement
quote: Original post by Anonymous Poster
Is there a list of commercial games that use ''standard'' scripting languages (say Lua or Python) and what language they used?


Blade: Edge of Darkness (aka Severence) was made with python for everything game related and its engine was done in C. Neverwinter Nights used Lua for its scripted levels. The Bigworld engine uses Python for most of its game and server related stuff.
Lua benefits:

1. Lightweight.
2. Easy to embed in a C++ project.
3. Significantly faster "out of the box," without relying on machine code generating extensions (like Psyco for Python).

Python benefits:

1. Richer language.
2. More predictable in terms of performance, because of reference counting over true garbage collection.
3. Much larger standard libraries.
4. Psyco compiler, if you need it.
quote: Original post by Anonymous Poster
The big advantage of python is that it is used a lot in the world : you find books, tutorials, libs, debuggers, ...
So perhaps Python has a better chance to stay than Lua...
But who knows ???
Actually, Python has been around for 13 years. It was developed as a shell language for a custom operating system based on ideas taken from an earlier language called "ABC" and ideas from Modula-2+. PyFAQ: Why Was Python Created In The First Place?

So, yeah, it''s going to last. It already has. (Not a comment on Lua''s long-term prospects!)
Plus with Python networking is a whole lot easier thanks to its huge number of libraries in that area, and that''s an asset not to be underestimated. Especially if you use Twisted Python =D
http://www.twistedmatrix.com
quote:
Did I mention "Don''t use tabs"?


What''s wrong with tabs? I have been using them for years in my code...no problems.

cb
Rock the cradle of love! You stupid WANKER!
I prefer tabs over spaces because some people have different preferences for the number of spaces in indenting - with tabs they can set them to be equivalent to 2, 4, 8 spaces or whatever they want, and it won''t mess up your own preference.
quote: Original post by Coleco
What's wrong with tabs? I have been using them for years in my code...no problems.


Python interprets one tab character as being worth 4 spaces (IIRC), which may not match what your IDE displays. Which means that, if you mix tabs and spaces (which *look* the same unless you have an editor that does make whitespace visible), you can have code that appears to line up, but that python sees as unconsistently indented.

As for python's suitability to embedded platforms (in re: the PS2 commend), I believe there is at least one cell-phone that is (entirely?) scriptable in python.

“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.” — Brian W. Kernighan (C programming language co-inventor)

[edited by - Fruny on February 10, 2004 4:59:38 AM]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
I prefer lua because of the same reasons many people pointed out.

Someone mentioned python itself is very tiny without lib, that's not true. There is dll that has been installed to system directory and that's a good 800k.

The only concern I have about python vs lua is, with python you can always replace a python module with c++ without having to change any other part of the code or script. Does lua has the similar ability?

[edited by - paladinzzz on February 12, 2004 5:39:01 PM]
800k isn''t very tiny? games are on the order of 3 gigabytes now.

This topic is closed to new replies.

Advertisement