Advertisement Jump to content
Sign in to follow this  

What programming language should someone pair with LUA?

This topic is 819 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everybody,


i am experimenting with a lot of languages lately and asking myself:


"What is the best language to use, when you want to have LUA as the scripting/extension language for game development?"


And are there (good) engines out there, which support those two languages combined.

I know there are a few languages using C++ and LUA, like the CryEngine for example.



Is there any other thought on this? 


Greetings :)

Share this post

Link to post
Share on other sites

Almost every (console game quality) game engine uses C++ primarily, so that pretty much limits your answers to C++ & Lua :lol:


Besides Cry, Stingray makes extensive use of Lua (more than most engines), and the previous few proprietary engines that I've worked with have been C++(engine) plus C++/Lua(game).

In my own engine, and some proprietary ones that I've worked with, Lua is also used within the toolchain, where it's C# & Lua, and as a DSL for a high level shader ("FX-like") language alongside HLSL.

Share this post

Link to post
Share on other sites

If you're not doing console game quality, it opens up the floor a bit more, so alternatives to c++ become viable. I'm working on a game project at the moment which is a mixture of C# and Lua.


To answer your question, the "best language to use" is probably going to be whatever language *you* are most proficient in that has a Lua implementation. 

Share this post

Link to post
Share on other sites

The common arguments for C++ is "because it is faster".

  But for whom is it faster?


The common arguments for scripts is "because C++ is a pain to use".

  So why do you use C++ in the first place?


The common arguments for OOP in C++ is "because it is higher".

  So why do you use a low level language just to fragment the heap with allocations that Java could move to the stack automatically?


If you use a safe compiled language as a middle layer then you can get both safety and performance at the same time which I consider to be a good tradeoff for most of the code.


Scripts are supposed to allow hard coded events for dynamically loaded things so that the core of the game does not have to change for each user made level.

A compiled language (C / C++) will catch a lot of run-time bugs as compile-time errors so use it instead of scripts whenever it makes sense.

A safe compiled language (Basic / Java) can prevent access violation and memory leaks leading to robust execution for the level designer and other tools.


Whenever you use scripts, consider if function pointers, class inheritance, data flow graphs, state machines or tables can be used instead.

The simpler it is, the easier it is to maintain when the interface has to change and graphical representations are nice to have in level editors when you just want a door to open when a button is pressed.


Use scripts when:

* You have dynamically loaded content and want players to be able to make their own things

* You want to do something that cannot be done easily with a compiled language because it is not expressive enough


When it comes to performance, higher languages give faster code given that the programmer is a beginner by applying high level optimizations more freely.

A low level language cannot do high optimizations because it is too explicit and assumes a certain level of hand optimization.

When writing code in C, you can be amazed by how poor the optimization is when looking at the assembly code. (around 5% of obvious optimizations applied)

Writing the same code in a higher language can then apply most of the obvious optimizations and some that you did not even think about.


Use C/C++ when:
* You are optimizing some things on a level where a higher language has awkward workarounds

* You want to use SSE/NEON SIMD intrinsics with multi-threading

* There is a certain library that has no wrapper yet

* You want to make code that can be called from another language without heavy dependencies

* You need the generic pointers for data management

* ...

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!