"Should I learn and use Python or Lua"
- a question to me. The questioner was perceptive, knowing that he shouldn't try to learn lots of languages at the same time, and that he should always limit the "basket" of languages used within his applications - in fact, he was wondering if he could select just a single language as his route forward.
All programming languages are different. BUT they all start from the same basic tennents ...
• A series of executable statements performed one after another
• Comment statements to allow the author to provide documentation for others coming back to the code later on
• Variables used to store information between statements
• Conditional statements or groups of statements performed only if a particular expression is true when the group (block) is reached
• Loops - blocks of statements which may be performed multiple times while a particular expression is true
• Loops and conditionals within loops and conditionals to deal with more complex cases
• Collection variables, in which you can gather a group of pieces of information under a single name.
• The ability to name blocks of code so that you can run them multiple times (with different inputs to the block too).
• Libraries of commonly used blocks of code which can be shared between programs. Many of these libraries provided with the language itself so you can easily call up common tasks such as reading keyboard or file inputs, and writing outputs.
• Storage of all of the above into disc files so you can write it once and run it may times.
The differences between the languages come in HOW they achieve the above - and how they achieve much more too. And those differences will effect what language is best for any particular task. You also need to consider:
• Licensing Issues and cost
• Knowledge of your existing team, and existing codebases
• The future availability and support of the language.
Let's look at the specifics of Lua v Python.
Lua is a small language - it has a tiny footprint which allows it to be used on almost any size of computer without grabbing a significant proportion of resources. That's fantastic news for applications such as computer gaming, where every byte and cycle can cost over thousands and (perhaps) millions of systems. But there's a sting in the tail - it's smaller because it doesn't include as many facilities and (especially) standard libraries, so that the programmer will often have to do a lot more work in writing code that a user of a larger language.
Python is a much larger language in comparison
. I've been careful so say "in comparison" because it does not include the bloat that you'll find in languages like Java and Perl, leading them towards applications with yet different metrics. So in Python, you don't have to do all the low level level "roll you own" coding that you sometimes need in Lua, but that's at the price of a bigger memory footprint and somewhat slower operation ... which doesn't really matter if you're running the code on a bigger computer such as a web server, or if you're not looking for the high speed dynamic graphics expected of a game.
Both Lua and Python are open source, with good licenses that allow you to use the language free at the point of distribution. Lua has an especially open license - you can distribute it as a part of your product (the license must be included) without charge, and without making your code conform to the same open source license (i.e. it is not a "Viral" license that transfers to all code written in Lua). So - again this places Lua ideally for inclusion in games, and in other commonly and heavily distributed bits of code such as virus scanners.
When you decide to invest - and it's often a heavy investment - in writing a large code base, you'll also want to know that it will have a long life. New hardware products seem to come out every year (like new car models!), but underlying them is the same programming - or at least the same libraries. You get to realise just how important this is, and how long the life of code is, when you look at Perl, PHP and Python and their major releases - how comparability, or at least a route forward to save redevelopment, is paramount in their plans, including ongoing support for facilities that are last-millennium, pre-web. Good news - both Lua and Python have strong, and ongoing, support and because they're open source they're not as susceptible to being withdrawn as a commercial product - you aren't going to suddenly hit a wall where you can do nothing, or find yourself having to buy an expensive contract for continued support and use. I'm afraid I can't say that "Open source = never an ongoing support problem" - there are several open source languages around at the moment where new versions and facilities are commercial / much more commercial, and I see the free-to-use approach fading onto older, more limited and more difficult to use versions. I can't say "never" for Lua or Python, but I'm not worried about them - whereas I am worried about MySQL and Java.
So - back to the original question - "Should I learn Lua or Python". The questioner's involved in the writing and production of computer games, sold and supported via a web service / site. His team are already writing in Lua (for the game) and Python (using a Django framework) on the web server. Good news - from what I've been told of the game and web site, the use of two different languages seems a sensible decision in this case, and both languages are well suited to the particular use / application to which they'll be put, as described to me.
With regards to learning, I'm going to answer a question with a series of question.
"Do you want to work on the game end or the web end of the business?"
"Are you a good learner who revels in getting deep into projects and detail"
"Might you do better actually be better placed getting an overview so that you can better support your existing team of programmers?"
These are very business-specific and personal questions, and it's up to the personal answers given by the questioner to find the best answer to the original question.
I have added two comparative examples, showing a program to tackle the same simple application if Lua and Python.
is a program in Lua which reads from the keyboard, and calculates on a loop outputting the results. And [here]
is the same thing programmed in Python. You'll note that even in a short program like this, the prompt-read is much shorter and cleaner in Python, but the Lua runs perfectly well.
is a program that opens and reads a file in Python, sorts the lines and outputs the sorted results. Again, it's longer in Lua - see [Here]
. I was very tempted to write a more complex data analysis - in Python that would have been trivial. In Lua it would have been very practical, but I would need to spend a lot more time on a course explaining the algorithms behind it. For completeness, the data file that both these programs use may be found [Here]
We run public Python and Lua courses. Here are some links ...
Public (open) Lua classes
Public (open) Python classes
These courses run at our Melksham, Wilthshire, UK training centre where we have residential accommodation available for delegates to stay overnight during courses.
We also run private (single company) classes in both Python and Lua - either at our training centre, or on site at your facilities. You can find further details ...
Private Lua or Python courses at your own offices
Private Lua or Python courses at our training centre in Melksham
Private course can be tailored to meet you exact needs.
(written 2011-12-21, updated 2011-12-24)
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articlesQ102 - Choosing your language 
Programming languages - what are the differences between them? - (2012-06-27) 
Shell, Awk, Perl of Python? - (2012-06-14) 
Ruby v Perl - a comparison example - (2012-02-21) 
Rekeying a table - comparison in #Ruby #Perl and #Python - (2011-02-14) 
Ruby - how does it compare and where is it the right language? - (2010-07-11) 
The same very simple program in many different programming languages - (2010-03-31) 
All the Cs ... and Java too - (2009-12-13) 
When should I use Java, Perl, PHP, or Python? - (2009-12-13) 
Admission - (2009-11-19) 
Learning to program in PHP, Python, Java or Lua ... - (2009-02-19) 
I have not programmed before, and need to learn - (2009-01-19) 
Speaking all the languages - (2009-01-12) 
Learning to program in - (2004-10-07)U103 - Lua - Conditionals and loops 
repeat until in Lua - a one or more rather than a zero or more loop - (2015-11-05) 
Learning to program - Loop statements such as while - (2014-11-22) 
Learning to Program - the conditional statement (if) - (2014-11-21) 
Lazy operators in Lua - what they mean, and examples - (2014-05-05) 
The goto statement in Lua - (2012-04-06) 
Does a for loop evaluate its end condition once, or on every iteration? - (2011-08-18) 
Lua examples - coroutines, error handling, objects, etc - (2009-10-15) 
For loops in Lua - (2009-10-14) 
Ternary operators alternatives - Perl and Lua lazy operators - (2009-08-12) 
Clean code, jump free (Example in Lua) - (2008-08-06) 
Saying NOT in Perl, PHP, Python, Lua ... - (2008-07-04) 
Short circuit evaluation (lazy operator) in Lua - (2008-06-22)U110 - Lua - Input / Output 
Reading a data file and sensing EOF in Lua - (2009-08-10) 
Formatting with a leading + / Lua and Perl - (2008-10-15) 
Lua examples, Lua Courses - (2008-08-08)Y103 - Python - Conditionals and Loops 
Conditional operators in Python - (2016-11-05) 
Equality (in Python) - (2016-10-30) 
Method, Class, Module, Package - how to they relate in Python? - (2015-10-17) 
Setting up and tearing down with the Python with keyword - (2015-10-16) 
Finding sum, minimum, maximum and average in Python (and Ruby) - (2015-01-19) 
If elif elif elif - multiway selection in Python - (2013-11-16) 
Identity in Python - (2013-05-17) 
Flowchart to program - learning to program with Well House - (2012-10-14) 
Learning to program - the if statement. Python. - (2012-06-12) 
Finding the total, average, minimum and maximum in a program - (2012-02-22) 
Python for loops - applying a temporary second name to the same object - (2011-09-14) 
How a for loop works Java, Perl and other languages - (2011-03-12) 
Python - fresh examples from recent courses - (2010-12-11) 
Groupsave tickets - 3 or 4 train tickets for the price of 2 - (2010-08-02) 
Learning to program in Python 2 ... and / or in Python 3 - (2010-05-24) 
Equality, sameness and identity - Python - (2008-05-31) 
Decisions - small ones, or big ones? - (2007-12-18) 
No switch in Python - (2007-05-23) 
Python is like a narrowboat - (2006-10-30) 
Python - when to use the in operator - (2006-08-16) 
New - Conditional expressions in Python 2.5 - (2006-07-01) 
Python - block insets help with documentation - (2006-04-04) 
The ternary operator in Python - (2006-03-25) 
Wimbledon Neck - (2005-06-20) 
What - no switch or case statement? - (2005-05-03)Y110 - Python - File Handling 
with in Python - examples of use, and of defining your own context - (2016-11-02) 
Scons - a build system in Python - building hello world - (2016-10-29) 
Easy data to object mapping (csv and Python) - (2016-03-24) 
Command line parameter handling in Python via the argparse module - (2015-12-08) 
Running an operating system command from your Python program - the new way with the subprocess module - (2015-03-06) 
Loving programming in Python - and ready to teach YOU how - (2015-02-22) 
How can I do an FTP transfer in Python? - (2011-10-05) 
A demonstration of how many Python facilities work together - (2011-09-16) 
Old prices - what would the equivalent price have been in 1966? - (2010-07-14) 
Checking robots.txt from Python - (2009-07-12) 
Conversion of OSI grid references to Eastings and Northings - (2009-01-28) 
Reading a file multiple times - file pointers - (2007-11-23) 
The elegance of Python - (2005-01-19) 
Relative or absolute milkman - (2004-11-10)
Some other Articles
Christmas Day - for unique picturesHappy Christmas ... a Christmas morning walk in MelkshamMelksham, Month by month through 2011Well House Consultants - Open Source Programming Courses for 2012Python or Lua - which should I use / learn?Melksham Christmas Lights - Town, Shops and Private HousesAeryn at 1Football league tables - under old and new point system. Python program.Learning more about our web site - and learning how to learn about yoursChanges to morning routines