Skip to content

Commit 225069a

Browse files
committed
Import original article
1 parent f5ac918 commit 225069a

File tree

1 file changed

+217
-0
lines changed

1 file changed

+217
-0
lines changed
Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
---
2+
layout: news_post
3+
title: "Ruby 3.1.0 Preview 1 Released"
4+
author: "naruse"
5+
translator:
6+
date: 2021-11-09 00:00:00 +0000
7+
lang: en
8+
---
9+
10+
{% assign release = site.data.releases | where: "version", "3.1.0-preview1" | first %}
11+
12+
We are pleased to announce the release of Ruby {{ release.version }}.
13+
14+
## YJIT: New experimental in-process JIT compiler
15+
16+
17+
Ruby 3.1 merges YJIT, a new in-process JIT compiler developed by Shopify.
18+
19+
Since [Ruby 2.6 introduced MJIT in 2018](https://www.ruby-lang.org/en/news/2018/12/25/ruby-2-6-0-released/), its performance greatly improved, and finally [we achieved Ruby3x3 last year](https://www.ruby-lang.org/en/news/2020/12/25/ruby-3-0-0-released/). But even though Optcarrot has shown impressive speedups, the JIT hasn't benefited real world business applications.
20+
21+
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.
22+
23+
Though MJIT is a method-based JIT compiler and uses an external C compiler, YJIT uses Basic Block Versioning and includes 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](https://dl.acm.org/doi/10.1145/3486606.3486781) for a detailed introduction.
24+
25+
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.
26+
27+
<!-- 試す人向けのお知らせ -->
28+
29+
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 macOS & Linux on x86-64 platforms for now.
30+
31+
* <https://bugs.ruby-lang.org/issues/18229>
32+
* <https://shopify.engineering/yjit-just-in-time-compiler-cruby>
33+
* <https://www.youtube.com/watch?v=PBVLf3yfMs8>
34+
35+
## debug gem: A new debugger
36+
37+
A new debugger [debug.gem](https://github.com/ruby/debug) is bundled. debug.gem is fast debugger implementation and it provides many features like remote debugging, colorful REPL, IDE (VSCode) integration and more. It replaces `lib/debug.rb` standard library.
38+
39+
## error_highlight: Fine-grained error location in backtrace
40+
41+
A built-in gem, error_highlight, has been introduced. It includes fine-grained error location in backtrace:
42+
43+
```
44+
$ ruby test.rb
45+
test.rb:1:in `<main>': undefined method `time' for 1:Integer (NoMethodError)
46+
47+
1.time {}
48+
^^^^^
49+
Did you mean? times
50+
```
51+
52+
This gem is enabled by default. You can disable it by using a command-line option `--disable-error_highlight`. See [the repository](https://github.com/ruby/error_highlight) in detail.
53+
54+
## Irb improvement
55+
56+
To be described in next preview.
57+
58+
## Other Notable New Features
59+
60+
### Language
61+
62+
* Values in Hash literals and keyword arguments can be omitted. [Feature #14579]
63+
* `{x:, y:}` is a syntax sugar of `{x: x, y: y}`.
64+
* `foo(x:, y:)` is a syntax sugar of `foo(x: x, y: y)`.
65+
66+
* Pin operator in pattern matching now takes an expression. [Feature #17411]
67+
68+
```ruby
69+
Prime.each_cons(2).lazy.find_all{_1 in [n, ^(n + 2)]}.take(3).to_a
70+
#=> [[3, 5], [5, 7], [11, 13]]
71+
```
72+
73+
74+
### RBS
75+
76+
RBS is a language to describe the structure of Ruby programs. See [the repository](https://github.com/ruby/rbs) for detail.
77+
78+
Updates since Ruby 3.0.0:
79+
80+
* `rbs collection` has been introduced to manage gems' RBSs. [doc](https://github.com/ruby/rbs/blob/master/docs/collection.md)
81+
* Many signatures for built-in and standard libraries have been added/updated.
82+
* It includes many bug fixes and performance improvements too.
83+
84+
See [the CHANGELOG.md](https://github.com/ruby/rbs/blob/master/CHANGELOG.md) for more information.
85+
86+
### TypeProf
87+
88+
TypeProf is a static type analyzer for Ruby. It generates a prototype of RBS from non-type-annotated Ruby code. See [the document](https://github.com/ruby/typeprof/blob/master/doc/doc.md) for detail.
89+
90+
Updates since Ruby 3.0.0:
91+
92+
* [Experimental IDE support](https://github.com/ruby/typeprof/blob/master/doc/ide.md) has been implemented.
93+
* Many bug fixes and performance improvements.
94+
95+
## Performance improvements
96+
97+
* MJIT
98+
* For workloads like Rails, the default `--jit-max-cache` is changed from 100 to 10000.
99+
The JIT compiler no longer skips compilation of methods longer than 1000 instructions.
100+
* To support Zeitwerk of Rails, JIT-ed code is no longer cancelled
101+
when a TracePoint for class events is enabled.
102+
103+
## Other notable changes since 3.0
104+
105+
* One-line pattern matching, e.g., `ary => [x, y, z]`, is no longer experimental.
106+
* Multiple assignment evaluation order has been changed slightly. [[Bug #4443]](https://bugs.ruby-lang.org/issues/4443)
107+
* `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`.
108+
* Variable Width Allocation: Strings (experimental) [[Bug #18239]](https://bugs.ruby-lang.org/issues/18239)
109+
110+
### Standard libraries updates
111+
112+
* Some standard libraries are updated.
113+
* RubyGems
114+
* Bundler
115+
* RDoc 6.4.0
116+
* ReLine
117+
* JSON 2.6.0
118+
* Psych 4.0.2
119+
* FileUtils 1.6.0
120+
* Fiddle
121+
* StringIO 3.0.1
122+
* IO::Console 0.5.9
123+
* IO::Wait 0.2.0
124+
* CSV
125+
* Etc 1.3.0
126+
* Date 3.2.0
127+
* Zlib 2.1.1
128+
* StringScanner
129+
* IpAddr
130+
* Logger 1.4.4
131+
* OStruct 0.5.0
132+
* Irb
133+
* Racc 1.6.0
134+
* Delegate 0.2.0
135+
* Benchmark 0.2.0
136+
* CGI 0.3.0
137+
* Readline(C-ext) 0.1.3
138+
* Timeout 0.2.0
139+
* YAML 0.2.0
140+
* URI 0.11.0
141+
* OpenSSL
142+
* DidYouMean
143+
* Weakref 0.1.1
144+
* Tempfile 0.1.2
145+
* TmpDir 0.1.2
146+
* English 0.7.1
147+
* Net::Protocol 0.1.2
148+
* Net::Http 0.2.0
149+
* BigDecimal
150+
* OptionParser 0.2.0
151+
* Set
152+
* Find 0.1.1
153+
* Rinda 0.1.1
154+
* Erb
155+
* NKF 0.1.1
156+
* Base64 0.1.1
157+
* OpenUri 0.2.0
158+
* SecureRandom 0.1.1
159+
* Resolv 0.2.1
160+
* Resolv::Replace 0.1.0
161+
* Time 0.2.0
162+
* PP 0.2.1
163+
* Prettyprint 0.1.1
164+
* Drb 2.1.0
165+
* Pathname 0.2.0
166+
* Digest 3.1.0.pre2
167+
* Un 0.2.0
168+
* The following bundled gems are updated.
169+
* minitest 5.14.4
170+
* power_assert 2.0.1
171+
* rake 13.0.6
172+
* test-unit 3.5.0
173+
* rbs 1.6.2
174+
* typeprof 0.20.0
175+
* The following default gems are now bundled gems.
176+
* net-ftp
177+
* net-imap
178+
* net-pop
179+
* net-smtp
180+
* matrix
181+
* prime
182+
183+
See [NEWS](https://github.com/ruby/ruby/blob/{{ release.tag }}/NEWS.md)
184+
or [commit logs](https://github.com/ruby/ruby/compare/v3_0_0...{{ release.tag }})
185+
for more details.
186+
187+
With those changes, [{{ release.stats.files_changed }} files changed, {{ release.stats.insertions }} insertions(+), {{ release.stats.deletions }} deletions(-)](https://github.com/ruby/ruby/compare/v3_0_0...{{ release.tag }}#file_bucket)
188+
since Ruby 3.0.0!
189+
190+
## Download
191+
192+
* <{{ release.url.gz }}>
193+
194+
SIZE: {{ release.size.gz }}
195+
SHA1: {{ release.sha1.gz }}
196+
SHA256: {{ release.sha256.gz }}
197+
SHA512: {{ release.sha512.gz }}
198+
199+
* <{{ release.url.xz }}>
200+
201+
SIZE: {{ release.size.xz }}
202+
SHA1: {{ release.sha1.xz }}
203+
SHA256: {{ release.sha256.xz }}
204+
SHA512: {{ release.sha512.xz }}
205+
206+
* <{{ release.url.zip }}>
207+
208+
SIZE: {{ release.size.zip }}
209+
SHA1: {{ release.sha1.zip }}
210+
SHA256: {{ release.sha256.zip }}
211+
SHA512: {{ release.sha512.zip }}
212+
213+
## What is Ruby
214+
215+
Ruby was first developed by Matz (Yukihiro Matsumoto) in 1993,
216+
and is now developed as Open Source. It runs on multiple platforms
217+
and is used all over the world especially for web development.

0 commit comments

Comments
 (0)