|
| 1 | +--- |
| 2 | +layout: post |
| 3 | +title: "mruby 3.0.0 released" |
| 4 | +date: 2021-03-05 00:00:00 |
| 5 | +categories: releases |
| 6 | +--- |
| 7 | + |
| 8 | +# mruby 3.0.0 |
| 9 | + |
| 10 | +We are announcing the first stable release of mruby 3.0 series - [mruby 3.0.0](https://github.com/mruby/mruby/releases/tag/3.0.0). |
| 11 | + |
| 12 | +With mruby 3.0, the memory used of the mruby VM has been significantly reduced, and we have succeeded in significantly saving memory. |
| 13 | +Previous versions required several hundred KB of RAM, but mruby 3.0 can launch an application with about 100 KB of RAM. |
| 14 | + |
| 15 | +Describes the new features and changes in mruby 3.0. |
| 16 | +The main changes in mruby 3.0 are also described in [doc/mruby3.md](https://github.com/mruby/mruby/blob/master/doc/mruby3.md). |
| 17 | + |
| 18 | +--- |
| 19 | + |
| 20 | +# New Features |
| 21 | + |
| 22 | +## Core Language Features |
| 23 | + |
| 24 | +- Implement endless-def. [Ruby:Feature#16746](https://bugs.ruby-lang.org/issues/16746) |
| 25 | +- Replace `R-assignment` by `single-line pattern matching`. [Ruby:Feature#15921](https://bugs.ruby-lang.org/issues/15921) |
| 26 | +- Support squiggly heredocs. [#5246](https://github.com/mruby/mruby/pull/5246) |
| 27 | + |
| 28 | +## Features for mruby Developer |
| 29 | + |
| 30 | +- Add new C APIs |
| 31 | + - `mrbc_cleanup_local_variables()` - Clean up local variables on mrbc_context. [#4931](https://github.com/mruby/mruby/pull/4931) |
| 32 | + - Add functions that take symbols as arguments. |
| 33 | + - `mrb_define_singleton_method_id()` |
| 34 | + - `mrb_define_class_method_id()` |
| 35 | + - `mrb_define_module_function_id()` |
| 36 | + - `mrb_undef_method_id()` |
| 37 | + - `mrb_undef_class_method_id()` |
| 38 | + - `mrb_define_const_id()` |
| 39 | + - `mrb_funcall_id()` |
| 40 | + - Add functions for symbol checking that return mrb_sym value. |
| 41 | + - `mrb_intern_check()` |
| 42 | + - `mrb_intern_check_cstr()` |
| 43 | + - `mrb_intern_check_str()` |
| 44 | + - `mrb_fiber_resume()` - Allow context switch from C module. |
| 45 | + |
| 46 | +--- |
| 47 | + |
| 48 | +# Update Features |
| 49 | + |
| 50 | +## Reduce memory usage |
| 51 | + |
| 52 | +- Preallocate Symbols |
| 53 | + The mruby 3.0 can now significantly reduce RAM usage by allocating symbols to static memory area at compile time. See [doc/guides/symbol.md](https://github.com/mruby/mruby/blob/master/doc/guides/symbol.md) for more information. |
| 54 | +- Reduce memory usage of Hash objects. [f2d8db39](https://github.com/mruby/mruby/commit/f2d8db39) |
| 55 | +- Reduce memory usage when calling methods. [#5272](https://github.com/mruby/mruby/pull/5272) |
| 56 | + |
| 57 | +## Updated build process |
| 58 | + |
| 59 | +The old build configuration file `build_config.rb` has been reconfigured to a file in the `build_config` directory. |
| 60 | +For example, the following typical build configuration is available. |
| 61 | + |
| 62 | +- `default`: the default configuration |
| 63 | +- `host-gprof`: compiles with `gprof` for performance tuning |
| 64 | +- `host-m32`: compiles in gcc 32bit mode on 64bit platforms |
| 65 | +- `boxing`: compiles all three boxing options |
| 66 | +- `clang-asan`: compiles with clang's Address Sanitizer |
| 67 | + |
| 68 | +You can specify the mruby build configuration by building mruby with the `rake` build, specifying the build configuration file in the environment variable `MRUBY_CONFIG`. |
| 69 | + |
| 70 | +## Core Libraries |
| 71 | + |
| 72 | +- Add new libraries. |
| 73 | + - `mruby-catch` - Support `Kernel.#catch` and `Kernel.#throw`. [7eaaee54](https://github.com/mruby/mruby/commit/7eaaee54) |
| 74 | + - `mruby-os-memsize` - Support `ObjectSpace.memsize_of` and `ObjectSpace.memsize_of_all`. [#5032](https://github.com/mruby/mruby/pull/5032) [#5040](https://github.com/mruby/mruby/pull/5040) [#5041](https://github.com/mruby/mruby/pull/5041) |
| 75 | +- Add `Array.new([])` initialization. (mruby-array) |
| 76 | +- Add `Hash#except` (mruby-hash-ext) |
| 77 | +- Update `IO#popen` to use keyword arguments. (mruby-io) |
| 78 | +- Make `Module#include` and `Module#prepend` behave like Ruby 3.0. [3972df57](https://github.com/mruby/mruby/commit/3972df57) |
| 79 | + |
| 80 | +## Tools |
| 81 | + |
| 82 | +- Allow to mixed and specify `*.rb` and `*.mrb` in `mruby` interpreter. [a045b6b8](https://github.com/mruby/mruby/commit/a045b6b8) |
| 83 | +- Add `irep` C struct dump from `mrbc` with `-S` option. |
| 84 | + |
| 85 | +## Features for mruby Developer |
| 86 | + |
| 87 | +- Add new specifier `c` to `mrb_get_args()` for receive Class/Module. |
| 88 | + |
| 89 | +--- |
| 90 | + |
| 91 | +# Breaking Changes |
| 92 | + |
| 93 | +## mruby VM and bytecode |
| 94 | + |
| 95 | +Due to improvements in the binary format, mruby binaries are no longer backward compatible. |
| 96 | +To run the mruby binaries on mruby 3.0, recompile with the mruby 3.0 `mrbc`. |
| 97 | + |
| 98 | +- Upgrade mruby VM version `RITE_VM_VER` to `0300` (means mruby 3.0). |
| 99 | +- Upgrade mruby binary version `RITE_BINARY_FORMAT_VER` to `0200`. |
| 100 | + |
| 101 | +## Recognize Integer system |
| 102 | + |
| 103 | +`Integer` has been changed to a specification similar to CRuby. |
| 104 | + |
| 105 | +- Integrate `Finxnum` and `Integer`. |
| 106 | +- Remove `Integral`. |
| 107 | +- `int / int -> int` |
| 108 | +- Add APIs for `Integer`. APIs for`Fixnum` (`mrb_fixnum_xxx()`) is also left for compatibility. |
| 109 | + - `mrb_fixnum()` -> `mrb_integer()` |
| 110 | + - `mrb_fixnum_value()` -> `mrb_int_value()` |
| 111 | + - `mrb_fixnum_p()` -> `mrb_integer_p()` |
| 112 | + |
| 113 | +--- |
| 114 | + |
| 115 | +# Major bug fixes |
| 116 | + |
| 117 | +- Fix take over file scope variables with `mruby` and `mirb` command. [#4933](https://github.com/mruby/mruby/issues/4933) |
| 118 | +- Fix performing `block_given?` from inside an orphan block always returns false. [#5039](https://github.com/mruby/mruby/issues/5039) |
| 119 | +- Fix segmentation fault in Mruby interpreter making it crash [#5046](https://github.com/mruby/mruby/issues/5046) |
| 120 | +- Fix splat operator to frozen Array raises FrozenError. [#5067](https://github.com/mruby/mruby/issues/5067) |
| 121 | +- Fix wrong behavior of File.extname when the filename starts or ends with a period. (mruby-io) [#5077](https://github.com/mruby/mruby/issues/5077) |
| 122 | +- Fix #parameters mistakes keyword "splat" for a block parameter. [#5066](https://github.com/mruby/mruby/issues/5066) |
| 123 | +- Fix mruby-io doesn't work in processes started as Windows service. [#5114](https://github.com/mruby/mruby/issues/5114) |
| 124 | +- Fix resuming fiber from C seems to loop infinitely. [#5261](https://github.com/mruby/mruby/issues/5261) |
| 125 | +- Fix invalid UTF-8 string length. [#5269](https://github.com/mruby/mruby/issues/5269) |
| 126 | +- Fix avoid syntax error when EXPR_MID appears in conditional operator. [#5290](https://github.com/mruby/mruby/issues/5290) |
| 127 | +- Fix symbols like numbered parameters in blocks get a syntax error. [#5295](https://github.com/mruby/mruby/issues/5295) |
| 128 | +- Avoid infinite loops when converting objects to strings. [01a8d849](https://github.com/mruby/mruby/commit/01a8d849) |
| 129 | +- Fix module order of `#include`. [ruby-bug:7844](https://bugs.ruby-lang.org/issues/7844) |
| 130 | + |
| 131 | +--- |
| 132 | + |
| 133 | +We have done 983 commits to 274 files with 16,929 additions and 11,685 deletions since mruby 2.1.2. For more detail of the updates, [see Commit Log](https://github.com/mruby/mruby/compare/2.1.2...3.0.0). |
| 134 | + |
| 135 | +Thanks to all the contributors who have worked on bug fixes and improvements in the release of `mruby 3.0.0`. |
0 commit comments