mruby:嵌入式系统的 Ruby
Mruby: Ruby for Embedded Systems

原始链接: https://github.com/mruby/mruby

mruby是Ruby语言的一个轻量级实现,与Ruby 3.x版本高度兼容(不包括模式匹配),设计用于嵌入到应用程序中。它包括一个解释器(mruby)、交互式shell(mirb)和一个字节码编译器(mrbc)。字节码可以直接编译成C源代码文件以进行进一步集成。 mruby可通过GitHub(https://github.com/mruby/mruby)获取,并可通过诸如`ruby-install`之类的工具安装。由于其宽松的MIT许可证,mruby为各种环境(特别是嵌入式系统)提供了灵活性。 mruby具有一个名为`mrbgems`的包管理器,用于用C和Ruby创建扩展。mruby和C API都有文档。欢迎通过pull request贡献代码,并遵守项目指南。所有内容均采用MIT许可,贡献者保留版权,同时授予非独占权利。出于简化起见,该项目通常使用“mruby developers”作为版权名称。

## mruby:轻量级 Ruby 用于嵌入 这次黑客新闻讨论的中心是 **mruby**,它是 Ruby 编程语言的一个轻量级实现,设计用于嵌入到其他应用程序中,而不是像标准 Ruby (MRI) 那样作为一个独立的系统。 用户将 mruby 与 **Lua** 进行比较,Lua 是一种流行的脚本语言,常用于嵌入式系统和游戏开发。虽然有些人认为 mruby 是一种更简洁的语言,但 Lua 因其更强大的实现和更广泛的应用而受到赞扬,尤其是在日本以外。 一个主要的争论点是 **mruby 的嵌入 API**,它被认为比 Lua 的更复杂且文档记录较差。用户强调了 C API 的困难、缺乏清晰的文档(“阅读头文件”)以及手动内存管理的要求。 尽管存在这些挑战,mruby 仍然在一些利基领域找到了用武之地,例如在 **DragonRuby 游戏引擎**中,甚至用于在 **Dreamcast** 上开发游戏。它能够编译成单个自包含文件也是一个重要的分发优势。 讨论还涉及 Ruby 生态系统的整体状况及其未来。
相关文章

原文

mruby is the lightweight implementation of the Ruby language complying to (part of) the ISO standard with more recent features provided by Ruby 3.x. Also, its syntax is Ruby 3.x compatible except for pattern matching.

You can link and embed mruby within your application. The "mruby" interpreter program and the interactive "mirb" shell are provided as examples. You can also compile Ruby programs into compiled byte code using the "mrbc" compiler. All these tools are located in the "bin" directory. "mrbc" can also generate compiled byte code in a C source file. See the "mrbtest" program under the "test" directory for an example.

This achievement was sponsored by the Regional Innovation Creation R&D Programs of the Ministry of Economy, Trade and Industry of Japan.

To get mruby, you can download the stable version 3.4.0 from the official mruby GitHub repository or clone the trunk of the mruby source tree with the "git clone" command. You can also install and compile mruby using ruby-install, ruby-build or rvm.

The latest development version of mruby can be downloaded via the following URL: https://github.com/mruby/mruby/zipball/master

The trunk of the mruby source tree can be checked out with the following command:

$ git clone https://github.com/mruby/mruby.git

The URL of the mruby homepage is: https://mruby.org.

We don't have a mailing list, but you can use GitHub issues.

How to compile, test, and install (mruby and gems)

For the simplest case, type

See the compile.md file for the detail.

There are two sets of documentation in mruby: the mruby API (generated by YARD) and C API (Doxygen and Graphviz)

To build both of them, simply go

You can also view them in your browser

rake view_api
rake view_capi

How to customize mruby (mrbgems)

mruby contains a package manager called "mrbgems" that you can use to create extensions in C and/or Ruby. For a guide on how to use mrbgems, consult the mrbgems.md file, and for example code, refer to the examples/mrbgems/ folder.

mruby is released under the MIT License.

mruby has chosen a MIT License due to its permissive license allowing developers to target various environments such as embedded systems. However, the license requires the display of the copyright notice and license information in manuals for instance. Doing so for big projects can be complicated or troublesome. This is why mruby has decided to display "mruby developers" as the copyright name to make it simple conventionally. In the future, mruby might ask you to distribute your new code (that you will commit,) under the MIT License as a member of "mruby developers" but contributors will keep their copyright. (We did not intend for contributors to transfer or waive their copyrights, actual copyright holder name (contributors) will be listed in the AUTHORS file.)

Please ask us if you want to distribute your code under another license.

To contribute to mruby, please refer to the contribution guidelines and send a pull request to the mruby GitHub repository. By contributing, you grant non-exclusive rights to your code under the MIT License.

mruby Star History

mruby Contributors

联系我们 contact @ memedata.com