You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ruby 4.0 will be released soon. This feature checklist is based on the NEWS file from CRuby's master branch. We'll update this list until the release has been finalized.
Pull requests to implement Ruby 4.0 features should be based on the ruby-4.0 branch, not master.
NEWS for Ruby 4.0
This document is a list of user-visible feature changes
since the 3.4.0 release, except for bug fixes.
Note that each entry is kept to a minimum, see links for details.
Logical binary operators (||, &&, and and or) at the
beginning of a line continue the previous line, like fluent dot.
The following two code are equal:
Note: We're only listing outstanding class updates.
Array
Array#rfind has been added as a more efficient alternative to array.reverse_each.find [Feature #21678]
Array#find has been added as a more efficient override of Enumerable#find [Feature #21678]
Binding
Binding#local_variables does no longer include numbered parameters.
Also, Binding#local_variable_get, Binding#local_variable_set, and Binding#local_variable_defined? reject to handle numbered parameters.
[Bug #21049]
Binding#implicit_parameters, Binding#implicit_parameter_get, and Binding#implicit_parameter_defined? have been added to access
numbered parameters and "it" parameter. [Bug #21049]
Enumerator
Enumerator.produce now accepts an optional size keyword argument
to specify the size of the enumerator. It can be an integer, Float::INFINITY, a callable object (such as a lambda), or nil to
indicate unknown size. When not specified, the size defaults to Float::INFINITY.
Introduce support for Fiber#raise(cause:) argument similar to Kernel#raise. [Feature #21360]
Fiber::Scheduler
Introduce Fiber::Scheduler#fiber_interrupt to interrupt a fiber with a
given exception. The initial use case is to interrupt a fiber that is
waiting on a blocking IO operation when the IO operation is closed.
[Feature #21166]
Introduce Fiber::Scheduler#yield to allow the fiber scheduler to
continue processing when signal exceptions are disabled.
[Bug #21633]
Reintroduce the Fiber::Scheduler#io_close hook for asynchronous IO#close.
Invoke Fiber::Scheduler#io_write when flushing the IO write buffer.
[Bug #21789]
File
File::Stat#birthtime is now available on Linux via the statx
system call when supported by the kernel and filesystem.
[Feature #21205]
A deprecated behavior, process creation by IO class methods
with a leading |, was removed. [Feature #19630]
Kernel
Kernel#inspect now checks for the existence of a #instance_variables_to_inspect method,
allowing control over which instance variables are displayed in the #inspect string:
Pathname has been promoted from a default gem to a core class of Ruby.
[Feature #17473]
Proc
Proc#parameters now shows anonymous optional parameters as [:opt]
instead of [:opt, nil], making the output consistent with when the
anonymous parameter is required. [Bug #20974]
Ractor
Ractor::Port class was added for a new synchronization mechanism
to communicate between Ractors. [Feature #21262]
As result, Ractor.yield and Ractor#take were removed.
Ractor#join and Ractor#value were added to wait for the
termination of a Ractor. These are similar to Thread#join
and Thread#value.
Ractor#monitor and Ractor#unmonitor were added as low-level
interfaces used internally to implement Ractor#join.
Ractor.select now only accepts Ractors and Ports. If Ractors are given,
it returns when a Ractor terminates.
Ractor#default_port was added. Each Ractor has a default port,
which is used by Ractor.send, Ractor.receive.
Ractor#close_incoming and Ractor#close_outgoing were removed.
Ractor.shareable_proc and Ractor.shareable_lambda is introduced
to make shareable Proc or lambda.
[Feature #21550], [Feature #21557]
Range
Range#to_set now performs size checks to prevent issues with
endless ranges. [Bug #21654]
Range#overlap? now correctly handles infinite (unbounded) ranges.
[Bug #21185]
Range#max behavior on beginless integer ranges has been fixed.
[Bug #21174] [Bug #21175]
Ruby
A new toplevel module Ruby has been defined, which contains
Ruby-related constants. This module was reserved in Ruby 3.4
and is now officially defined. [Feature #20884]
Set#inspect now uses a simpler display, similar to literal arrays.
(e.g., Set[1, 2, 3] instead of #<Set: {1, 2, 3}>). [Feature #21389]
Passing arguments to Set#to_set and Enumerable#to_set is now deprecated.
[Feature #21390]
Socket
Socket.tcp & TCPSocket.new accepts open_timeout as a keyword argument to specify
the timeout for the initial connection. [Feature #21347]
When a user-specified timeout occurred in TCPSocket.new, either Errno::ETIMEDOUT
or IO::TimeoutError could previously be raised depending on the situation.
This behavior has been unified so that IO::TimeoutError is now consistently raised.
(Please note that, in Socket.tcp, there are still cases where Errno::ETIMEDOUT
may be raised in similar situations, and that in both cases Errno::ETIMEDOUT may be
raised when the timeout occurs at the OS level.)
Introduce support for Thread#raise(cause:) argument similar to Kernel#raise. [Feature #21360]
Stdlib updates
The following bundled gems are promoted from default gems.
ostruct 0.6.3
pstore 0.2.0
benchmark 0.5.0
logger 1.7.0
rdoc 7.0.3
win32ole 1.9.2
irb 1.16.0
reline 0.6.3
readline 0.0.4
fiddle 1.1.8
We only list stdlib changes that are notable feature changes.
Other changes are listed in the following sections. We also listed release
history from the previous bundled version that is Ruby 3.3.0 if it has GitHub
releases.
The following default gem is added.
win32-registry 0.1.1
The following default gems are updated.
RubyGems 4.0.3
bundler 4.0.3
date 3.5.1
delegate 0.6.1
digest 3.2.1
english 0.8.1
erb 6.0.1
error-highlight 0.7.1
etc 1.4.6
fcntl 1.3.0
fileutils 1.8.0
forwardable 1.4.0
io-console 0.8.2
io-nonblock 0.3.2
io-wait 0.4.0
ipaddr 1.2.8
json 2.18.0
net-http 0.9.1
openssl 4.0.0
optparse 0.8.1
pp 0.6.3
prism 1.6.0
psych 5.3.1
resolv 0.7.0
stringio 3.2.0
strscan 3.1.6
time 0.4.2
timeout 0.4.4
uri 1.1.1
weakref 0.1.4
zlib 3.2.2
The following bundled gems are added.
The following bundled gems are updated.
minitest 6.0.0
power_assert 3.0.1
rake 13.3.1
test-unit 3.7.5
rexml 3.4.4
rss 0.3.2
net-ftp 0.3.9
net-imap 0.6.2
net-smtp 0.5.1
matrix 0.4.3
prime 0.1.4
rbs 3.10.0
typeprof 0.31.1
debug 1.11.1
base64 0.3.0
bigdecimal 4.0.1
drb 2.2.3
syslog 0.3.0
csv 3.3.5
repl_type_completor 0.1.12
Supported platforms
Windows
Dropped support for MSVC versions older than 14.0 (_MSC_VER 1900).
This means Visual Studio 2015 or later is now required.
Compatibility issues
The following methods were removed from Ractor due because of Ractor::Port:
Process::Status#& and Process::Status#>> have been removed.
They were deprecated in Ruby 3.3. [Bug #19868]
rb_path_check has been removed. This function was used for $SAFE path checking which was removed in Ruby 2.7,
and was already deprecated.
[Feature #20971]
A backtrace for ArgumentError of "wrong number of arguments" now
include the receiver's class or module name (e.g., in Foo#bar
instead of in bar). [Bug #21698]
Backtraces no longer display internal frames.
These methods now appear as if it is in the Ruby source file,
consistent with other C-implemented methods. [Bug #20968]
Before:
ruby -e '[1].fetch_values(42)'
<internal:array>:211:in 'Array#fetch': index 42 outside of array bounds: -1...1 (IndexError)
from <internal:array>:211:in 'block in Array#fetch_values'
from <internal:array>:211:in 'Array#map!'
from <internal:array>:211:in 'Array#fetch_values'
from -e:1:in '<main>'
After:
$ ruby -e '[1].fetch_values(42)'
-e:1:in 'Array#fetch_values': index 42 outside of array bounds: -1...1 (IndexError)
from -e:1:in '<main>'
Stdlib compatibility issues
CGI library is removed from the default gems. Now we only provide cgi/escape for
the following methods:
CGI.escape and CGI.unescape
CGI.escapeHTML and CGI.unescapeHTML
CGI.escapeURIComponent and CGI.unescapeURIComponent
With the move of Set from stdlib to core class, set/sorted_set.rb has
been removed, and SortedSet is no longer an autoloaded constant. Please
install the sorted_set gem and require 'sorted_set' to use SortedSet.
[Feature #21287]
Net::HTTP
The default behavior of automatically setting the Content-Type header
to application/x-www-form-urlencoded for requests with a body
(e.g., POST, PUT) when the header was not explicitly set has been
removed. If your application relied on this automatic default, your
requests will now be sent without a Content-Type header, potentially
breaking compatibility with certain servers.
[GH-net-http #205]
Implementation improvements
Ractor
A lot of work has gone into making Ractors more stable, performant, and usable. These improvements bring Ractors implementation closer to leaving experimental status.
Performance improvements
Frozen strings and the symbol table internally use a lock-free hash set
Method cache lookups avoid locking in most cases
Class (and geniv) instance variable access is faster and avoids locking
Cache contention is avoided during object allocation
object_id avoids locking in most cases
Bug fixes and stability
Fixed possible deadlocks when combining Ractors and Threads
Fixed issues with require and autoload in a Ractor
Fixed encoding/transcoding issues across Ractors
Fixed race conditions in GC operations and method invalidation
Fixed issues with processes forking after starting a Ractor
GC allocation counts are now accurate under Ractors
Fixed TracePoints not working after GC [Bug #19112]
Ruby 4.0 will be released soon. This feature checklist is based on the NEWS file from CRuby's master branch. We'll update this list until the release has been finalized.
Pull requests to implement Ruby 4.0 features should be based on the
ruby-4.0branch, notmaster.NEWS for Ruby 4.0
This document is a list of user-visible feature changes
since the 3.4.0 release, except for bug fixes.
Note that each entry is kept to a minimum, see links for details.
Language changes
*nilno longer callsnil.to_a, similar to how**nildoesnot call
nil.to_hash. [Feature #21047] (Avoid array allocation for *nil, by not calling nil.to_a #9074)Logical binary operators (
||,&&,andandor) at thebeginning of a line continue the previous line, like fluent dot.
The following two code are equal:
[Feature #20925]
Core classes updates
Note: We're only listing outstanding class updates.
Array
Array#rfindhas been added as a more efficient alternative toarray.reverse_each.find[Feature #21678]Array#findhas been added as a more efficient override ofEnumerable#find[Feature #21678]Binding
Binding#local_variablesdoes no longer include numbered parameters.Also,
Binding#local_variable_get,Binding#local_variable_set, andBinding#local_variable_defined?reject to handle numbered parameters.[Bug #21049]
Binding#implicit_parameters,Binding#implicit_parameter_get, andBinding#implicit_parameter_defined?have been added to accessnumbered parameters and "it" parameter. [Bug #21049]
Enumerator
Enumerator.producenow accepts an optionalsizekeyword argumentto specify the size of the enumerator. It can be an integer,
Float::INFINITY, a callable object (such as a lambda), orniltoindicate unknown size. When not specified, the size defaults to
Float::INFINITY.[Feature #21701]
Fiber
Fiber#raise(cause:)argument similar toKernel#raise. [Feature #21360]Fiber::Scheduler
Introduce
Fiber::Scheduler#fiber_interruptto interrupt a fiber with agiven exception. The initial use case is to interrupt a fiber that is
waiting on a blocking IO operation when the IO operation is closed.
[Feature #21166]
Introduce
Fiber::Scheduler#yieldto allow the fiber scheduler tocontinue processing when signal exceptions are disabled.
[Bug #21633]
Reintroduce the
Fiber::Scheduler#io_closehook for asynchronousIO#close.Invoke
Fiber::Scheduler#io_writewhen flushing the IO write buffer.[Bug #21789]
File
File::Stat#birthtimeis now available on Linux via the statxsystem call when supported by the kernel and filesystem.
[Feature #21205]
IO
IO.selectacceptsFloat::INFINITYas a timeout argument.[Feature #20610] (Align IO.select timeout logic with CRuby #9079)
A deprecated behavior, process creation by
IOclass methodswith a leading
|, was removed. [Feature #19630]Kernel
Kernel#inspectnow checks for the existence of a#instance_variables_to_inspectmethod,allowing control over which instance variables are displayed in the
#inspectstring:[Feature #21219] (Selective inspect of instance variables #9075)
A deprecated behavior, process creation by
Kernel#openwith aleading
|, was removed. [Feature #19630]Math
Math.log1pandMath.expm1are added. [Feature #21527] (Add Math.{expm1,log1p} #9078)Pathname
[Feature #17473]
Proc
Proc#parametersnow shows anonymous optional parameters as[:opt]instead of
[:opt, nil], making the output consistent with when theanonymous parameter is required. [Bug #20974]
Ractor
Ractor::Portclass was added for a new synchronization mechanismto communicate between Ractors. [Feature #21262]
Ractor::Portprovides the following methods:Ractor::Port#receiveRactor::Port#send(orRactor::Port#<<)Ractor::Port#closeRactor::Port#closed?As result,
Ractor.yieldandRactor#takewere removed.Ractor#joinandRactor#valuewere added to wait for thetermination of a Ractor. These are similar to
Thread#joinand
Thread#value.Ractor#monitorandRactor#unmonitorwere added as low-levelinterfaces used internally to implement
Ractor#join.Ractor.selectnow only accepts Ractors and Ports. If Ractors are given,it returns when a Ractor terminates.
Ractor#default_portwas added. EachRactorhas a default port,which is used by
Ractor.send,Ractor.receive.Ractor#close_incomingandRactor#close_outgoingwere removed.Ractor.shareable_procandRactor.shareable_lambdais introducedto make shareable Proc or lambda.
[Feature #21550], [Feature #21557]
Range
Range#to_setnow performs size checks to prevent issues withendless ranges. [Bug #21654]
Range#overlap?now correctly handles infinite (unbounded) ranges.[Bug #21185]
Range#maxbehavior on beginless integer ranges has been fixed.[Bug #21174] [Bug #21175]
Ruby
Rubyhas been defined, which containsRuby-related constants. This module was reserved in Ruby 3.4
and is now officially defined. [Feature #20884]
Ruby::Box
For the detail of "Ruby Box", see doc/language/box.md.
[Feature #21311] [Misc #21385]
Set
Setis now a core class, instead of an autoloaded stdlib class.[Feature #21216] (Move Set to a core class [Ruby 4.0] #9066)
Set#inspectnow uses a simpler display, similar to literal arrays.(e.g.,
Set[1, 2, 3]instead of#<Set: {1, 2, 3}>). [Feature #21389]Passing arguments to
Set#to_setandEnumerable#to_setis now deprecated.[Feature #21390]
Socket
Socket.tcp&TCPSocket.newacceptsopen_timeoutas a keyword argument to specifythe timeout for the initial connection. [Feature #21347]
TCPSocket.new, eitherErrno::ETIMEDOUTor
IO::TimeoutErrorcould previously be raised depending on the situation.This behavior has been unified so that
IO::TimeoutErroris now consistently raised.(Please note that, in
Socket.tcp, there are still cases whereErrno::ETIMEDOUTmay be raised in similar situations, and that in both cases
Errno::ETIMEDOUTmay beraised when the timeout occurs at the OS level.)
String
Update Unicode to Version 17.0.0 and Emoji Version 17.0 #9250
[Feature #19908][Feature #20724] (also applies to Regexp)
String#strip,strip!,lstrip,lstrip!,rstrip, andrstrip!are extended to accept
*selectorsarguments. [Feature #21552] (String#split and rsplit do not support selectors (Ruby 4.0) #9267)Thread
Thread#raise(cause:)argument similar toKernel#raise. [Feature #21360]Stdlib updates
The following bundled gems are promoted from default gems.
We only list stdlib changes that are notable feature changes.
Other changes are listed in the following sections. We also listed release
history from the previous bundled version that is Ruby 3.3.0 if it has GitHub
releases.
The following default gem is added.
The following default gems are updated.
The following bundled gems are added.
The following bundled gems are updated.
Supported platforms
Windows
This means Visual Studio 2015 or later is now required.
Compatibility issues
The following methods were removed from Ractor due because of
Ractor::Port:Ractor.yieldRactor#takeRactor#close_incomingRactor#close_outgoging[Feature #21262]
ObjectSpace._id2refis deprecated. [Feature #15408]Process::Status#&andProcess::Status#>>have been removed.They were deprecated in Ruby 3.3. [Bug #19868]
rb_path_checkhas been removed. This function was used for$SAFEpath checking which was removed in Ruby 2.7,and was already deprecated.
[Feature #20971]
A backtrace for
ArgumentErrorof "wrong number of arguments" nowinclude the receiver's class or module name (e.g., in
Foo#barinstead of in
bar). [Bug #21698]Backtraces no longer display
internalframes.These methods now appear as if it is in the Ruby source file,
consistent with other C-implemented methods. [Bug #20968]
Before:
After:
Stdlib compatibility issues
CGI library is removed from the default gems. Now we only provide
cgi/escapeforthe following methods:
CGI.escapeandCGI.unescapeCGI.escapeHTMLandCGI.unescapeHTMLCGI.escapeURIComponentandCGI.unescapeURIComponentCGI.escapeElementandCGI.unescapeElement[Feature #21258]
With the move of
Setfrom stdlib to core class,set/sorted_set.rbhasbeen removed, and
SortedSetis no longer an autoloaded constant. Pleaseinstall the
sorted_setgem andrequire 'sorted_set'to useSortedSet.[Feature #21287]
Net::HTTP
Content-Typeheaderto
application/x-www-form-urlencodedfor requests with a body(e.g.,
POST,PUT) when the header was not explicitly set has beenremoved. If your application relied on this automatic default, your
requests will now be sent without a Content-Type header, potentially
breaking compatibility with certain servers.
[GH-net-http #205]
Implementation improvements
Ractor
A lot of work has gone into making Ractors more stable, performant, and usable. These improvements bring Ractors implementation closer to leaving experimental status.
object_idavoids locking in most cases