Another (in)famous comparison!
At least once in your programmer career, you will face the need to add a scripting language to your program. Many famous programs use a scripting language: Unreal, Quake, Emacs, Blender 3D and many games.
But, when you decide it and when you start to project your implementation, you face a terrible dilemma: should you make a program with a interpreter or functions for a interpreter?
This crossroad is the "embed vs extend". I'll talk about my personal opinion and how this dilemma is equal by Lua vs Python comparison.
Python or Lua? Which one is better?
«If you ask me this, you'll never understand the answer». Maybe it's a too zen statement, but it has a truth. When you decide to use a scripting language on your program, probably you haven't decided yet what's more important: speed? Expressiveness? Clearness? Less verbosity? Python is a complete language, with a huge standard library; it's not very fast and uses much memory than a C/C++ program. Lua is faster and have a small memory footprint, but has a less complete standard library, uses metatables to implement Object Oriented Programming. I assume both are less verbose than C/C++ and both are clear enough.Conclusion? Probably, I think they have both pros and cons. Rather than ask yourself "which one is better", you should ask yourself "what I need for my next project?"
When Python and when Lua
Now, if I should start a new project without precise design goals about language/technology, I'll use Python. Why?- I like Python syntax
- I like Python OOP approach. It's more readable ("class" keyword)
- I like Python's huge standard library
- Customizable GUI
- Complex configuration files
- Plugins
- Complex data files
if I must create a big program, I'll write it in Python, extending it with C/C++ where I need higher performances. If my program is already done in C/C++, other functions will be provided embedding Lua
Conclusions
I hate the Python vs Lua comparison, because these two tools are suited for different problems. Python is more oriented to create applications and system scripts. Lua is great when you need a easy way to add features and plugins to your program.Next time you have to choose between embed or extend your program, or if you're thinking if Python is better than Lua, look at your project design. The answer is probably already there.
No comments:
Post a Comment