Lua in multi-programmer teams

First of all, thank you for the invitation and this wonderful piece of software!

I love Lua a lot. I used it for a couple of solo projects, and it worked great! But in a team of several programmers, how does it fare compared to a statically typed language, say C#?

I’ve been coding in C# extensively over the past 2 years on a game project, and getting to APIs of various libraries, and most importantly, classes that other programmers write, is a breeze, thanks to the strong intellisense. Speeds up your typing rapidly. In Lua, you don’t have such a comfort.

So, people who work in teams, what is your experience with it?

We have several teams at King working with Defold. I think the largest team of client devs we have for a single project working in Lua and Defold is six developers. My personal experience and what I learnt while working with the game teams here at King is that multi-programmer teams and Lua is far from mutually exclusive. Some thoughts:

  • Lua isn’t an OOP language (although you can achieve the same thing if you wish) so you won’t see a lot of inheritance, interfaces and complex interaction with a ton of different classes. With that being said, it is still very easy to organise your code in a modular way through the use of Lua modules and script files that you combine on a game object to build advanced behaviour. If done right there is no risk of huge monolithic Lua modules and scripts and it becomes easy for many developers to work on the same project without stepping on each others toes.
  • Since Lua isn’t a compiled language there’s a higher risk that less frequently run code paths may contain bugs or that certain kinds of issues sneak by and only get caught when running your code under certain conditions. Use assert() to verify function arguments and other requirements and pcall() to catch and handle runtime issues.
  • Use a static code analyser such as LuaInspect or luacheck to verify your code before running it. You can find things such as unknown global variables, unused variables and so on.
  • Test your code! Use unit tests for important game logic! Busted and Telescope are popular unit test frameworks.
  • If you write a lot of code and find that the built in editor is lacking then look at another IDE, for instance LDT (Eclipse based), IntelliJ (with the Sylvanaar plugin) or Sublime or Atom with Lua plugins enabled.
4 Likes

Thank you, britzl!

This comes as natural to me. We are using C# in our Unity project in a similar fashion. If we ever decide to go for inheritance somewhere, then only a shallow one. I would never go back to huge inheritance trees (ick).

Basically, I meant intellisense vs just reading. As I see it, with statically typed langs, you get the power and comfort of intellisense + complile time checking, with dynamic languages, you get the ease of use, straightforwardness, and a ton of flexibility. Pros and cons.

Use assert() to verify function arguments and other requirements and pcall() to catch and handle runtime issues.

Yeah, you can find quite a few of these in my Lua code. :smile:

Use a static code analyser such as LuaInspect or luacheck to verify your
code before running it. You can find things such as unknown global
variables, unused variables and so on.

Didn’t know about these. Thanks!

If you write a lot of code and find that the built in editor is lacking
then look at another IDE, for instance LDT (Eclipse based), IntelliJ
(with the Sylvanaar plugin) or Sublime or Atom with Lua plugins enabled.

Yeah, I’m using Sublime from the get go, losing the advantage of getting Defold’s API calltips. Lack of dark theme ain’t friendly on my eyes :smile:

2 Likes