[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: RE: Lua documentation, Python, etc.
- From: Nick Trout <Nick.Trout@<a href="/cgi-bin/echo.cgi?warthog.co.uk">...</a>>
- Date: Wed, 5 Jun 2002 11:29:43 +0100
> I don't want a flame fest on the issue, but would appreciate comments
> on pros and cons of the two different languages for those that have
> used both, because once I make this decision, I'm kinda committed =|
John has pointed out a few of the obvious points.
* Is better equipped. Huge library of very useful functionality. I tend to
think this is more useful for off line work. ie. I do all tool scripting in
Python and game scripting in Lua. Huge catalog of example scripts,
tutorials, help and general reference material (e.g.
http://python.foundries.sourceforge.net/index.pl ). But, TBH Lua has all the
libraries you need for in game (I have found so far anyway).
* Has a remote debugger! (http://hapdebugger.sourceforge.net/) Note that
one has been started for Lua but its fallen by the wayside. I do intend to
carry on work on this in the future - hopefully publicly - it depends on my
* Python has a nice simple syntax and behaves "as you would expect". ie. no
gotchas for scripters like undeclared local variables default to global.
Note: this is being resolved with the new "global" keyword. Upvalues were
also a little quirky but now there is lexical scoping in Lua (dont anyone
*dare* start that argument again :OD ). It is potentially easier to script
for for inexperiences scripters/game designers.
* Very stable but monolithic. Python has grown in size and complex since I
started using it a couple of years ago. While it is well supported and
documented there is a lot to get your head round.
X Off the top of my head I thing there are some nasty threading issues with
Python as well. Cant remember exactly but something like the core is not
reentrant so they have to bodge it! Read this a while ago may be wrong
altogether or may have been fixed.
* Faster: http://www.bagley.org/~doug/shootout/
* Smaller footprint (look at size of python.dll)
* Uses less memory: http://dada.perl.it/shootout/craps_cpumem.html
* Has a nice simple API for talking between script and C. Try creating and
manipulating lists and dictionaries in Python and then doing it in Lua. Ok
its not that difficult but because Luas syntax is much simpler you'll find
yourself in the reference manual less. And...
* Doesnt use reference counting for objects which can get complex and error
prone. Although you can use things like the Python Boost library
(http://www.boost.org/libs/python/doc/) if you're into C++.
* Lua started off a configuration language. This has some nice quirks in
that its great for creating and configuring things - which is what you want
to do in a game. Python is probably ahead if you want to write big
complicated apps because Lua has some issues, but then Lua is catching up.
eg. table syntax, anonymous functions.
* Has a nice simple a very powerful syntax. I find you can write the same
thing in Lua with less code than Python and you have more flexibilty because
of Luas metamechanisms. eg. tables are lists and dictionaries combined in
Lua (although you can make them behave like lists and dicts
http://lua-users.org/wiki/PythonDictionaries). Anonymous functions are also
particularly nice for configuring things. In Python you get their poor
cousin, lambda functions.
* Small, simple, stable codebase. Easy to poke around inside and modify if
need be. Probably not as well documented and commented as Python.
On the fence:
* They both have automatic binding generators. SWIG works for both. Lua
also has toLua (which hasnt been developed for a while but works for 4.0 -
not sure about 4.1).
IMHO: I've dabbled with putting both in games and tools. Python is better
for offline tools, Lua is better for embedding and configuration.
I noticed the other day that Crystalspace supports both!
http://crystal.sourceforge.net/ So perhaps you could look there to see which
> inclination is that Lua is the way to go, but because of my lack of
> experience with Lua and the lack of complete documentation,
I do a agree that there is still a lack of introductory material for Lua.
The manual is sufficient but could do with more examples. There is a book on
the way though. I think the wiki should probably contain something like the
Python tutorial: http://python.org/doc/current/tut/tut.html I think you can
always follow this tutorial as a lot of the concepts overlap.