{"id":13608291,"url":"https://github.com/berry-lang/berry","last_synced_at":"2025-05-14T23:07:55.935Z","repository":{"id":36986153,"uuid":"157044434","full_name":"berry-lang/berry","owner":"berry-lang","description":"A ultra-lightweight embedded scripting language optimized for microcontrollers.","archived":false,"fork":false,"pushed_at":"2025-05-06T03:17:40.000Z","size":1990,"stargazers_count":867,"open_issues_count":13,"forks_count":101,"subscribers_count":30,"default_branch":"master","last_synced_at":"2025-05-10T12:15:15.608Z","etag":null,"topics":["berry","c","embedded","language","microcontroller","scripting-language"],"latest_commit_sha":null,"homepage":"https://berry-lang.github.io","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/berry-lang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-11-11T03:38:12.000Z","updated_at":"2025-05-09T15:50:40.000Z","dependencies_parsed_at":"2023-01-17T11:32:10.826Z","dependency_job_id":"913435b3-5f22-424f-a6a1-f77b0fb91348","html_url":"https://github.com/berry-lang/berry","commit_stats":{"total_commits":805,"total_committers":26,"mean_commits":30.96153846153846,"dds":0.577639751552795,"last_synced_commit":"23c6576e5e428415c8e83ab8a43aa39c7af811a5"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/berry-lang%2Fberry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/berry-lang%2Fberry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/berry-lang%2Fberry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/berry-lang%2Fberry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/berry-lang","download_url":"https://codeload.github.com/berry-lang/berry/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254243362,"owners_count":22038046,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["berry","c","embedded","language","microcontroller","scripting-language"],"created_at":"2024-08-01T19:01:26.032Z","updated_at":"2025-05-14T23:07:50.924Z","avatar_url":"https://github.com/berry-lang.png","language":"C","funding_links":[],"categories":["Uncategorized","C"],"sub_categories":["Uncategorized"],"readme":"\u003cp align=\"center\"\u003e\n  \u003ch1 align=\"center\"\u003e\n    \u003cimg src=\"https://gitee.com/mirrors/Berry/raw/master/berry-logo.png\" alt=\"Berry\" width=272 height=128\u003e\n  \u003c/h1\u003e\n  \u003cp align=\"center\"\u003eThe Berry Script Language.\u003c/p\u003e\n\u003c/p\u003e\n\n## Introduction\n\nBerry is a ultra-lightweight dynamically typed embedded scripting language. It is designed for lower-performance embedded devices. The Berry interpreter-core's code size is less than 40KiB and can run on less than 4KiB heap (on ARM Cortex M4 CPU, Thumb ISA and ARMCC compiler).\n\nThe interpreter of Berry include a one-pass compiler and register-based VM, all the code is written in ANSI C99. In Berry not every type is a class object. Some simple value types, such as int, real, boolean and string are not class object, but list, map and range are class object. This is a consideration about performance. \nRegister-based VM is the same meaning as above.\n\nBerry has the following advantages:\n\n* Lightweight: A well-optimized interpreter with very little resources. Ideal for use in microprocessors.\n* Fast: optimized one-pass bytecode compiler and register-based virtual machine.\n* Powerful: supports imperative programming, object-oriented programming, functional programming.\n* Flexible: Berry is a dynamic type script, and it's intended for embedding in applications. It can provide good dynamic scalability for the host system.\n* Simple: simple and natural syntax, support garbage collection, and easy to use FFI (foreign function interface).\n* RAM saving: With compile-time object construction, most of the constant objects are stored in read-only code data segments, so the RAM usage of the interpreter is very low when it starts.\n\n## Documents\n\nReference Manual: [Read the docs](https://berry.readthedocs.io/)\n\nShort Manual: [berry_short_manual.pdf](https://github.com/berry-lang/berry_doc/blob/master/pdf/berry_short_manual.pdf).\n\nBerry's EBNF grammar definition: [tools/grammar/berry.ebnf](./tools/grammar/berry.ebnf)\n\n## Features\n\n* Base Type\n  * Nil: `nil`\n  * Boolean: `true` and `false`\n  * Numerical: Integer (`int`) and Real (`real`)\n  * String: Single quotation-mark string and double quotation-mark string\n  * Class: Instance template, read only\n  * Instance: Object constructed by class\n  * Module: Read-write key-value pair table\n  * List: Ordered container, like `[1, 2, 3]`\n  * Map: Hash Map container, like `{ 'a': 1, 2: 3, 'map': {} }`\n  * Range: include a lower and a upper integer value, like `0..5`\n* Operator and Expression\n  * Assign operator: `=`, `+=`, `-=`, `*=`, `/=`, `%=`, `\u0026=`, `|=`, `^=`, `\u003c\u003c=`, `\u003e\u003e=`\n  * Relational operator: `\u003c`, `\u003c=`, `==`, `!=`, `\u003e`, `\u003e=`\n  * Logic operator: `\u0026\u0026`, `||`, `!`\n  * Arithmetic operator: `+`, `-`, `*`, `/`, `%`\n  * Bitwise operator: `\u0026`, `|`, `~`, `^`, `\u003c\u003c`, `\u003e\u003e`\n  * Field operator: `.`\n  * Subscript operator: `[]`\n  * Connect string operator: `+`\n  * Conditional operator: `? :`\n  * Brackets: `()`\n* Control Structure\n  * Conditional statement: `if-else`\n  * Iteration statement: `while` and `for`\n  * Jump statement: `break` and `continue`\n* Function\n  * Local variable and block scope\n  * Return statement\n  * Nested functions definition\n  * Closure based on Upvalue\n  * Anonymous function\n  * Lambda expression\n* Class\n  * Inheritance (only public single inheritance)\n  * Method and Operator Overload\n  * Constructor method\n  * Destructive method\n* Module Management\n  * Built-in module that takes almost no RAM\n  * Extension module support: script module, bytecode file module and shared library (like *.so, *.dll) module\n* GC (Garbage collection)\n  * Mark-Sweep GC\n* Exceptional Handling\n  * Throw any exception value using the `raise` statement\n  * Multiple catch mode\n* Bytecode file support\n  * Export function to bytecode file\n  * Load the bytecode file and execute\n\n## Build and Run\n\n1. Install the readline library (Windows does not need):\n\n   ``` bash\n   sudo apt install libreadline-dev # Ubuntu\n   brew install readline            # MacOS\n   ```\n\n2. Build (The default compiler is GCC):\n\n   ```\n   make\n   ```\n\n3. Run:\n\n   ``` bash\n   ./berry # Bash or PowerShell\n   berry   # Windows CMD\n   ```\n\n4. Install (Only Unix-like):\n\n   ``` bash\n   make install\n   ```\n\n## Editor plugins\n\n[Visual Studio Code](https://code.visualstudio.com/) plugin are in this directory: [./tools/plugins/vscode](./tools/plugins/vscode).\n\n## Examples\n\nAfter compiling successfully, use the `berry` command with no parameters to enter the REPL environment:\n```\nBerry 0.0.1 (build in Dec 24 2018, 18:12:49)\n[GCC 8.2.0] on Linux (default)\n\u003e\n```\n\nNow enter this code:\n\n``` lua\nprint(\"Hello world!\")\n```\n\nYou will see this output:\n\n```\nHello world!\n```\n\nYou can copy this code to the REPL:\n\n``` ruby\ndef fib(x)\n    if x \u003c= 1\n        return x\n    end\n    return fib(x - 1) + fib(x - 2)\nend\nfib(10)\n```\n\nThis example code will output the result `55` and you can save the above code to a plain text file (eg test.be) and run this command:\n\n``` bash\n./berry test.be\n```\n\nThis will also get the correct output.\n\n## License\n\nBerry is free software distributed under the [MIT license](./LICENSE).\n\nThe Berry interpreter partly referred to [Lua](http://www.lua.org/)'s design. View Lua's license here: http://www.lua.org/license.html.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fberry-lang%2Fberry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fberry-lang%2Fberry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fberry-lang%2Fberry/lists"}