Open side-bar Menu
 Embedded Software
Colin Walls
Colin Walls
Colin Walls has over thirty years experience in the electronics industry, largely dedicated to embedded software. A frequent presenter at conferences and seminars and author of numerous technical articles and two books on embedded software, Colin is an embedded software technologist with Mentor … More »

Ah! Lua

 
February 18th, 2019 by Colin Walls

My Portuguese is limited. Well, non-existent actually. Last time I was in Portugal, finding myself in restaurants where no English was spoken, it was a matter of selecting things rather randomly from the menu or pointing at other people’s plates. When I first saw the name Lua, it made me think of the Hawaiian greeting “Aloha!”, but then I found out that its meaning was “moon”.

But really, it is a scripting language …

I have always been interested in the wide range of available programming languages and have a couple of shelves full of books on the topic. Of course, my focus is particularly on languages that find a place in embedded systems. I was, therefore, intrigued when a reader contacted me and told me about a language that I had never come across before: Lua.

I have a profound ignorance of many things in the world, but my lack of awareness of Lua is particularly surprising, as it has been around for a couple of decades!

Lua is executed using a virtual machine (like Java) which interprets bytecodes. It has a very straightforward syntax that has much of the simplicity of C, but is more forgiving (IMHO). This is combined with great flexibility in data representation and automated memory management. If I have any criticism, it might be that the dynamic typing is just a bit too flexible and might lead to very sloppy coding.

Lua has been used in many applications, but why might it be useful to the embedded developer? Several reasons:

  • the Lua runtime is quite compact
  • execution is fast
  • the runtime code is very portable
  • it is designed to integrate with code written in other languages – typically C/C++

In addition, embedded developers are quite a conservative bunch, only adopting a technology that is well proven. Lua has been shown to be robust and has been applied very widely for both embedded and non-embedded (like games design – heard of Angry Birds?) applications. The open source licensing is also an attraction.

As Lua is very easy to get running and get to grips with – I got it installed on my Windows PC and was busy programming within the hour. So, apart from being embedded in systems that need a scripting language, it seems to me that fast prototyping of algorithms is another application of the language. To give you a feel for the language, here is some Lua code:

If like me, you have never heard of Lua, you may be surprised to find that you already know how to use it. How come? It is the scripting language built into a number of software products and systems. An example is one of my favorite desktop applications – Adobe Lightroom – which uses Lua for plug-in implementation.

Logged in as . Log out »




© 2024 Internet Business Systems, Inc.
670 Aberdeen Way, Milpitas, CA 95035
+1 (408) 882-6554 — Contact Us, or visit our other sites:
TechJobsCafe - Technical Jobs and Resumes EDACafe - Electronic Design Automation GISCafe - Geographical Information Services  MCADCafe - Mechanical Design and Engineering ShareCG - Share Computer Graphic (CG) Animation, 3D Art and 3D Models
  Privacy PolicyAdvertise