NEWS for Ruby 2.3.0

This document is a list of user visible feature changes made between releases except for bug fixes.

Note that each entry is kept so brief that no reason behind or reference information is supplied with. For a full list of changes with all sufficient information, see the ChangeLog file or Redmine (e.g. https://bugs.ruby-lang.org/issues/$FEATURE_OR_BUG_NUMBER)

Changes since the 2.2.0 release

Language changes

  • frozen-string-literal pragma:

    • new pragma, frozen-string-literal has been experimentally introduced.

      Feature #8976
    • besides, –enable/–disable=frozen-string-literal options also have been introduced. [Feature #8976]

    • command line options –debug or –debug=frozen-string-literal enable additional debugging mode which shows created location with at frozen object error (RuntimeError).

      Feature #11725
  • safe navigation operator:

    • new method call syntax, `object&.foo', method foo is called on `object' if it is not nil. this is similar to `try!' in Active Support, except:

      • method name is syntactically required

        obj.try! {} # valid
        obj&. {}    # syntax error
      • arguments are evaluated only if a call is made:

        obj.try!(:foo, bar())  # bar() is always evaluated
        obj&.foo(bar())        # bar() is conditionally evaluated
        
      • attribute assignment is valid

        obj&.attr += 1
        
      Feature #11537
  • the did_you_mean gem:

    • When a NameError or NoMethodError occurs because of a typo in the name, the did_you_mean gem automatically suggests other names similar to the method name.

      "Yuki".starts_with?("Y")
      # => NoMethodError: undefined method `starts_with?' for "Yuki":String
      #    Did you mean?  start_with?
      
  • indented here document:

    • new string literal, here document starts with `<<~`. refer doc/syntax/literals.rdoc for more details.

      Feature #9098

Core classes updates (outstanding ones only)

Core classes compatibility issues (excluding feature bug fixes)

Stdlib updates (outstanding ones only)

Stdlib compatibility issues (excluding feature bug fixes)

Built-in global variables compatibility issues

  • $SAFE

    • $SAFE=2 and $SAFE=3 are obsolete. If $SAFE is set to 2 or larger, an ArgumentError is raised. [Feature #5455]

C API updates

  • rb_define_class_id_under() now raises a TypeError exception when the class is already defined but its superclass does not match the given superclass, as well as definitions in ruby level.

  • rb_timespec_now() is added to fetch current datetime as struct timespec.

    Feature #11558
  • rb_time_timespec_new() is added to create a time object with epoch, nanosecond, and UTC/localtime/time offset arguments. [Feature #11558]

  • rb_autoload() deprecated, use rb_funcall() instead. [Feature #11664]

  • rb_compile_error_with_enc(), rb_compile_error(), and rb_compile_bug() deprecated. these functions are exposed but only for internal use. external libraries should not use them.

Supported platform changes

  • OS/2 is no longer supported

  • BeOS is no longer supported

  • Borland-C is no longer supported

  • Haiku now stable and best effort

Implementation improvements

  • Optimize Proc#call to eliminate method frame construction.

    Feature #11569
  • Reconsidering method entry data structure.

    Bug #11278
  • Introducing new table data structure for ID keys tables used by method table and so on. New table structure is simple and fast than st_table. [Feature #11420]

  • Machine code level tuning for object allocation and method calling code. r52099, r52254

  • RubyVM::InstructionSequence is extended for future improvement.

    Feature #11788
  • Case dispatch is now optimized for all special constant literals including nil, true, and false. Previously, only literal strings, symbols, integers and floats compiled to optimized case dispatch.

    Feature #11769
  • Instance variables on non-pure Ruby classes (T_DATA, T_FILE, etc..) is less expensive to store than before. [Feature #11170]

  • All accesses to members of big Struct objects are performed in constant-time. Previously, Struct elements beyond the first 10 10 elements used a linear scan. [Feature #10585]

  • The Set class got several speed up.

    Misc #10754], [r52591
  • Socket and I/O-related improvements

    • Calling overhead of most of new keyword-using I/O methods in

      Feature #11229

      is reduced by avoiding the inefficient C API

      to parse keywords. [Feature #11339]

    • The standard library is updated to use the improved exception-free non-blocking I/O from [Feature #11229]. This has the additional benefit of quieter $DEBUG output in addition to reducing expensive exceptions. [Feature #11044]

    • (Linux-only) waiting on a single FD anywhere in the stdlib no longer uses select(2), making it immune to slowdowns with high-numbered FDs.

      Feature #11081
      Feature #11377
  • CGI.escapeHTML is optimized with C extention. github.com/ruby/ruby/pull/1164