Live data from Hacker News

Lua beats MicroPython for embedded devs

embedded.com

51–60 of 87 posts

Re: Lua beats MicroPython for embedded devs

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

8 years of full time professional lua development experience here and unfortunately I agree with all of this. I use fennel when I can; it doesn't improve any of the library or tooling problems but it doesn't make them worse either and addresses several of the problems with the language semantics itself.

Re: Lua beats MicroPython for embedded devs

#52

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?

Nim is a likely a pretty good option, see https://github.com/EmbeddedNim/picostdlib/tree/master

Toit from the v8 devs is also pretty cool.

Re: Lua beats MicroPython for embedded devs

#53

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.

Actually I haven't heard this. Does Arduino have a bunch of controversy now?

It evokes the "real engineers don't use it" reaction, similar to any tool that's perceived as being of primary interest to hobbyists and students.

Some concerns are valid: Arduino doesn't have as much flexibility for digging really deep into things like pin and memory assignments and what happens when a microcontroller starts up. Also, the quality and documentation of Arduino support can vary from one MCU family to another.

There's a concern about the quality of libraries and code.

It doesn't support hardware debugging.

Granted, the embedded community has good reasons for being conservative, especially for critical applications.

Re: Lua beats MicroPython for embedded devs

#54
post #29
post #2

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

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.

Could you give some examples?

Re: Lua beats MicroPython for embedded devs

#56
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.

Re: Lua beats MicroPython for embedded devs

#58
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.

Re: Lua beats MicroPython for embedded devs

#59
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"

Re: Lua beats MicroPython for embedded devs

#60

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…

> You use micrpython when you have lots of horsepower It runs on a 2350.

2350 with PSRAM is more powerful than top of the line 1997 PC.
Post reply on HN