|
| 1 | +--- |
| 2 | +layout: post |
| 3 | +title: "mruby 2.0.0 released" |
| 4 | +date: 2018-12-11 00:00:00 |
| 5 | +categories: releases |
| 6 | +--- |
| 7 | + |
| 8 | +# mruby 2.0.0 |
| 9 | + |
| 10 | +We are proudly announcing the first stable release of mruby 2.0 series -- mruby 2.0.0. |
| 11 | + |
| 12 | +This release includes the improvement of Ruby2.x compatibility and memory consumption. |
| 13 | + |
| 14 | +--- |
| 15 | +## New Features |
| 16 | + |
| 17 | +### Core Language Features |
| 18 | + |
| 19 | +- Keyword Arguments Implemented (Ruby 2.0 Compatible) |
| 20 | +- Argument Deconstructing Implemented |
| 21 | + |
| 22 | +### Core Libraries |
| 23 | + |
| 24 | +#### mruby-kernel-ext |
| 25 | +- `Kernel#then` was added as `Kernel#yield_self` (Ruby 2.6 Compatible) |
| 26 | + |
| 27 | +#### mruby-array-ext |
| 28 | +- `Array#to_h` can be called with a block (Ruby 2.6 Compatible) |
| 29 | +- `Array#union` was added (Ruby 2.6 Compatible) |
| 30 | + |
| 31 | +#### mruby-string-ext |
| 32 | +- `String#lines` can be called with a block |
| 33 | +- The following methods are added |
| 34 | + `String#tr`, `String#tr!`, `String#tr_s`, `String#tr_s!`, `String#squeeze`, `String#squeeze!`, `String#count`, `String#delete`, `String#delete!` |
| 35 | + |
| 36 | +#### mruby-pack |
| 37 | +- `String#unpack1` was added |
| 38 | + |
| 39 | +#### mruby-metaprog |
| 40 | +Meta-programming features are separated as a mrbgem. You need to link `mruby-metaprog` to use meta-programming. (See `Breaking Changes` for more detail) |
| 41 | + |
| 42 | +#### mruby-sleep |
| 43 | +[matsumotory/mruby-sleep](https://github.com/matsumotory/mruby-sleep) was bundled as a core library. |
| 44 | +You can use `Kernel#sleep` and `Kernel#usleep` methods. |
| 45 | + |
| 46 | +### Tools |
| 47 | + |
| 48 | +#### mruby compiler (mrbc) |
| 49 | + |
| 50 | +- `--remove-lv` option was added |
| 51 | + By specifying `--remove-lv`, mrbc suppress the generation of local variable information to be used for debugging in the compiled binary. It reduces the size of compiled mruby binary and memory consumption when loaded. |
| 52 | + |
| 53 | +#### mruby interpreter (mruby) |
| 54 | + |
| 55 | +- `-d` option was added |
| 56 | + By specifying `-d`, mruby execute the script in the debugging mode ($DEBUG=true). |
| 57 | +- `-r` option was added |
| 58 | + By specifying `-r library`, mruby loads the specified library before the execution. |
| 59 | + |
| 60 | +#### interactive mruby (mirb) |
| 61 | + |
| 62 | +- `-d` option was added (Behaves as `mruby -d`) |
| 63 | +- `-r` option was added (Behaves as `mruby -r`) |
| 64 | + |
| 65 | + |
| 66 | +--- |
| 67 | +## Reducing Memory Consumption |
| 68 | + |
| 69 | +Several improvements were done in mruby 2.0.0 to reduce memory consumption: |
| 70 | + |
| 71 | +- Instance variables are stored in segmented lists |
| 72 | +- Hash implementation replaced from khash |
| 73 | +- `--remove-lv` option was added to mruby compiler(mrbc) |
| 74 | +- And smaller improvements including VM stack and call frames. |
| 75 | + |
| 76 | +--- |
| 77 | +## Breaking Changes |
| 78 | + |
| 79 | +There are two major breaking changes from mruby 1.4.1 |
| 80 | + |
| 81 | +### 1. Bytecode Overhauled |
| 82 | + |
| 83 | +VM instruction format has been completely changed. |
| 84 | +The fixed width instruction until mruby 1.4.1 was abandoned. We chose variable length bytecode instructions in mruby 2.0. You need to recompile everything for mruby 2.0. |
| 85 | + |
| 86 | +- Binary Format Version: `0005` |
| 87 | +- VM Version: `0002` |
| 88 | + |
| 89 | +### 2. Meta-programming features separated as mrbgem |
| 90 | + |
| 91 | +From the assumption that meta-programming features are not frequently used in embedded system development, we separated meta-programming features as a mebgem (`mruby-metaprog`). The following methods have moved to `mruby-metaprog` gem. |
| 92 | + |
| 93 | +- Kernel module |
| 94 | + global_variables, local_variables, singleton_class, instance_variables, instance_variables_defined?, instance_variable_get, instance_variable_set, methods, private_methods, public_methods, protected_methods, singleton_methods, define_singleton_methods, send |
| 95 | + |
| 96 | +- Module class |
| 97 | +class_variables, class_variables_defined?, class_variable_get, class_variable_set, remove_class_variable, included_modules, instance_methods, remove_method, method_removed, constants |
| 98 | + |
| 99 | +- Module class (Singleton Methods) |
| 100 | +constants, nesting |
| 101 | + |
| 102 | +--- |
| 103 | + |
| 104 | +We have done 378 commits to 156 files, 7,949 lines were added, 5,430 lines removed since mruby1.4.1. |
| 105 | +For more detail of the updates, see [Commit Log](https://github.com/mruby/mruby/compare/1.4.1...2.0.0). |
| 106 | + |
| 107 | +## Evaluated mrbgems list (NPO mruby forum) |
| 108 | + |
| 109 | +[See the list](http://forum.mruby.org/download/index2EN.html). |
| 110 | + |
| 111 | + |
0 commit comments