Scripting: Python VS. Lua

A place to discuss the implementation and style of computer programs.

Moderators: phlip, Moderators General, Prelates

Scripting: Python VS. Lua

Postby Taehl » Mon Dec 10, 2007 11:17 pm UTC

Python and Lua seem to be about the most popular scripting languages out there, showing up in everything from modeling apps (Blender), to games (Garry's Mod 10 for Half-Life 2), to database management (MySQL). I figure it'd be handy to get at least one under my belt, so which would you recommend, and why?
Taehl
 
Posts: 8
Joined: Mon Dec 10, 2007 11:09 pm UTC

Re: Scripting: Python VS. Lua

Postby dan » Mon Dec 10, 2007 11:40 pm UTC

As far as I'm aware, Lua is used much less as a general purpose language than Python is, so unless you only plan to be scripting for games and such, go for Python. As a side note, Ruby is also worth considering.
User avatar
dan
 
Posts: 62
Joined: Wed Aug 09, 2006 12:55 am UTC

Re: Scripting: Python VS. Lua

Postby tetsujin » Tue Dec 11, 2007 1:08 am UTC

The two have slightly different aims, as I understand it. Lua's strength is that it's fast and has a small footprint.

Python's a much more powerful option in terms of the libraries and language features. It's a language you can reasonably write some fairly substantial programs in, too.

Which to learn? I know a lot more about Python than about Lua - but I'd say go for Lua if its speed or small footprint would be significant assets (for instance in a game or on an embedded platform) otherwise I'd probably go with Python. But the real answer is, learn both. :D
---GEC
I want to create a truly new command-line shell for Unix.
Anybody want to place bets on whether I ever get any code written?
User avatar
tetsujin
 
Posts: 420
Joined: Thu Nov 15, 2007 8:34 pm UTC
Location: Massachusetts

Re: Scripting: Python VS. Lua

Postby thoughtfully » Tue Dec 11, 2007 1:41 am UTC

These two languages have only slightly overlapping application. Both are very cool trickses, in my opinion.

Python is the clear choice (among these two) for a general purpose language.

Lua is a fast and very lightweight embedded language, but also runs standalone. Python is also embeddable, but is rather full featured, and uses a good deal more resources, although if you cut out the bits of the standard library you don't use, it isn't too bad.

Lua's standard library is very spare. Python's is renowned for its completeness. Lua's OO support looks a little funny. Lua will fit (and leave a lot of room!) on a floppy. I think some enterprising hackers have shoehorned Python into floppies, but it takes a lot of work with a crowbar and doesn't include much functionality.

I am pleased to discover that Lua has bindings for most of the popular cross-platform GUI toolkits.

I'd say use Lua for embedded scripting unless you have a convincing need for the Power of Python (tm).

Lua also beats the pants off of Forth, and yes there is an (actively maintained!!) implementation for HP calculators. Drool.

Check out the Wikipedia entries, and their main websites.

Lua is on the Very Short List of languages I am going to learn Real Soon Now. :)
Image
Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
-- Antoine de Saint-Exupery
User avatar
thoughtfully
 
Posts: 1912
Joined: Thu Nov 01, 2007 12:25 am UTC
Location: Minneapolis, MN

Re: Scripting: Python VS. Lua

Postby crazyjimbo » Tue Dec 11, 2007 12:15 pm UTC

If you are going to learn Lua then a good place to start might be tinkering with a game that uses it for scripting. I learnt Lua by modding Supreme Commander and while it was a great language for this purpose, I can't imagine it being much use on its own. But then that's not what you asked for. :)

I would agree with the above sentiments that if you want to learn a language that will act as an introduction to programming, or allow you to do more than just scripting, Python is the way to go.
User avatar
crazyjimbo
 
Posts: 887
Joined: Fri Apr 20, 2007 11:45 pm UTC
Location: Durham, England

Re: Scripting: Python VS. Lua

Postby lone_wolfy » Fri Jan 04, 2008 1:43 am UTC

thoughtfully wrote:Lua also beats the pants off of Forth...

thoughtfully wrote:Lua is on the Very Short List of languages I am going to learn Real Soon Now. :)

Your statements are confusing. How does a language that you have yet to learn beat "the pants off of Forth" :?:

In what ways do you consider Lua to be superior to Forth?
lone_wolfy
 
Posts: 1
Joined: Fri Jan 04, 2008 1:35 am UTC

Re: Scripting: Python VS. Lua

Postby Hangar » Fri Jan 04, 2008 2:44 am UTC

This sounds like a religious debate. But anyway, the two languages are very different. Lua is much smaller, simpler and easy to embed; it also works well as a file format, an alternative to XML. Python is a general-purpose language. You don't embed Python in an application. You extend it with some functions that you provide in C++, but Python keeps control of the flow of control. (It is possible to embed Python, but much more difficult than Lua.) That said, Lua is much easier to pick up. I suggest you learn Lua in terms of trying to embed something. Learning Python is much more a complete exercise in itself.
User avatar
Hangar
 
Posts: 171
Joined: Fri Nov 23, 2007 3:41 am UTC

Re: Scripting: Python VS. Lua

Postby simo » Tue Feb 12, 2008 10:33 pm UTC

I learnt Lua in an evening. Infact last night. It really is bare bones. I can sum up its main features on one hand.

For speed I cant fault it. On my eeepc I made a program that generates pseudo code. It wrote 20,000 lines in 1/10 of a second. My python script took a little over a second. However in terms of the code the Lua needed a lot of comments to explain the functionality of my code, the Python seemed a lot more self explanatory with its specific data structures.

I guess its down to usage, its definitely not a VS. debate. Python I'd see as a tool for messing around with files(eg. you need something robust and easily comprehended and modded), Lua I'd integrate into my 3d stuff for pure speed.

I'm learning python (fully) next. I expect it to take longer than Lua, but it will make me much more employable. As for which to learn learn... both! Lua is tiny and thusly most implementations of specific programming techniques are just a matter of ingenuitive objective programming rather than finding the structure or function to do it for you.

-Si
simo
 
Posts: 227
Joined: Sat Dec 08, 2007 12:17 am UTC
Location: In ma Bucket! (bournemouth uk)

Re: Scripting: Python VS. Lua

Postby LauraSakura » Fri Feb 22, 2008 3:42 pm UTC

Is Lua the scripting language used to make addons for World of Warcraft?
If so... a good learning tool might be the World of Warcraft add on studio which is for Visual Studio (works in the free express version as well)
LauraSakura
 
Posts: 18
Joined: Fri Feb 22, 2008 3:16 pm UTC
Location: Somewhere between Azeroth and Middle Earth

Re: Scripting: Python VS. Lua

Postby sunami » Fri Feb 22, 2008 4:15 pm UTC

LauraSakura wrote:Is Lua the scripting language used to make addons for World of Warcraft?
If so... a good learning tool might be the World of Warcraft add on studio which is for Visual Studio (works in the free express version as well)

Having learned lua this way, I can say that it introduced a lot of pain with testing some things, like onevent handlers (which then generate other events, which throws more problems at you), which are required for any addon. I suppose for learning the basics of the language it could be great, but for anything beyond the basics of it's OO, tables, and How To Call A Function, it's slightly face-stabby [to learn it this way].
"You heard it here first: all my software is shitty."
User avatar
sunami
 
Posts: 239
Joined: Sat Jul 21, 2007 4:52 am UTC
Location: Arlington. The state of Northern Virginia.


Return to Coding

Who is online

Users browsing this forum: Jplus and 8 guests