|
| 1 | +--- |
| 2 | +layout: news_post |
| 3 | +title: "Ruby 3.4.0 rc1 Released" |
| 4 | +author: "naruse" |
| 5 | +translator: |
| 6 | +date: 2024-12-12 00:00:00 +0000 |
| 7 | +lang: en |
| 8 | +--- |
| 9 | + |
| 10 | +{% assign release = site.data.releases | where: "version", "3.4.0-rc1" | first %} |
| 11 | +We are pleased to announce the release of Ruby {{ release.version }}. |
| 12 | + |
| 13 | +## Prism |
| 14 | + |
| 15 | +Switch the default parser from parse.y to Prism. [[Feature #20564]] |
| 16 | + |
| 17 | +## Modular GC |
| 18 | + |
| 19 | +* Alternative garbage collector (GC) implementations can be loaded dynamically |
| 20 | + through the modular garbage collector feature. To enable this feature, |
| 21 | + configure Ruby with `--with-modular-gc` at build time. GC libraries can be |
| 22 | + loaded at runtime using the environment variable `RUBY_GC_LIBRARY`. |
| 23 | + [[Feature #20351]] |
| 24 | + |
| 25 | +* Ruby's built-in garbage collector has been split into a separate file at |
| 26 | + `gc/default/default.c` and interacts with Ruby using an API defined in |
| 27 | + `gc/gc_impl.h`. The built-in garbage collector can now also be built as a |
| 28 | + library using `make modular-gc MODULAR_GC=default` and enabled using the |
| 29 | + environment variable `RUBY_GC_LIBRARY=default`. [[Feature #20470]] |
| 30 | + |
| 31 | +* An experimental GC library is provided based on [MMTk](https://www.mmtk.io/). |
| 32 | + This GC library can be built using `make modular-gc MODULAR_GC=mmtk` and |
| 33 | + enabled using the environment variable `RUBY_GC_LIBRARY=mmtk`. This requires |
| 34 | + the Rust toolchain on the build machine. [[Feature #20860]] |
| 35 | + |
| 36 | + |
| 37 | +## Language changes |
| 38 | + |
| 39 | +* String literals in files without a `frozen_string_literal` comment now emit a deprecation warning |
| 40 | + when they are mutated. |
| 41 | + These warnings can be enabled with `-W:deprecated` or by setting `Warning[:deprecated] = true`. |
| 42 | + To disable this change, you can run Ruby with the `--disable-frozen-string-literal` |
| 43 | + command line argument. [[Feature #20205]] |
| 44 | + |
| 45 | +* `it` is added to reference a block parameter. [[Feature #18980]] |
| 46 | + |
| 47 | +* Keyword splatting `nil` when calling methods is now supported. |
| 48 | + `**nil` is treated similarly to `**{}`, passing no keywords, |
| 49 | + and not calling any conversion methods. [[Bug #20064]] |
| 50 | + |
| 51 | +* Block passing is no longer allowed in index. [[Bug #19918]] |
| 52 | + |
| 53 | +* Keyword arguments are no longer allowed in index. [[Bug #20218]] |
| 54 | + |
| 55 | +## YJIT |
| 56 | + |
| 57 | +TL;DR: |
| 58 | +* Better performance on most benchmarks on both x86-64 and arm64 platforms. |
| 59 | +* Reduced memory usage of compilation metadata |
| 60 | +* Multiple bug fixes. YJIT is now even more robust and better tested. |
| 61 | + |
| 62 | +New features: |
| 63 | +* Add unified memory limit via `--yjit-mem-size` command-line option (default 128MiB) |
| 64 | + which tracks total YJIT memory usage and is more intuitive than the |
| 65 | + old `--yjit-exec-mem-size`. |
| 66 | +* More statistics now always available via `RubyVM::YJIT.runtime_stats` |
| 67 | +* Add compilation log to track what gets compiled via `--yjit-log` |
| 68 | + * Tail of the log also available at run-time via `RubyVM::YJIT.log` |
| 69 | +* Add support for shareable consts in multi-ractor mode |
| 70 | +* Can now trace counted exits with `--yjit-trace-exits=COUNTER` |
| 71 | + |
| 72 | +New optimizations: |
| 73 | +* Compressed context reduces memory needed to store YJIT metadata |
| 74 | +* Improved allocator with ability to allocate registers for local variables |
| 75 | +* When YJIT is enabled, use more Core primitives written in Ruby: |
| 76 | + * `Array#each`, `Array#select`, `Array#map` rewritten in Ruby for better performance [[Feature #20182]]. |
| 77 | +* Ability to inline small/trivial methods such as: |
| 78 | + * Empty methods |
| 79 | + * Methods returning a constant |
| 80 | + * Methods returning `self` |
| 81 | + * Methods directly returning an argument |
| 82 | +* Specialized codegen for many more runtime methods |
| 83 | +* Optimize `String#getbyte`, `String#setbyte` and other string methods |
| 84 | +* Optimize bitwise operations to speed up low-level bit/byte manipulation |
| 85 | +* Various other incremental optimizations |
| 86 | + |
| 87 | +## Core classes updates |
| 88 | + |
| 89 | +Note: We're only listing outstanding class updates. |
| 90 | + |
| 91 | +* Exception |
| 92 | + |
| 93 | + * `Exception#set_backtrace` now accepts an array of `Thread::Backtrace::Location`. |
| 94 | + `Kernel#raise`, `Thread#raise` and `Fiber#raise` also accept this new format. [[Feature #13557]] |
| 95 | + |
| 96 | +* Range |
| 97 | + |
| 98 | + * `Range#size` now raises `TypeError` if the range is not iterable. [[Misc #18984]] |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | +## Compatibility issues |
| 103 | + |
| 104 | +Note: Excluding feature bug fixes. |
| 105 | + |
| 106 | +* Error messages and backtrace displays have been changed. |
| 107 | + * Use a single quote instead of a backtick as a opening quote. [[Feature #16495]] |
| 108 | + * Display a class name before a method name (only when the class has a permanent name). [[Feature #19117]] |
| 109 | + * `Kernel#caller`, `Thread::Backtrace::Location`'s methods, etc. are also changed accordingly. |
| 110 | + |
| 111 | + ``` |
| 112 | + Old: |
| 113 | + test.rb:1:in `foo': undefined method `time' for an instance of Integer |
| 114 | + from test.rb:2:in `<main>' |
| 115 | +
|
| 116 | + New: |
| 117 | + test.rb:1:in 'Object#foo': undefined method 'time' for an instance of Integer |
| 118 | + from test.rb:2:in '<main>' |
| 119 | + ``` |
| 120 | + |
| 121 | +## C API updates |
| 122 | + |
| 123 | +* `rb_newobj` and `rb_newobj_of` (and corresponding macros `RB_NEWOBJ`, `RB_NEWOBJ_OF`, `NEWOBJ`, `NEWOBJ_OF`) have been removed. [[Feature #20265]] |
| 124 | +* Removed deprecated function `rb_gc_force_recycle`. [[Feature #18290]] |
| 125 | + |
| 126 | +## Miscellaneous changes |
| 127 | + |
| 128 | +* Passing a block to a method which doesn't use the passed block will show |
| 129 | + a warning on verbose mode (`-w`). |
| 130 | + [[Feature #15554]] |
| 131 | + |
| 132 | +* Redefining some core methods that are specially optimized by the interpeter |
| 133 | + and JIT like `String.freeze` or `Integer#+` now emits a performance class |
| 134 | + warning (`-W:performance` or `Warning[:performance] = true`). |
| 135 | + [[Feature #20429]] |
| 136 | + |
| 137 | +See GitHub releases like [Logger](https://github.com/ruby/logger/releases) or |
| 138 | +changelog for details of the default gems or bundled gems. |
| 139 | + |
| 140 | +See [NEWS](https://github.com/ruby/ruby/blob/{{ release.tag }}/NEWS.md) |
| 141 | +or [commit logs](https://github.com/ruby/ruby/compare/v3_3_0...{{ release.tag }}) |
| 142 | +for more details. |
| 143 | + |
| 144 | +With those changes, [{{ release.stats.files_changed }} files changed, {{ release.stats.insertions }} insertions(+), {{ release.stats.deletions }} deletions(-)](https://github.com/ruby/ruby/compare/v3_3_0...{{ release.tag }}#file_bucket) |
| 145 | +since Ruby 3.3.0! |
| 146 | + |
| 147 | + |
| 148 | +## Download |
| 149 | + |
| 150 | +* <{{ release.url.gz }}> |
| 151 | + |
| 152 | + SIZE: {{ release.size.gz }} |
| 153 | + SHA1: {{ release.sha1.gz }} |
| 154 | + SHA256: {{ release.sha256.gz }} |
| 155 | + SHA512: {{ release.sha512.gz }} |
| 156 | + |
| 157 | +* <{{ release.url.xz }}> |
| 158 | + |
| 159 | + SIZE: {{ release.size.xz }} |
| 160 | + SHA1: {{ release.sha1.xz }} |
| 161 | + SHA256: {{ release.sha256.xz }} |
| 162 | + SHA512: {{ release.sha512.xz }} |
| 163 | + |
| 164 | +* <{{ release.url.zip }}> |
| 165 | + |
| 166 | + SIZE: {{ release.size.zip }} |
| 167 | + SHA1: {{ release.sha1.zip }} |
| 168 | + SHA256: {{ release.sha256.zip }} |
| 169 | + SHA512: {{ release.sha512.zip }} |
| 170 | + |
| 171 | +## What is Ruby |
| 172 | + |
| 173 | +Ruby was first developed by Matz (Yukihiro Matsumoto) in 1993, |
| 174 | +and is now developed as Open Source. It runs on multiple platforms |
| 175 | +and is used all over the world especially for web development. |
| 176 | + |
| 177 | +[Feature #13557]: https://bugs.ruby-lang.org/issues/13557 |
| 178 | +[Feature #15554]: https://bugs.ruby-lang.org/issues/15554 |
| 179 | +[Feature #16495]: https://bugs.ruby-lang.org/issues/16495 |
| 180 | +[Feature #18290]: https://bugs.ruby-lang.org/issues/18290 |
| 181 | +[Feature #18980]: https://bugs.ruby-lang.org/issues/18980 |
| 182 | +[Misc #18984]: https://bugs.ruby-lang.org/issues/18984 |
| 183 | +[Feature #19117]: https://bugs.ruby-lang.org/issues/19117 |
| 184 | +[Bug #19918]: https://bugs.ruby-lang.org/issues/19918 |
| 185 | +[Bug #20064]: https://bugs.ruby-lang.org/issues/20064 |
| 186 | +[Feature #20182]: https://bugs.ruby-lang.org/issues/20182 |
| 187 | +[Feature #20205]: https://bugs.ruby-lang.org/issues/20205 |
| 188 | +[Bug #20218]: https://bugs.ruby-lang.org/issues/20218 |
| 189 | +[Feature #20265]: https://bugs.ruby-lang.org/issues/20265 |
| 190 | +[Feature #20351]: https://bugs.ruby-lang.org/issues/20351 |
| 191 | +[Feature #20429]: https://bugs.ruby-lang.org/issues/20429 |
| 192 | +[Feature #20470]: https://bugs.ruby-lang.org/issues/20470 |
| 193 | +[Feature #20564]: https://bugs.ruby-lang.org/issues/20564 |
| 194 | +[Feature #20860]: https://bugs.ruby-lang.org/issues/20860 |
0 commit comments