36 comments

[ 3.3 ms ] story [ 70.9 ms ] thread
Lua is just a much simpler language at heart.

Python does have the 'there should be one, preferably only one, way to do it' mantra, but to me it utterly fails at that, and is in fact a bit of a 'kitchen sink' or 'armchair' language.

That is it's strength in some ways, it's easy and approachable, and has more libraries than perhaps any other language, so you can usually get something working fairly quickly.

But it's not so suited to sparse environments. You can't easily turn a plump armchair with automatic footrests and telescoping side-tables into a plywood Eames.

Python also seems to have more issues with stability, in the sense that things randomly stop working when you upgrade from version 3.x to 3.x+1. Lua might not be perfect either, but at least it seems common that a platform supports a range of Lua versions instead of forcing an immediate upgrade.
What’s the dev experience actually like for serious Lua? I’ve only used it for some basic neovim configuration. The dynamicism and lack of type hinting in Python that was the norm when I started having to review professional code, after transitioning from pure mathematics, was a major cognitive blocker for me. With a math paper I could typically skim the first few pages to map the author’s particular symbology (if non-standard) and know exactly what was being expressed. I could never do that with untyped code.
Lua can be quite an elegant language once you get to know it well, but you can still use it like most other programming languages, it's not that weird. There are quirks like arrays starting at 1 (and all arrays being hash tables) but they don't take that long to get used to. The real strength is in the ecosystem and implementation itself, it's designed to be easily embedded into applications and there's not really much else like it. Some developers want to incorporate a scripting language into their project and get turned off by Lua's quirks and choose something else, but it usually ends up causing more problems than it was meant to solve.

On typing, there's only a few main ones you need to worry about—strings, functions, tables and numbers. I don't think it does weird things like JS where it converts between them without asking. Luau adds some type hinting if it's a big point of concern but I haven't really looked into it much.

> What’s the dev experience actually like for serious Lua

The dev experience for lua is f-ing awful.

The language is small, but not “simple”; it’s stuck in 1985.

The tooling is nearly non-existent and the stuff that does exist is a joke.

The few libraries that exist are awful and barely maintained; the maintained libraries are maintained by neckbeards with a god-complex.

The community is “reimplementing everything by hand is the right way to do it AND ALSO you’re an idiot doing it wrong” toxic. There are a million good reasons why it’s only has a foothold in nginx and Roblox territory.

It’s not a joke to say that it’s f-ing terrible all the way around.

When I decided to create a game engine where the game could be entirely scripted in a scripting language, I was choosing between JavaScript (QuickJS), Python (Boost.Python), and Lua (Sol2).

The ease of embedding Lua, even with a C++ wrapper, is incredible. With little effort, I now have something I consider “ready”.

Not to mention, it’s a very lightweight VM.

https://github.com/willtobyte/carimbo

Boost.python is not the best scripting tool to be honest. So, that might affect your judgement as well.
Is Sol2 a Lua VM or just a wrapper to the standard Lua VM?
A nice thing about seeing an engine or application support Lua for scripting is that it implies Fennel can be used (and transpiled to Lua). Or at least that is highly likely unless something unusually weird is going on.

https://fennel-lang.org/

is anyone "serious" using micropython or lua for embedded work?
Yes, we use MicroPython for medical device development up to class B.
Could you give a link to such devices?
I can't reveal specific implementation details but I work for Planet Innovation:

https://planetinnovation.com/

Some of our products use MicroPython though we also use a whole host of other technologies. Some of our devices are proof-of-concept (often designed to progress a theory) but we also deliver up to Class B solutions.

I have been developing Lua-heavy embedded products as a freelancer for about 20 years now, including VoIP devices, home automation controllers, industrial routers, digital video recorders, and more. These systems typically consist of a Linux kernel, some libc implementation, the lua interpreter and a few 3d party libs support libs to help building the app. The Lua apps ranges from 30k to 100k lines of code, depending on the application. Some of these devices can be considered 'small' in 2025 terms: 8MB of flash, 64MB of ram. Lua is doing great here.

All of these products are still alive today, actively supported and making my customers good money.

Some things come very natural to Lua: Lua <=> C interfacing is a breeze, and while some modern languages are still struggling to figure out how to do proper async, Lua has been able to do this for decades. The language itself is minimal and simple but surprisingly powerful - a few smart constructs like coroutines, closures and metatables allow for a lot of different paradigms.

For new projects at this scale, I would still choose Lua + C/C++ as my stack. Over the last few years I have been visiting other ecosystems to see what I'm missing out on (Elixir, Rust, Nim), and while I learned to love all of those, I found none of them as powerful, low-friction and flexible as Lua.

the article is comparing micropython and lua, so i assume this is about MCU, not embedded linux.

Most of the time you have less than 1MB of ram on MCU

there are thousands of products that use Lua underneath or in some capacity. I investigated LuaJIT these past few months and I think it is underrated.
Just as one example, MicroPython is deployed in several satellites (cubesats). There are some conference talks and podcasts about it.
> [bolded] Lua isn’t just a high-level language. It’s an embedded dev strategy.

I find it difficult to take any writing seriously when it uses phrases like this.

The whole article gives me a 'I know LUA and have been using it for years, I also tried MicroPython for a couple of hours, so now I'm ready to draw conclusions' vibe. With some 'Python vs C' on top of it. Not everything written about MicroPython is factually incorrect, but some of the things are so over the top to the point that it becomes ridiculous. Just one example:

MicroPython can be equally readable, but in practice, many projects end up with blurred layers between system code and scripting. That creates a maintenance burden as projects grow.

Yeah, right. Even if this is the case (I find it hard to belive the author has really seen 'many' sort of professional MicroPython projects), where's the proof the language used was the deciding factor in that. And not the project management for instance. Or simply the dev's architecturing abilities.

Much of the article resembles chatgptese... though I suppose for adslop it doesn't matter whether it's written by a human or an llm
as other commenters noted, this sounds like chatgpt and it gave me indigestion when reading
With respect that sounds like marketing fluff.

You use micrpython when you have lots of horsepower and need something fairly robust on the network.

You use C/C++ if you need precise control over power, memory or CPU. Even though if you're doing network stuff its much harder to do quickly and securely. (THere might be better embedded TLS support now)

Lua is frankly just sparkling C. Sure if someone has create a bunch of libraries for you, then great, if not, you've now go to support lua toolchain, and your own microcontrollers toolchain, and port what ever control lib the manufacturer provides yourself.

Or, as this is a marketing page, pay https://realtimelogic.com/products/xedge/ to do it for you.

Is there a way to try out embedded Lua within the Arduino dev environment? Yeah I know, friends don't let friends, but I'm still curious.
Another scripting language that I’ve been using in embedded systems with a little more memory is AngelScript. It’s underrated in this space. It’s very easy to extend and has the advantage of being a subset of C/C++.
As a hobbyist I just use Arduino (via platformio). I don't think I need an interpreter of any sort for microcontrollers because recompiling and uploading the flash on hobbyist boards is quick and easy.

But I'd like to try some other compiled language someday because I'm not a big fan of C++. Any recommendations for something that works well with a Raspberry Pi Pico?

I dislike how the syntax of lua feels, maybe the same for its semantics

gdscript is so awesome

"Serious embedded devs" are probably using a compiled language.
Lua is a great language, including for embedded. And I am sure that their Lua-based product is good also. But this article was not very convincing as to why it "beats MicroPython". The criticisms are vague or not correct. Extending MicroPython in C is quite easy, and one can implement third party modules in the same way all the official modules are made. There is build variable to set for including that into your custom firmware build - nothing particularly tricky about it. The article goes on to lament that popular libraries from Python world are not available, including numpy. But actually there is a very good reimplementation of numpy (and parts of scipy), called ulab.
It's important to distinguish between "embedded" as in platform, and "embeddable" as in "integrate into existing application". MicroPython is used in embedded platforms, yes, but it's not an embeddable runtime like Lua. MicroPython is designed to replace the traditional C runtime with a Python one. The expected use case is to have a minimal C shim that initializes MicroPython, then define the rest of your business logic as a MicroPython script. There's no equivalent of lua_State that allows you to run multiple MicroPython interpreters concurrently in your program. There's no sandboxing functionality for running untrusted user scripts containing "while True: continue" or "oom = 'a'*(10**40)'. MicroPython doesn't solve the "I want rapid iteration with scripts in my game engine" problem, it solves the "I want to read the temperature sensor on my IoT board using Python" problem.
https://pldb.io/lists/top1000.html

Lua ranks higher than MicroPython in this list

https://www.farginfirmware.com/home/lua-vs-micropython

Github account "SkipKaczinksi" thinks Lua is generally faster

https://hackaday.com/2020/11/14/micropython-on-microcontroll...

Hackaday commenter "Michael Polia" suggests Lua, smaller, faster

https://www.cnx-software.com/2021/11/28/toit-open-source-lan...

Toit scripting language claims to be 30x faster than MicroPython

Toit founder was "responsible for initial development of V8"

The problem with Micropython is that they don't have unit tests for the features they implement, so they keep breaking things over and over, or fix something but brake something else.
Unit test coverage is exceptionally high for the interpreter, and always has been:

https://micropython.org/resources/code-coverage/

('py' folder: 99.2% line, 88.7% branch coverage)

Testing the port-specific code has been a much more challenging problem.

Which is why in the past year or two there's been a lot of energy put in to HIL testing. There are now a few dozen boards that are automatically tested with an increasingly rich suite of hardware tests. Both the number of boards and tests are increasing rapidly.

It's not perfect but it's getting pretty darn good. If you want to help out please do reach out.

Then why do they have 1300 issues open? Good luck to you but it looks like a land mine to me. They are 420 pull requests not merged, so that is a lot of disappointed developers.

They need to test the whole ecosystem, that is the usual interaction with typical peripherals (I2C, I2S, SPI, Serial, interrupts...) and for every bug fixed there should be a unit test to make sure future changes don't cause regressions.

I had this conversation with them but they take every opportunity to justify/ask for more funding.

They are also prioritizing adding support for new chips but they quickly get eaten alive by chaos, regressions and platform fragmentation.

> Then why do they have 1300 issues open? There are 420 pull requests not merged...

Because it's a large, widely-used project with relatively few core developers. Many other projects have similar numbers of issues, that's not unique to MicroPython! For example, I admire Zephyr's organisation, yet they have double the issues and 5x the PRs.

> They need to test the whole ecosystem...and for every bug fixed there should be a unit test...

Sure, that's a great ideal to strive for. That was - and is - the case for the language and interpreter. It's becoming more common for port-specific code as the tools to allow automated hardware testing are implemented. But it doesn't happen overnight and it's a large surface area.

> I had this conversation with them but they take every opportunity to justify/ask for more funding.

Ah, I presume you're referring to this discussion?

https://github.com/orgs/micropython/discussions/13436

No-one asked for funding. Some noted that such testing infrastructure doesn't come without effort or for free.

BTW I'm not sure if that was you, but that post had a pretty unhelpful, disrespectful tone. If that was you, I suggest you check your tone and get in and help create some tests. We'd appreciate the help!

> They are also prioritizing adding support for new chips...

That's often paid work. Recent paid work has helped fund HIL testing. Further, a careful expansion of the number of ports is necessary to avoid becoming irrelevant.

> ...get eaten alive by chaos, regressions and platform fragmentation

I use MicroPython commercially, daily...and I don't share your experience with chaos or regressions. Sure, sometimes issues occur, particularly if you're on the bleeding edge - but they're pretty well controlled and rapidly fixed. YMMV.

As for platform fragmentation, I struggle to understand your concerns; it has been improving for a long time now as developers have focused on ensuring compatibility between ports. Again, yes, there are some differences - but given how radically different the micros can behave, the consistency between ports is pretty remarkable.

>testing infrastructure doesn't come without effort or for free.

We don't implement unit tests because it is more effort, we implement them because in the long run is less effort and we catch issues before they happen.

Up to you.