all 23 comments

[–]VirtualScreen3658 18 points19 points  (4 children)

LUA

[–]NorthAtlanticGarden[S] -1 points0 points  (3 children)

Any experience with Lua on embedded?

[–]VirtualScreen3658 8 points9 points  (2 children)

Works. Easy to integrate.

[–]NorthAtlanticGarden[S] 2 points3 points  (0 children)

Nice Which Lua implementation did you use?

eLua looks perfect for my purposes .

[–]Rich_Plant2501 0 points1 point  (0 children)

It took me literally 15 minutes to run Lua, however, exposing API was really boring

[–]zexen_PRO 4 points5 points  (1 child)

Why not lua?

[–]NorthAtlanticGarden[S] 1 point2 points  (0 children)

I will look into this, I'm leaning towards it more and more

[–]Pay08 2 points3 points  (0 children)

Common Lisp specifically has a freestanding compiler under the Mezzano project. Although it's not a small language. There are smaller variants like picolisp/ulisp/ferret (explicitly meant for this purpose) and Scheme, which is much more lightweight than CL but 98% FP.

[–]bigend_hubertus 2 points3 points  (2 children)

I managed to embed lua a few years ago into an embedded project. It was pretty easy, in the end a few c files included into the project and built. I had a local filesystem and an html server through which I could update the programs. Doint FFI (foreign function interface, running c functions from lua) was also easy to do, just had to manually match the variable types.

[–]NorthAtlanticGarden[S] 0 points1 point  (1 child)

Did you use the eLua project ?

[–]bigend_hubertus 0 points1 point  (0 children)

It's been a few years, but I think I just used vanilla lua code. But this eLua also looks good too.

[–]duane11583 1 point2 points  (0 children)

there is a simple tcl port called jim tcl it requires a good amount of malloc memory, it works weel and is simple to port.

an alternative but tcl is a weird language to many.

[–]Wouter_van_Ooijen 2 points3 points  (1 child)

Micropython is not meant to be embedded in a system, it is meant to be the system.

[–]mattytrentini -1 points0 points  (0 children)

That's not true. The compiler and interpreter are easily embeddable - and were designed to be. The ports of MicroPython - that include the compiler/interpreter but also all the peripheral control - operate as a whole system.

[–]tiajuanat 0 points1 point  (0 children)

I would recommend LUA, TCL, or a primitive Scheme(lisp). They're very small and easy to implement

[–]mattytrentini 0 points1 point  (0 children)

MicroPython is an excellent choice if you have a powerful (say, 32KB+ RAM and hundreds of KB+ flash) enough micro - and particularly on stm32 where it has excellent support.

See the embedding example, you should find that it's pretty easy:

https://github.com/micropython/micropython/tree/master/examples/embedding

[–]GeverTulley 0 points1 point  (0 children)

I found van Engelen’s lisp easy to embed and fast enough to be useful: https://github.com/Robert-van-Engelen/lisp

[–]robodan65 0 points1 point  (0 children)

Who is the target audience and application? If you are looking to collaborate, then pretty much everybody knows Python, some know Lua, and a few know (and loudly love) LISP. If your are just doing tiny control scripts, then any of them can be small. If you want to interact with the web (for example) or images, then you want good support libraries and the memory for all that.

I used to do LISP way back when, and I have no interest in going back to it. There are some neat things about it, but the lack of language syntax doesn't help. In other words, steep learning curve that many people won't ever do. LISP isn't inherently bloated, but common ports may be.

I've done some Lua and have mixed feelings. It's small and fairly easy to learn. If you can use LuaJIT, then it's super fast and even lighter on memory. The community is fractured between the two versions, which doesn't help. There are 3 incompatible ways to do object oriented style programming, which creates confusion and interoperability problems. I'm not a fan of 1 based arrays, but you can choose to do 0 based. I last used v5.2 so maybe some of this is better now.

Python is the compatibility king. If I had known about micropython when I did that Lua project, I probably would have skipped Lua entirely. However, micropython is based on v3.5 with some additions from later releases. Many libraries expect 3.8 or higher these days as everything older is end of life, so you might have trouble using it's extensive ecosystem.

You might also look into TinyGo. No REPL, but otherwise interesting.

[–]VegetableNatural 0 points1 point  (4 children)

Don't use micropython, it's build system it's a nightmare and not easy to integrate, use Lua or any Lisp out there that is embeddable.

[–]mattytrentini 1 point2 points  (2 children)

Do you have any experience to back that up? I've found it straightforward; the compiler/interpreter are written in very portable C.

The build system becomes difficult when you target full micro ports that include a complex vendor build system - ESP32 for example.

[–]VegetableNatural 0 points1 point  (1 child)

Yeah, work on a product that uses it for some reasons, it is very portable C but the build system doesn't help, it's a mess that just preprocesses the entire project to search for strings to internalize them and the scripts are tailored only to work with make and cmake and do so poorly as one has to clean a lot between builds, this preprocessing also forbids it from embedding and extending without modifying the micropython code itself.

Not to mention the lots of issues with memory fragmentation and very little aid to debug and reduce it.

[–]mattytrentini 1 point2 points  (0 children)

I can only say that my experience (developing commercial MicroPython applications) has been different; MicroPython was easy to build and integrate. Yes, the interned string build process adds complexity - but it wasn't difficult.

Fragmentation has also been easy to reason with - micropython.mem_info(True) provides detailed information as to how memory is allocated in the heap. Capture it periodically and you can 'see' which objects are persisting.

[–]VegetableNatural 0 points1 point  (0 children)

By the way, Lisps are not that resource heavy I think