berry-lang/berry logo

berry-lang/berry

Free

A ultra-lightweight embedded scripting language optimized for microcontrollers.

FreeFree tier
Type
Open Source

About berry-lang/berry

Berry is an ultra-lightweight dynamically typed embedded scripting language designed for lower-performance microcontrollers. The interpreter core is less than 40KiB in code size and can run on less than 4KiB of heap memory (on ARM Cortex M4 with Thumb ISA and ARMCC compiler). It features a one-pass bytecode compiler and a register-based virtual machine, all written in ANSI C99. Berry supports imperative, object-oriented, and functional programming paradigms, includes garbage collection, and provides an easy-to-use foreign function interface (FFI). It is optimized for RAM savings by storing constant objects in read-only code data segments. The language offers base types such as nil, boolean, integer, real, string, class, instance, module, list, map, and range, along with control structures, functions, closures, lambda expressions, and single inheritance classes.

Key Features

Ultra-lightweight: interpreter core <40KiB and runs on <4KiB heap
Fast one-pass bytecode compiler and register-based virtual machine
Supports imperative, object-oriented, and functional programming
Dynamic typing with base types: nil, boolean, integer, real, string, class, instance, module, list, map, range
Garbage collection (GC) integrated
Easy-to-use foreign function interface (FFI) for embedding
RAM saving via compile-time object construction in read-only data segments
Single inheritance class system with method and operator overloading
Module management: built-in modules, script modules, bytecode files, and shared libraries
Closures and lambda expressions based on upvalues

Pros & Cons

Pros
  • Extremely small memory footprint suitable for microcontrollers
  • Fast execution with optimized compiler and register-based VM
  • Flexible multi-paradigm language (imperative, OOP, functional)
  • Easy to embed in existing C applications via clean FFI
  • RAM efficient due to compile-time constant object storage
  • Simple syntax and good documentation available
Cons
  • Niche focus on embedded systems; not suitable for general-purpose application development
  • Limited ecosystem and third-party libraries compared to mainstream languages
  • Small community and fewer resources for learning and troubleshooting
  • Performance and feature trade-offs due to minimalistic design

Best For

Embedded systems programming on microcontrollersIoT devices with constrained resourcesScripting in low-power or battery-operated devicesProviding dynamic extensibility to host applicationsEducation and prototyping on resource-limited hardware

FAQ

What is Berry?
Berry is an ultra-lightweight dynamically typed embedded scripting language designed for microcontrollers and low-performance embedded devices.
What are the main advantages of Berry?
Berry is very lightweight (interpreter core <40KiB, heap <4KiB), fast (one-pass compiler, register-based VM), powerful (supports imperative/OOP/functional programming), flexible (dynamic typing, easy FFI), simple syntax, and RAM saving (constant objects stored in read-only segments).
On what platforms can Berry run?
Berry is designed for lower-performance embedded devices, such as ARM Cortex M4 microcontrollers. It is written in ANSI C99 and can be compiled for any platform with a C99 compiler.
What programming paradigms does Berry support?
Berry supports imperative programming, object-oriented programming (via classes and single inheritance), and functional programming (closures, lambda expressions).
Is Berry open-source?
Yes, Berry is open-source and hosted on GitHub under the berry-lang/berry repository.