When I see Lua, the only thing I ever read is "great for embedding", "fast", "lightweight" and more often than anything else: "World of Warcraft" or in short "WoW".
Why is it limited to embedding the whole thing into another application? Why not write general-purpose scripts like you do with Python or Perl?
Lua seems to be doing great in aspects like speed and memory-usage (The fastest scripting language afaik) so why is it that I never see Lua being used as a "Desktop scripting-language" to automate tasks? For example:
Is it the lack of the standard library?
In order for Lua to be easy to embed it has to have few dependencies and be small. That makes it poorly suited as a general purpose scripting language. Because using it as a general purpose script language would require a lot of standard libraries.
Lua can be used in everyday applications to extend the existing functionality or create new features and functions. Some popular games, programs, and services that use Lua are Dark Souls, Fable II, Garry's Mod, Wireshark, VLC, Apache, and Nginx Web Servers.
Lua has an extremely clean simple design and a small API. I think this is the reason that it has the world's fastest JIT implementation for a dynamic scripting language. Lua is extremely popular within the gaming market because of its speed (see also speed compared to python).
Lua is a cool language, light-weight and extremely fast!
But the point is: Is performance so important for those tasks you mentioned?
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:
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 run the program, but you can do other things when the program is running. How about play World of Warcraft, kill monsters with 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 is not on the performance of the language. The bottleneck is on network I/O, HTML parsing and multitasking. All I have to do is make sure the program works and find the bottleneck. Finally, I chose Python rather than Lua. There is so many excellent Python modules; I have no reason to build my own.
According to my experience about webscraping, I chose Twisted for network I/O and lxml for html parsing as the backend of 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With