Live data from Hacker News

Show HN: MicroLua – Lua for the RP2040 Microcontroller

github.com

11–20 of 35 posts

Re: Show HN: MicroLua – Lua for the RP2040 Microcontroller

#11
OpenWRT's LuCI WebUI, Torch ML, and embedded interpreters in game engines are also written in Lua.

Apache Arrow's C GLib implementation works with Lua. From https://news.ycombinator.com/item?id=38103326 :

> Apache Arrow already supports C, C++, Python, Rust, Go and has C GLib support Lua: https://github.com/apache/arrow/tree/main/c_glib/example/lua

LearnXinYminutes Lua: https://learnxinyminutes.com/docs/lua/

OpenWRT is a Make-based Linux distro for embedded devices with limited RAM and flash ROM, x86, and docker. OpenWRT is built on `uci` (and procd and ubusd instead of systemd and dbus). UCI is an /etc/config/* dotted.key=value configuration system which procd sys-v /etc/init.d/* scripts read values in from when regenerating their configuration when $1 is e.g. 'start', 'restart', or 'reload' per sys-v. LuCI is the OpenWRT web UI which is written in Lua; which is now implemented mostly as a JSON-RPC API instead of with server-side HTML templates for usability and performance on embedded devices.

Notes on how to write a LuCI app in Lua: https://github.com/x-wrt/luci/commit/73cda4f4a0115bb05bbd3d1...

applications/luci-app-example: https://github.com/openwrt/luci/tree/master/applications/luc...

openwrt/luci//docs: https://github.com/openwrt/luci/tree/master/docs

https://openwrt.org/supported_devices

It's probably impossible to build OpenWRT (and opkg packages) for an RP2040W.

Re: Show HN: MicroLua – Lua for the RP2040 Microcontroller

#14
Does Lua have primitive arrays now? When I looked at it some years ago, it seemed to support only hash maps, and arrays were emulated using hash maps, which I found to be completely bizarre. There were discussions online where Lua folks were saying, no, you don't really need arrays. And I'm thinking to myself, hell yeah, I really needs arrays on resource-constrained microcontroller systems without garage collection.

Re: Show HN: MicroLua – Lua for the RP2040 Microcontroller

#15
post #14

Does Lua have primitive arrays now? When I looked at it some years ago, it seemed to support only hash maps, and arrays were emulated using hash maps, which I found to be completely bizarre. There were discussions online where Lua folks were saying, no, you don't really need arrays. And I'm thinking to myself, hell yeah, I really needs arrays on resource-constrained microcontroller systems without garage collection.

If a table is contiguously indexed by integers from 1, the storage is optimized into an array.

Re: Show HN: MicroLua – Lua for the RP2040 Microcontroller

#16
post #14

Does Lua have primitive arrays now? When I looked at it some years ago, it seemed to support only hash maps, and arrays were emulated using hash maps, which I found to be completely bizarre. There were discussions online where Lua folks were saying, no, you don't really need arrays. And I'm thinking to myself, hell yeah, I really needs arrays on resource-constrained microcontroller systems without garage collection.

Yeah, tables serve as both lists and maps. You can even have a table with _both_.

Re: Show HN: MicroLua – Lua for the RP2040 Microcontroller

#18

I can't get my head around a 1 based language.

It helps if you realize that there are no arrays in Lua. Instead, everything is an optimized hash map that can be indexed by any value of any type. A single table can have some elements indexed by integers, others indexed by strings, function pointers (useful for a table of debug hooks), etc.

The few convenient things that expect tables to be indexed using integers starting at 1 are the # operator to get the number of elements, and the ipairs function, used in the common idiom “for index, value in ipairs(t) do . . . end”.

Re: Show HN: MicroLua – Lua for the RP2040 Microcontroller

#20

OpenWRT's LuCI WebUI, Torch ML, and embedded interpreters in game engines are also written in Lua. Apache Arrow's C GLib implementation works with Lua. From https://news.ycombinator.com/item?id=38103326 : > Apache Arrow already supports C, C++, Python, Rust, Go and has C GLib support Lua: https://github.com/apache/arrow/tree/main/c_glib/example/lua LearnXinYminutes Lua: https://learnxinyminutes.com/docs/lua/ OpenWRT…

Yes, it's impossible (i'm dev on OpenWRT) because it build toolchain first then, Linux kernel, drives and userland apps.
Post reply on HN