Live data from Hacker News

Lua beats MicroPython for embedded devs

embedded.com

61–70 of 87 posts

Re: Lua beats MicroPython for embedded devs

#61
post #4

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 no…

> 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…

Lua was designed in 1993. This was back when MS-DOS was still cutting edge and the 66MHz Pentium was cutting-edge consumer technology.

Even "modern" languages often don't have features like first-class functions, closures, proper tail calls, etc that Lua has had for a very long time now. LuaJIT also trades blows with JS almost certainly making it the fastest or second-fastest dynamic language around.

There's a lot to like about the language (aside from array indexes starting at 1), but I think you are right about the ecosystem and probably right about most of community.

Re: Lua beats MicroPython for embedded devs

#63
post #44

Earlier quoted context omitted.

It is a RP2040. We plan to eventually upgrade to RP2350B.

Well, there you are: https://github.com/MicroLua/MicroLua

Do you have anything like this: https://docs.micropython.org/en/v1.9.3/pyboard/reference/spe...

Viper Bytecode emitter.

Re: Lua beats MicroPython for embedded devs

#64
post #16

Earlier quoted context omitted.

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…

I am currently working on an embedded system with 264Kb of RAM and 4Mb of flash. Do you think Lua could be used in such limited settings? I am also considering the berry scripting language [0]. [0] https://berry-lang.github.io/

Those are generous resources for MicroPython. And it'll be faster and less quirky to develop in than either Berry or Lua.

Re: Lua beats MicroPython for embedded devs

#65

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 lo…

it's not an embeddable runtime like Lua

While it's true you can't have multiple MicroPython interpreters running concurrently (or at least not easily; it's not that the design makes this impossible, it's just that all in all MicroPython is fairly young and development focus has been put elsewhere), it is possible to embed MicroPython. Not completely out of the box, needs some glue code etc. See for example https://github.com/micropython/micropython/tree/master/ports....

Re: Lua beats MicroPython for embedded devs

#66
post #16

Earlier quoted context omitted.

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…

I am currently working on an embedded system with 264Kb of RAM and 4Mb of flash. Do you think Lua could be used in such limited settings? I am also considering the berry scripting language [0]. [0] https://berry-lang.github.io/

It's more than generous. You can run it with much less resource utilisation than this. It only needs a few tens of kilobytes of flash (and you can cut it right back if you drop bits you don't need in the library code). 32 KiB is in the ballpark of what you need. As for RAM, the amount you need depends upon what your application requires, but it can be as little as 4-8 KiB, with needs growing as you add more library code and application logic and data.

If you compare this with what MicroPython uses, its requirements are well over an order of magnitude larger.

Re: Lua beats MicroPython for embedded devs

#68

Earlier quoted context omitted.

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

"It isn't just X, it's Y" is textbook ChatGPT.

ChatGPT must have learned that from somewhere...

Re: Lua beats MicroPython for embedded devs

#69

Earlier quoted context omitted.

Yes, we use MicroPython for medical device development up to class B.

How do you handle memory fragmentation?

Carefully, at least for devices with higher classifications. Using pre/early allocation helps but, more importantly, we monitor memory use over time in realistic scenarios. We've built tooling, like a memory-profiler [1] that allows us to observe memory consumption and quantify performance over time.

However, it turns out that MicroPython has a simple and efficient GC - and once you eliminate code that gratuitously fragments memory it behaves quite predictably. We've tested devices running realistic scenarios for months without failure.

[1] https://github.com/pi-mst/micropython-memory-profiler

Re: Lua beats MicroPython for embedded devs

#70

Earlier quoted context omitted.

> There are quirks like arrays starting at 1 I know it’s probably and overreaction, but this was a compete non-starter for me.

Not having to put length-1 everywhere is a good thing, actually.

Probably just use a .last method or something. Reads better too.
Post reply on HN