Lua as a general-purpose scripting language? Lua as a general-purpose scripting language? python python

Lua as a general-purpose scripting language?


Lua is a cool language, light-weight and extremely fast!

But the point is: Is performance so important for thosetasks you mentioned?

  • Renaming a bunch of files
  • Download some files from the web
  • Webscraping

You write those programs once, and run them once, too maybe.Why do you care about performance so much for a run-once program?

For example:

  1. Cost 3 hours to write a C/C++ program, to handle data once, the program will take 1 hour to run.
  2. Cost 30 Minute to write a Python program to handle data once, the program will take 10 hours to run.

If you choose the first, you save the time to run the program,but you cost your time to develop the program.

On the other hand, if you choose the second, you waste time to runthe program, but you can do other things when the program isrunning. How about play World of Warcraft, kill monsterswith your warlock? Eat my D.O.T! :P

That's it! Although Lua is not so difficult to write, everything about Lua is designed to be efficient.And what's more, there are little modules for Lua, but there are so many modules for Python. You don't want to port a C library for Lua just for a run-once program, do you? Instead, choose Python and use those module to achieve your task easily might be a better idea.

FYI: Actually, I have tried to use Lua to do webscraping,but finally, I realized I do not have to care so much about language performance. The bottleneck of webscraping isnot on the performance of the language. The bottleneck is onnetwork I/O, HTML parsing and multitasking. All I have to dois make sure the program works and find the bottleneck.Finally, I chose Python rather than Lua. There is somany excellent Python modules; I have no reason to build myown.

According to my experience about webscraping, I choseTwisted for network I/O and lxml for html parsing as the backendof my webscraping program. I have wrote an article for an introduction to this technology.

The best choice to grab data from websites: Python + Twisted + lxml

Hope this is helpful.


Lua has fewer libraries than Python. But be sure to have a look at LuaForge. It has a lot of interesting libs, like LuaCURL, wxLua or getopt.

Then, visit LuaRocks, the package management system for Lua. With it, you can search and install most mature Lua modules with dependencies. It feels like RubyGems or aptitude.

The site lua-users.org has a lot of interesting resources too, like tutorials or the Lua Wiki.

What I like about Lua is not its speed, it's its minimal core language, flexibility and extensibility.

That said, I would probably use Python for the tasks you mentionned because of the larger community doing such things in Python.


Just because it is "marketed" (in some general sense) as a special-purpose language for embedded script engines, does not mean that it is limited to that. In fact, WoW could probably just as well have chosen Python as their embedded scripting language.