With

It has a very simple C interface, and gives the engine developer a lot of flexibility in the language itself. Artists tend to love Lua too because it's very approachable, with plain and forgiving syntax. If your codebase is C or C, I would highly recommend it. It has good runtime performance when compared to other scripting languages like Python. Python is better for offline tools, Lua is better for embedding and configuration. Python has a mass of very useful libraries for most tasks and Lua is small, fast and very configurable, ideal for embedding.

Python is great, but pure Python code sometimes has one problem: It’s slow.

Fortunately there are several great solutions to improve the performance, like Numpy, Cython, Numba, Pypy.

All of the above solutions have different drawbacks:

Numpy and Numba are big modules. In addition Numpy is not always fast enough.Pypy is not 100% compatible and a heavy solution if it is used in addition to CPython.Cython is complex and you need a C-compiler.Recently I’ve found one more solution which maybe is not that well known: Lua integration in Python programs.

Lua is another scripting language with dynamic data types.

So I asked myself:

Does it make sense to have another scripting language inside Python scripts?

Let’s have a look at a simple example: Mandelbrot

Which Is Easier Lua Or Python Integration With C++ C

First of all the pure Python example:

Runtimes of this example on a Core i7 laptop with Python 3.7 and Windows 10:

Sizedt [s]
3203.32
64013.54
128055.59

Now the Lua example integrated in a Python script:

Runtimes of this example on a performance laptop with Python 3.7 and Windows 10:

Sizedt [s]
1 thread
dt [s]
2 threads
dt [s]
4 threads
dt [s]
8 threads
dt [s]
16 threads
3200.220.110.070.060.04
6400.680.380.260.210.17
12802.711.501.050.810.66

The above results are very impressive. As you can see Lua is really much faster. And as you can also see: You can parallelize with threads!

The module lupa, which comes with a Lua interpreter and a JIT compiler, is a very interesting alternative for speeding up long running tasks.

The Lua solution has the following advantages:

  • The lupa module is very small.
  • Lua is much faster than Python.
  • You can run Lua scripts in parallel with threads.
  • Lua is very easy to read and code.
  • You can easily integrate Lua scripts in Python code.
  • You can easily access Python objects within Lua and vice versa.
  • There are many extension modules available for Lua (~2600, see luarocks.org).

Give lupa a try. It’s easy to use and really great!

I want to start game developing but I need help choosing what programming language to learn. I already tryed Lua,Java,C++ but not Rudy and Python... So here is my question, I need the pros and cons on Ruby and Python and your recommendation. I need something I feel comfortable with.

With
  • 3 Contributors
  • forum3 Replies
  • 288 Views
  • 1 Week Discussion Span
  • commentLatest PostLatest Postby jwenting

Recommended Answers

I don't really know Ruby, and only a bit of Python (as much as I need). But I definitely say, go for Python. Python is great and is definitely becoming an landmark language in that space (high-level interpreted languages). I can't give you technical arguments why, all I can do …

Which Is Easier Lua Or Python Integration With C++ 2

Jump to Post

All 3 Replies

mike_2000_172,66921st Century Viking Team ColleagueFeatured Poster

I don't really know Ruby, and only a bit of Python (as much as I need). But I definitely say, go for Python. Python is great and is definitely becoming an landmark language in that space (high-level interpreted languages). I can't give you technical arguments why, all I can do is give you my impression, which is that Python is everywhere and super important, while Ruby remains obscure and seems to be 'losing the fight'.

Also, I don't know what you think that these languages will do for you in terms of game-dev, but I don't think it's much. Serious game-dev is dominated by C++. The 'fun apps' space is a bit more diverse (Obj-C, Java, Python). But still, the primary focus for game-dev is C++, and it will remain so probably for a long time. And that brings me back to Python, one of the great advantages of Python is that it interacts very well with C/C++ libraries, and so, it's a great language to use as a high-level layer sitting on top of the serious heavy-lifting code that you write in C/C++.

Which Is Easier Lua Or Python Integration With C++ Design

Editedby mike_2000_17 because:typo