Skip to content

Commit f510edb

Browse files
committed
cp {en,ko}/news/_posts/2022-04-03-ruby-3-2-0-preview1-released.md
1 parent 280f05e commit f510edb

File tree

1 file changed

+178
-0
lines changed

1 file changed

+178
-0
lines changed
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
---
2+
layout: news_post
3+
title: "Ruby 3.2.0 Preview 1 Released"
4+
author: "naruse"
5+
translator:
6+
date: 2022-04-03 00:00:00 +0000
7+
lang: en
8+
---
9+
10+
{% assign release = site.data.releases | where: "version", "3.2.0-preview1" | first %}
11+
12+
We are pleased to announce the release of Ruby {{ release.version }}. Ruby 3.2 adds many features and performance improvements.
13+
14+
15+
## WASI based WebAssembly support
16+
17+
This is an initial port of WASI based WebAssembly support. This enables a CRuby binary to be available on Web browser, Serverless Edge environment, and other WebAssembly/WASI embedders. Currently this port passes basic and bootstrap test suites not using Thread API.
18+
19+
![](https://i.imgur.com/opCgKy2.png)
20+
21+
### Background
22+
23+
[WebAssembly (WASM)](https://webassembly.org/) is originally introduced to run programs safely and fast in web browsers. But its objective - running programs efficiently with security on various environment - is long wanted not only by web but also by general applications.
24+
25+
[WASI (The WebAssembly System Interface)](https://wasi.dev/) is designed for such use cases. Though such applications need to communicate with operating systems, WebAssembly runs on a virtual machine which didn't have a system interface. WASI standardizes it.
26+
27+
WebAssembly/WASI Support in Ruby intends to leverage those projects. It enables Ruby developers to write applications which runs on such promised platform.
28+
29+
### Use case
30+
31+
This support encourages developers can utilize CRuby in WebAssembly environment. An example use case of it is [TryRuby playground](https://try.ruby-lang.org/playground/)'s CRuby support. Now you can try original CRuby in your web browser.
32+
33+
### Technical points
34+
35+
Today’s WASI and WebAssembly itself has some missing features to implement Fiber, exception, and GC because it’s still evolving and also for security reasons. So CRuby fills the gap by using Asyncify, which is a binary transformation technique to control execution in userland.
36+
37+
In addition, we built [a VFS on top of WASI](https://github.com/kateinoigakukun/wasi-vfs/wiki/Getting-Started-with-CRuby) so that we can easily pack Ruby apps into a single .wasm file. This makes distribution of Ruby apps a bit easier.
38+
39+
40+
### Related links
41+
42+
* [Add WASI based WebAssembly support #5407](https://github.com/ruby/ruby/pull/5407)
43+
* [An Update on WebAssembly/WASI Support in Ruby](https://itnext.io/final-report-webassembly-wasi-support-in-ruby-4aface7d90c9)
44+
45+
## Regexp timeout
46+
47+
A timeout feature for Regexp matching is introduced.
48+
49+
```ruby
50+
Regexp.timeout = 1.0
51+
52+
/^a*b?a*$/ =~ "a" * 50000 + "x"
53+
#=> Regexp::TimeoutError is raised in one second
54+
```
55+
56+
It is known that Regexp matching may take unexpectedly long. If your code attempts to match an possibly inefficient Regexp against an untrusted input, an attacker may exploit it for efficient Denial of Service (so-called Regular expression DoS, or ReDoS).
57+
58+
The risk of DoS can be prevented or significantly mitigated by configuring `Regexp.timeout` according to the requirements of your Ruby application. Please try it out in your application and welcome your feedback.
59+
60+
Note that `Regexp.timeout` is a global configuration. If you want to use different timeout settings for some special Regexps, you may want to use `timeout` keyword for `Regexp.new`.
61+
62+
```ruby
63+
Regexp.timeout = 1.0
64+
65+
# This regexp has no timeout
66+
long_time_re = Regexp.new("^a*b?a*$", timeout: nil)
67+
68+
long_time_re =~ "a" * 50000 + "x" # never interrupted
69+
```
70+
71+
The original proposal is https://bugs.ruby-lang.org/issues/17837
72+
73+
74+
## Other Notable New Features
75+
76+
### No longer bundle 3rd party sources
77+
78+
* We no longer bundle 3rd party sources like `libyaml`, `libffi`.
79+
80+
* libyaml source has been removed from psych. You may need to install `libyaml-dev` with Ubuntu/Debian platform. The package name is different each platforms.
81+
82+
* libffi will be removed from `fiddle` at preview2
83+
84+
### Language
85+
86+
* Find pattern is no longer experimental.
87+
88+
89+
## Performance improvements
90+
91+
92+
93+
## Other notable changes since 3.1
94+
95+
* Hash
96+
* Hash#shift now always returns nil if the hash is
97+
empty, instead of returning the default value or
98+
calling the default proc. [[Bug #16908]]
99+
100+
* MatchData
101+
* MatchData#byteoffset has been added. [[Feature #13110]]
102+
103+
* Module
104+
* Module.used_refinements has been added. [[Feature #14332]]
105+
* Module#refinements has been added. [[Feature #12737]]
106+
* Module#const_added has been added. [[Feature #17881]]
107+
108+
* Proc
109+
* Proc#dup returns an instance of subclass. [[Bug #17545]]
110+
* Proc#parameters now accepts lambda keyword. [[Feature #15357]]
111+
112+
* Refinement
113+
* Refinement#refined_class has been added. [[Feature #12737]]
114+
115+
* Set
116+
* Set is now available as a builtin class without the need for `require "set"`. [[Feature #16989]]
117+
It is currently autoloaded via the `Set` constant or a call to `Enumerable#to_set`.
118+
119+
* String
120+
* String#byteindex and String#byterindex have been added. [[Feature #13110]]
121+
* Update Unicode to Version 14.0.0 and Emoji Version 14.0. [[Feature #18037]]
122+
(also applies to Regexp)
123+
* String#bytesplice has been added. [[Feature #18598]]
124+
125+
* Struct
126+
* A Struct class can also be initialized with keyword arguments
127+
without `keyword_init: true` on `Struct.new` [[Feature #16806]]
128+
129+
130+
### Standard libraries updates
131+
132+
* The following default gem are updated.
133+
134+
* TBD
135+
136+
* The following bundled gems are updated.
137+
138+
* TBD
139+
140+
* The following default gems are now bundled gems. You need to add the following libraries to `Gemfile` under the bundler environment.
141+
142+
* TBD
143+
144+
See [NEWS](https://github.com/ruby/ruby/blob/{{ release.tag }}/NEWS.md)
145+
or [commit logs](https://github.com/ruby/ruby/compare/v3_1_0...{{ release.tag }})
146+
for more details.
147+
148+
With those changes, [{{ release.stats.files_changed }} files changed, {{ release.stats.insertions }} insertions(+), {{ release.stats.deletions }} deletions(-)](https://github.com/ruby/ruby/compare/v3_1_0...{{ release.tag }}#file_bucket)
149+
since Ruby 3.1.0!
150+
151+
## Download
152+
153+
* <{{ release.url.gz }}>
154+
155+
SIZE: {{ release.size.gz }}
156+
SHA1: {{ release.sha1.gz }}
157+
SHA256: {{ release.sha256.gz }}
158+
SHA512: {{ release.sha512.gz }}
159+
160+
* <{{ release.url.xz }}>
161+
162+
SIZE: {{ release.size.xz }}
163+
SHA1: {{ release.sha1.xz }}
164+
SHA256: {{ release.sha256.xz }}
165+
SHA512: {{ release.sha512.xz }}
166+
167+
* <{{ release.url.zip }}>
168+
169+
SIZE: {{ release.size.zip }}
170+
SHA1: {{ release.sha1.zip }}
171+
SHA256: {{ release.sha256.zip }}
172+
SHA512: {{ release.sha512.zip }}
173+
174+
## What is Ruby
175+
176+
Ruby was first developed by Matz (Yukihiro Matsumoto) in 1993,
177+
and is now developed as Open Source. It runs on multiple platforms
178+
and is used all over the world especially for web development.

0 commit comments

Comments
 (0)