From Fedora Project Wiki


Ruby 2.7

Summary

Ruby 2.7 is the latest stable version of Ruby. Many new features and improvements are included for the increasingly diverse and expanding demands for Ruby. With this major update from Ruby 2.6 in Fedora 31 to Ruby 2.7 in Fedora 32, Fedora becomes the superior Ruby development platform.

Owner

Current status

Detailed Description

Ruby 2.7 is upstream's new major release of Ruby. Many new features and improvements are included.

Compaction GC

This release introduces Compaction GC which can defragment a fragmented memory space.

Some multi-threaded Ruby programs may cause memory fragmentation, leading to high memory usage and degraded speed.

The GC.compact method is introduced for compacting the heap. This function compacts live objects in the heap so that fewer pages may be used, and the heap may be more CoW friendly.

Pattern Matching [Experimental]

Pattern matching, a widely used feature in functional programming languages, is introduced as an experimental feature.

It can traverse a given object and assign its value if it matches a pattern.

REPL improvement

irb, the bundled interactive environment (REPL; Read-Eval-Print-Loop), now supports multi-line editing. It is powered by reline, a readline-compatible pure Ruby implementation. It also provides rdoc integration. In irb you can display the reference for a given class, module, or method.

Besides, source lines shown at binding.irb and inspect results for core-class objects are now colorized.

Separation of positional and keyword arguments

Automatic conversion of keyword arguments and positional arguments is deprecated, and conversion will be removed in Ruby 3.

  • When a method call passes a Hash at the last argument, and when it passes no keywords, and when the called method accepts keywords, a warning is emitted. To continue treating the hash as keywords, add a double splat operator to avoid the warning and ensure correct behavior in Ruby 3.
  • When a method call passes keywords to a method that accepts keywords, but it does not pass enough required positional arguments, the keywords are treated as a final required positional argument, and a warning is emitted. Pass the argument as a hash instead of keywords to avoid the warning and ensure correct behavior in Ruby 3.
  • When a method accepts specific keywords but not a keyword splat, and a hash or keywords splat is passed to the method that includes both Symbol and non-Symbol keys, the hash will continue to be split, and a warning will be emitted. You will need to update the calling code to pass separate hashes to ensure correct behavior in Ruby 3.
  • If a method does not accept keywords, and is called with keywords, the keywords are still treated as a positional hash, with no warning. This behavior will continue to work in Ruby 3.
  • Non-symbols are allowed as keyword argument keys if the method accepts arbitrary keywords.
  • **nil is allowed in method definitions to explicitly mark that the method accepts no keywords. Calling such a method with keywords will result in an ArgumentError.
  • Passing an empty keyword splat to a method that does not accept keywords no longer passes an empty hash, unless the empty hash is necessary for a required parameter, in which case a warning will be emitted. Remove the double splat to continue passing a positional hash.

Other Notable New Features

  • Numbered parameter as the default block parameter is introduced as an experimental feature.
  • A beginless range is experimentally introduced. It might not be as useful as an endless range, but would be good for DSL purposes.
  • Enumerable#tally is added. It counts the occurrence of each element.
  • Calling a private method on self is now allowed.
  • Enumerator::Lazy#eager is added. It generates a non-lazy enumerator from a lazy enumerator.

Performance improvements

  • JIT [Experimental]
    • JIT-ed code is recompiled to less-optimized code when an optimization assumption is invalidated.
    • Method inlining is performed when a method is considered as pure. This optimization is still experimental and many methods are NOT considered as pure yet.
    • The default value of --jit-min-calls is changed from 5 to 10,000.
    • The default value of --jit-max-cache is changed from 1,000 to 100.
  • The performance of CGI.escapeHTML is improved.
  • The performance of Monitor and MonitorMixin is improved.

Other notable changes since 2.6

  • Some standard libraries are updated.
  • Big part of stdlib was to default gems.
  • Proc.new and proc with no block in a method called with a block is warned now.
  • lambda with no block in a method called with a block errs.
  • Update Unicode version and Emoji version from 11.0.0 to 12.0.0.
  • Update Unicode version to 12.1.0, adding support for U+32FF SQUARE ERA NAME REIWA.
  • Date.jisx0301, Date#jisx0301, and Date.parse support the new Japanese era.
  • Require compilers to support C99.

Benefit to Fedora

With a latest release, Ruby language is supporting the newest language features, which enables even faster and easier development of Ruby applications.

Scope

  • Other developers: N/A (not a System Wide Change)
    • Rebuild of packages with binary extensions (i.e. packages which depends on libruby) will be handled automatically, but some packages might need fixes/updates to support Ruby 2.7 properly.
  • Release engineering: #9104 (a check of an impact with Release Engineering is needed)
    • Separate Koji tag for package rebuild will be needed.
  • Policies and guidelines: N/A (not a System Wide Change)
  • Trademark approval: N/A (not needed for this Change)

Upgrade/compatibility impact

  • User specific Ruby binary extensions need to be rebuild.

How To Test

  • No special hardware is needed.
  • To test, install Ruby 2.7. The test builds are pusblished in PR or on Ruby-SIG ML
  • Try to locally rebuild your packages using Ruby 2.7.
  • Use the packages with your applications previously written in Ruby.
  • If something doesn't work as it should, let us know.

User Experience

The Ruby programs/scripts should behave as they were used to.

Dependencies

$ dnf repoquery --disablerepo=* --enablerepo=rawhide --enablerepo=rawhide-source --arch=src --whatrequires 'ruby-devel' | sort | uniq | wc -l
142

Contingency Plan

  • Contingency mechanism: We would like to get a special buildroot tag to be able to rebuild necessary the packages with Ruby 2.7. If anything goes wrong, the tag could be easily dropped and previous version of Ruby 2.6 and its dependencies stays intact. The tag would be merged into F32 after everything is rebuild.
  • Contingency deadline: Mass Rebuild
  • Blocks release? No (not a System Wide Change), Yes/No
  • Blocks product? No

Documentation

Release Notes

  • The Ruby 2.7 bumps soname, therefore Ruby packages, which use binary extensions, should be rebuilt. Nevertheless, since upstream paid great attention to source compatibility, no changes to your code are needed.

https://github.com/ruby/ruby/blob/master/NEWS