Berry Script: lightweight embedded scripting language for microcontrollers
14 comments
·July 5, 202590s_dev
90s_dev
Oh, they say it was inspired by Lua. So it's more like Wren I guess, but probably less performant than Wren too[1]. And less powerful than Lua since Lua metatables are half magic half genius. Still, I'd like to see a benchmark like this.
floitsch
A similar project: https://toitlang.org (or https://toit.io).
Currently it's only targeting the ESP32 family, but the code is pretty portable. By default, it probably also needs more resources due to OS-like abstractions, allowing for multiple containers to run on parallel, etc. Obviously that also brings some nice advantages. For example, installing or updating, a new container is just a few lines of code.
We have been working on it for more than 5 years now, and it's definitely at a stage where lots of projects would benefit from it.
ost-ing
Embedded Rust alternative: https://github.com/rhaiscript/rhai
sagacity
Doesn't seem to have received any updates in the last 2 years. I'm wondering what the use cases are for this type of scripting in embedded systems, though?
elitepleb
Running arbitrary user code in IOT systems safely like https://tasmota.github.io/docs/Berry/#rules
It's still receiving maintenance from contributors, but these sort projects reach a stable maturity and stay there for years fulfilling their use case.
middayc
One benefit can be more interactive development, or interaction with the embedded device. I think various forths were used on embedded systems also because of that.
And some projects just don't require much speed and benefit from a higher level lanuage. Reading a couple of sensors over I2C every few seconds, doing some "business logic" and serving data via a http server over wifi can be simpler to achieve in higher level language and the device will be idle for the most of the time anyway.
Micropython is a nice solution in that niche.
But for some projects you do want a lower level language if not for else maybe for lower battery consumption.
iainmerrick
Interpreted languages can be great for small code size too. Forth is especially good as it doesn't need a big runtime and the language lends itself really well to code reuse.
ethan_smith
The repo has active development with commits from March 2025, and scripting languages like Berry enable rapid prototyping, runtime configuration changes, and user customization without reflashing firmware.
imtringued
If you have an embedded system with a screen, say a 3d printer, it's probably nicer to write the UI in JavaScript than C.
However, now that I look at the syntax, Berry Script doesn't really look like a well designed language to me. It's like a weird mix of Lua, Python and Javascript. It's a very backwards looking (as in, it is emulating the past rather than innovating) language, where a lot of the differences only exist for the sake of being different and the more I read through the docs the more I think it looks like a bastardized Python and that I'd rather use MicroPython instead.
aa-jv
I don't use Berry (although its quite interesting), but I do use Lua in this context, and I find that putting a lot of embedded-application logic into a script is very productive - especially in the case where the VM is running and is passed a validated bytecode stream. This is quite an effective way of building sophisticated applications with embedded targets.
Alifatisk
Reminds me a lot of Ruby! Gorgeous.
abdellah123
why not use Moddable's [1] xs engine [2]? it's JavaScript ...
[1] https://www.moddable.com/ [2] https://github.com/Moddable-OpenSource/moddable/tree/public/...
abdellah123
and it's the most conformant implementation to the latest specs of ECMAScript + of the ECMA-419 spec for js in iot
This seems to have almost the exact same feature set and use-case as Lua. How does it compare in performance? I doubt it can be faster than Lua 5.5