Advertisement

Lua vs. Python

Started by February 22, 2004 10:01 PM
8 comments, last by gbone 20 years, 9 months ago
Just curious why people are using Lua and not Python - seems like Python is syntactically easier to read and thus a better rapid development language. What do you guys think?
I find that the difference between Lua and Python is actually fairly small. Syntactically, they are in reality very similar, the biggest difference being the sometimes awkward enforced indentation of Python as opposed to an explicit keyword (end) to demarcate the end of blocks of code. Python is a little bit more powerful, especially in list manipulations, and has a greater wealth of external modules, but Lua tends toward smaller size added to the size of your executable. It''s almost like a lightweight version of Python, and can be handier and a tiny bit easier to embed than Python. But if you can program in one, you can certainly program in the other with only minor adjustments in thinking.

I personally prefer Lua for embedding, but that preference is in no way based on any assumption that one is better than the other, since I routinely use Python (and enjoy using it) for other projects such as Blender scripts. Since I place little reliance on outside modules when embedding, the main reason to choose Python (the wealth of modules) is mostly eliminated.

Golem
Blender--The Gimp--Python--Lua--SDL
Nethack--Crawl--ADOM--Angband--Dungeondweller
Advertisement
I confess, i have only looked at lua, but had to work in a team which chose Python. I saw that python needs a dll-file (please correct me if i''m wrong, i just don''t believe they wouldn''t make also a static lib). I also do not like the indent flow control. From some projects i see on the web i also get the impression that some people want Python to be a full fledged programming language which it ain''t. It''s a scripting language.

I format my code quite readable (subjective opinion), but i don''t like being forced.

The first thing i wanted to do with the scripting language was embed it in my simple, one-file installer.
Lua worked very fine for me for my small installer app, adding only about 90k to it when being stripped of unneccessary extra libs. I''ve used lua for some games now too and it works flawlessly. There''s some simpler class wrappers like luna (simple, but yet powerful) and some heavy beasts like luabind (which are damn easy to work with, just heavy on the compiler).

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

I confess, i have only looked at lua, but had to work in a team which chose Python. I saw that python needs a dll-file (please correct me if i''m wrong, i just don''t believe they wouldn''t make also a static lib).

There is a 155k static lib.

I also do not like the indent flow control.

Matters of taste.

From some projects i see on the web i also get the impression that some people want Python to be a full fledged programming language which it ain''t.

Python is a ''full-fledged'' programming language.

It''s a scripting language.

The difference being?

I format my code quite readable (subjective opinion), but i don''t like being forced.

Work on large projects, and you''ll learn the importance of coding standards.

"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
Lua was designed from the ground up as an embeddable and extensible language. Its primary purpose has always been as an extension language for applications, serving as both a data description format and a scripting component. In contrast, Python was designed primarily as a standalone language. Of course both fulful both functions; but the "advertising" for Python tends to focus on its standalone uses, whereas the "advertising" for Lua tends to focus on embedding it.

"Sneftel is correct, if rather vulgar." --Flarelocke
There is a 155k static lib.

Didn''t know that, that''s a big plus for python.

''full-fledged'' vs. ''scripting''
The difference being?


Scripting language has for me the meaning of being embeddable and not being the complete code of the main app.

Work on large projects, and you''ll learn the importance of coding standards.

I did and i know how to work with standards. I was forced to use tabs (yuck!) and i did. I still don''t like them.


Back to the topic:
It''s a matter of the project design, what kind of tasks you need the scripting to do. You should choose the language by how it fulfills your requirements best. If you have more choices it''s mostly a matter of taste.
You could also ask why people are using C++ and not C#.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

Advertisement
quote: Original post by Endurion
Scripting language has for me the meaning of being embeddable and not being the complete code of the main app.


Yeah, but your understanding of the term doesn''t prove anything, does it? If I started calling C++ a scripting language, would that make it any less capable?

Python is a complete programming language.


[ MSVC Fixes | STL Docs | SDL | Game AI | Sockets | C++ Faq Lite | Boost
Asking Questions | Organising code files | My stuff | Tiny XML | STLPort]
I agree with VertexNormal, there is no big difference between lua and python.
I use Python, and I am very happy with it, I has everything I need for my game programming stuffs. But I''m sure Lua would have been great too.

I usually found this discussion looking like OpenGL vs DirectX discussion : some zealot fighting for their church, and not being really open to anything else...


BTW, Endurion, if I use Python with C++ module for my app, does that makes C++ a scripting language... Whoa...
Well, looks like i need to redefine my understanding of scripting.

I''ll probably go take a look at Python then; sounds better than i remember it to be.

AP: I refer to scripting when it''s embedded and mutable without recompiling (usually interpreted), as in Configuration scripts and Game-"Movie"-scripts.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

Scripting is an inaccurate term for programming in Python. The origin of the term in regard to programming at all is probably in Unix shell scripts, which are difficult to consider in traditional programming parlance (shell scripts don''t have modules, they simply invoke other scripts like executables from the command line; shell scripts don''t have data structures of any sort; shell scripts have no concept of type per se - and it''s completely different from the dynamic typing of Lua and Python).

Unfortunately, the term was popularized as a convenient means of stating that an application was programmatically extensible - from Microsoft Office to Unreal [Tournament] - resulting in the mistaken pidgeonholing that some are given to today.

One more thing: There is generally only one widely available implementation of Python, though I have heard of a second. Many of the limitations pointed to as flaws of the language are actually choices in the implementation; an individual with the desire, skill and time could provide an implementation with completely different choices made, yet retaining all core language features (perhaps with fewer builtins?)

This topic is closed to new replies.

Advertisement