Posted by naruse on 25 Dec 2021
We are pleased to announce the release of Ruby 3.1.0. Ruby 3.1 keeps compatibility with Ruby 3.0 and also adds many features.
YJIT: New experimental in-process JIT compilerRuby 3.1 merges YJIT, a new in-process JIT compiler developed by Shopify.
Since Ruby 2.6 introduced MJIT in 2018, its performance greatly improved, and finally we achieved Ruby3x3 last year. But even though the Optcarrot benchmark has shown impressive speedups, the JIT has not benefited real world business applications.
Recently Shopify contributed many Ruby improvements to speed up their Rails application. YJIT is an important contribution, and aims to improve the performance of Rails applications.
While MJIT is a method-based JIT compiler and uses an external C compiler, YJIT uses Basic Block Versioning and includes a JIT compiler inside it. With Lazy Basic Block Versioning (LBBV) it first compiles the beginning of a method, and incrementally compiles the rest when the type of arguments and variables are dynamically determined. See YJIT: a basic block versioning JIT compiler for CRuby for a detailed introduction.
With this technology, YJIT achieves both fast warmup time and performance improvements on most real-world software, up to 22% on railsbench, 39% on liquid-render.
YJIT is still an experimental feature, and as such, it is disabled by default. If you want to use this, specify the --yjit
command-line option to enable YJIT. It is also limited to Unix-like x86-64 platforms for now.
A completely rewritten debugger debug.gem is bundled. debug.gem has the following features:
Ruby had bundled lib/debug.rb, but it was not well maintained and it had issues about performance and features. debug.gem replaces lib/debug.rb completely.
error_highlight: Fine-grained error location in backtraceA built-in gem, error_highlight, has been introduced. It includes fine-grained error location in backtraces:
$ ruby test.rb
test.rb:1:in `<main>': undefined method `time' for 1:Integer (NoMethodError)
1.time {}
^^^^^
Did you mean? times
Currently, only NameError
is supported.
This gem is enabled by default. You can disable it by using the command-line option --disable-error_highlight
. See the error_highlight repository for details.
The IRB now has an autocomplete feature, where you can just type in the code, and the completion candidates dialog will appear. You can use Tab and Shift+Tab to move up and down.
If documentation is installed when you select a completion candidate, the documentation dialog will appear next to the completion candidates dialog, showing part of the content. You can read the full documentation by pressing Alt+d.
Other Notable New Features Language{x:, y:}
is syntax sugar for {x: x, y: y}
.foo(x:, y:)
is syntax sugar for foo(x: x, y: y)
.The pin operator (^
) in pattern matching now takes an expression. [Feature #17411]
Prime.each_cons(2).lazy.find_all{_1 in [n, ^(n + 2)]}.take(3).to_a
#=> [[3, 5], [5, 7], [11, 13]]
Parentheses can be omitted in one-line pattern matching. [Feature #16182]
[0, 1] => _, x
{y: 2} => y:
x #=> 1
y #=> 2
RBS is a language to describe the structure of Ruby programs. See the RBS repository for details.
Updates since Ruby 3.0.0:
rbs collection
has been introduced to manage gems’ RBSs. (doc)See the RBS changelog for more information.
TypeProfTypeProf is a static type analyzer for Ruby. It generates a prototype of RBS from non-type-annotated Ruby code. See the documentation for details.
The main update since Ruby 3.0.0 is an experimental IDE support called “TypeProf for IDE”.
The VS Code extension shows a guessed (or explicitly written in an RBS file) method signature above each method definition, draws a red underline under the code that may cause a name error or type error, and completes method names (i.e., shows method candidates). See the documentation for details.
Also, the release includes many bug fixes and performance improvements.
Performance improvements--jit-max-cache
is changed from 100 to 10000. The JIT compiler no longer skips compilation of methods longer than 1000 instructions.ary => [x, y, z]
, is no longer experimental.foo[0], bar[0] = baz, qux
was evaluated in order baz
, qux
, foo
, and then bar
in Ruby 3.0. In Ruby 3.1, it is evaluated in order foo
, bar
, baz
, and then qux
.Variable Width Allocation: Strings (experimental). [Bug #18239]
Psych.load
to use safe_load
by default. You may need to use Psych 3.3.2 for migrating to this behavior. [Bug #17866]Gemfile
under the bundler environment.
See NEWS or the commit logs for more details.
With those changes, 3124 files changed, 551760 insertions(+), 99167 deletions(-) since Ruby 3.0.0!
Merry Christmas, Happy Holidays, and enjoy programming with Ruby 3.1!
Downloadhttps://cache.ruby-lang.org/pub/ruby/3.1/ruby-3.1.0.tar.gz
SIZE: 20103517
SHA1: e4e8c20dd2a1fdef4d3e5bd5a3461000dd17f226
SHA256: 50a0504c6edcb4d61ce6b8cfdbddaa95707195fab0ecd7b5e92654b2a9412854
SHA512: 76009d325e961e601d9a287e36490cbc1f3b5dbf4878fa6eab2c4daa5ff2fed78cbc7525cd87b09828f97cbe2beb30f528928bcc5647af745d03dffe7c5baaa9
https://cache.ruby-lang.org/pub/ruby/3.1/ruby-3.1.0.tar.xz
SIZE: 14709096
SHA1: 92b603c2a69fb25d66c337a63e94280984edea11
SHA256: 1a0e0b69b9b062b6299ff1f6c6d77b66aff3995f63d1d8b8771e7a113ec472e2
SHA512: a2bb6b5e62d5fa06dd9c30cf84ddcb2c27cb87fbaaffd2309a44391a6b110e1dde6b7b0d8c659b56387ee3c9b4264003f3532d5a374123a7c187ebba9293f320
https://cache.ruby-lang.org/pub/ruby/3.1/ruby-3.1.0.zip
SIZE: 24388179
SHA1: e37435956d6f840a0e8758d7374bc7e0e346105f
SHA256: a3bfcd486d09c065d46421da0ff3d430ce4423fefd80cea63c6595d83ae4af0e
SHA512: 67db71144e06da2c1c25eaf413d1417c99a4b18738a573f9e3371c11ea242eee9dcbdc3de17336f25ab5060039fe034e57298943d344be9cd9eb33bb56e2e1c6
Ruby was first developed by Matz (Yukihiro Matsumoto) in 1993, and is now developed as Open Source. It runs on multiple platforms and is used all over the world especially for web development.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.3