Latest in branch 2.4
2.4.10
Released 31 Mar 2020
(6 years ago)
SoftwareRuby
Version2.4
Status
End of life
Initial release2.4.0
25 Dec 2016
(9 years ago)
Latest release2.4.10
31 Mar 2020
(6 years ago)
End of bug fixes01 Apr 2019
(Ended 7 years, 2 months ago)
End of life31 Mar 2020
(Ended 6 years, 2 months ago)
Release notes https://ruby-lang.org/en/news/2020/03/31/ruby-2-4-10-released/
Source codehttps://github.com/ruby/ruby/tree/v2_4_10
Documentationhttps://ruby-doc.org
Downloadhttps://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.10.tar.gz
Ruby 2.4 ReleasesView full list

What Is New in Ruby 2.4

Ruby 2.4 brings a host of improvements focused on performance, new capabilities, and modernizing the language. Here's a quick overview of the key changes.

Category Key Changes
Language Features Top-level return, Binding#irb, Refinements for instance methods
Performance Faster Fixnum and Bignum unification, Regexp match?, String#match?, Thread#wakeup
Standard Library OpenSSL 1.1.0, Updated libraries (RubyGems, RDoc, BigDecimal, etc.)
Deprecations Fixnum & Bignum classes, Dir#exists?, File#exists?

What new language features were introduced?

Ruby 2.4 added syntactic sugar and debugging aids that make development smoother. The most notable is the ability to return from the top-level of a program.

You can now use return in the main context, which exits the script. The new Binding#irb method drops you into an IRB session at any point in your code, which is fantastic for live debugging.

Refinements also got more powerful. You can now use them on instance methods like instance_method and instance_methods, giving you finer control over monkey-patching scope.

How did performance improve in this release?

This release tackled performance from several angles, with the unification of Fixnum and Bignum into Integer being the headline act. This simplification cleans up the internals and can speed up certain integer operations.

Regexp matching got faster with the new match? method. Unlike match or =~, it avoids creating a MatchData object and backreferences, which reduces overhead for simple truthy checks.

Other optimizations include a faster Thread#wakeup and improvements to the garbage collector and memory allocation. In practice, these micro-optimizations add up to a snappier experience.

What was updated in the standard library?

The standard library received its usual round of updates, with OpenSSL getting a major bump to version 1.1.0. This matters because it supports newer protocols and cryptographic algorithms.

Several bundled libraries were updated, including RubyGems 2.6.8, RDoc 5.0.0, and BigDecimal 1.3.0. The net modules (net-ftp, net-imap, net-smtp) now use the timeout options from the socket, making network timeouts more consistent.

What was deprecated and needs changing?

This release started the process of cleaning up old naming conventions. The Fixnum and Bignum classes are now deprecated and unified under Integer. You should use Integer for all new code.

The methods Dir.exists? and File.exists? are also deprecated in favor of Dir.exist? and File.exist?. The change aligns the method names with other predicate methods like Array#exist?.

FAQ

What happens to my Fixnum and Bignum constants?
They are now aliases to the Integer class. Your existing code will work, but you'll see deprecation warnings. The long-term fix is to replace them with Integer everywhere.

When should I use Regexp#match? instead of =~?
Use match? when you only need a boolean answer for a match. It's faster because it doesn't create MatchData objects or set global variables like $~.

Is the OpenSSL update backwards compatible?
Upgrading to OpenSSL 1.1.0 could have compatibility implications with very old systems or specific ciphers. You should test your application's TLS connections after upgrading.

How do I use the new Binding#irb method?
Just add binding.irb anywhere in your code. When execution hits that line, it will launch an IRB session in your terminal with the current context, similar to binding.pry from Pry.

What's the deal with the top-level return?
It allows a return statement in the main scope to exit the script entirely. Before 2.4, a top-level return would raise a LocalJumpError.

Releases In Branch 2.4

VersionRelease date
2.4.1031 Mar 2020
(6 years ago)
2.4.902 Oct 2019
(6 years ago)
2.4.801 Oct 2019
(6 years ago)
2.4.728 Aug 2019
(6 years ago)
2.4.601 Apr 2019
(7 years ago)
2.4.517 Oct 2018
(7 years ago)
2.4.428 Mar 2018
(8 years ago)
2.4.314 Dec 2017
(8 years ago)
2.4.214 Sep 2017
(8 years ago)
2.4.122 Mar 2017
(9 years ago)
2.4.025 Dec 2016
(9 years ago)
2.4.0-rc112 Dec 2016
(9 years ago)
2.4.0-preview309 Nov 2016
(9 years ago)
2.4.0-preview208 Sep 2016
(9 years ago)
2.4.0-preview120 Jun 2016
(9 years ago)