Lua vs. Python as embedded scripting languages.

Lately when I was skimming through slashdot’s articles I’ve found a story about game developer having problem with paypal. Having myself paypal account I initially though it would be good knowing what this is about, because I don’t want to be caught by surprise one day, and be unable to access my own money. Starting reading about Notch case I havn’t suspected I’ll end up discovering new programming frontiers.

Making long story short, I ended up watching C418’s BIG JAM videos. I assume C418 must be somebody connected with indie game scene, but frankly speaking I’ve never heard about him before. I haven’t been playing or writing my own games in a long time, so those presentations was like big bag of fresh ideas. Especially one’s caught my attention. A use of scripting languages in C++ applications.

Being C++ programmer professionally and Python fledgling, when referring to built-in scripting I always was considering latter to be my language of choice. Suddenly this all changes as I’ve learnt about something new. This was how I started discovering Lua .

Not knowing much about it, I’ve been a bit distrustful if it’s really worth my attention and me spending more time investigating the use cases of Lua. However after reading few other articles and where people shared my own doubts, I think I’ve made up my mind and could consider Lua as a another great choice if for embedded scripting language beside a Python.

Not being viable to write my own examples, I’ve used Google and found out that there at least few articles describing pros and cons of both languages in case of embedded scripting. Lua Versus Python which could be found on Lua’s mailing list explains in a impartial way uses of those two languages in decent way. Of course this articles describes Lua with much more details, but it’s not a surprise looking at the place it can be found on.

Another great source of knowledge is a stackoverflow’s question “Which game scripting language is better to use: Lua or Python?“. It’s much more focus on a discussion therefore you can find there arguments from both sides. Thus making this discussion much more interesting.

So here it is short Lua vs. Python smackdown in a nutshell:

  • Python comes will many additional libraries, which make writing complex application easier that in Lua.
  • Because out of the box Lua is much more crippled that Python it allow it to be smaller and easier to embed in system where you do not  need additional functionality, beside having a possibility to control your main system with it. This is a result of initial provisions Lua engineers’ve taken, as Lua started as a language for configuration purposes.
  • It worth to mention that even though Lua doesn’t come with all functionalities of Python it’s still possible to extend it with additional libraries, ie. from LuaForge.
  • Both Python and Lua are easy to access from C++ application. However from the what I read it looks like Lua is slightly better and accessing its code comes much more naturally.
  • If you are considering multithreading application, you might be better with Lua.
  • Those two language both have interpreters with run their code and manage all task connected with modern programming languages, ie. memory management, JIT, debugging. However Lua is lacking good remote debugger.

This is just a short list of advantages and disadvantages of both languages, but at the end it comes to the complexity of what you want to accomplish. If you are looking for a language for writing a logic for your app I suppose Python is a way to go. If, on the other hand, you are looking for good configuration/control scripting language Lua seems better.

I hope this would give you a solid start in your own investigation. As all my current plans regarding programming are a little bit limited I’m not sure how much of my free time I will be able to spent learning more about Lua or Python as embedded scripting language. However two of them looks like great prototyping tools and you can count on my writing something more about any of them.

Till then, have a nice hacking time!

This entry was posted in blog, c++, lua, programming, python. Bookmark the permalink.

2 Responses to Lua vs. Python as embedded scripting languages.

  1. Uri Cohen says:

    “However Lua is lacking good remote debugger.”
    No more!

  2. Pingback: lars bendixen (lars.b) | Pearltrees

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s