BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Ruby 2.5.0 Overview

Ruby 2.5.0 Overview

Leia em Português

This item in japanese

Following the Christmas tradition for a sixth year in a row, a new major release of Ruby was released on December 25th. Ruby 2.5.0 features performance enhancements, improvements to Struct initialisation, the ability to print stacktraces in reverse order and more, and several common libraries have been promoted to default gems.

Ruby 2.5.0 features several performance related improvements with the most notable being removing all trace instructions from bytecode, thus improving performance by 5-10%. Trace instructions were added to support TracePoint, however in most cases TracePoint wasn’t used, adding pure overhead. Ruby now supports a dynamic instrumentation technique. Other performance related improvements include three times faster block passing as a block parameter and two times faster ERB code generation from templates. Performance has also been improved for built in functions like Array#concat, String#concat and Enumerable#sort_by and the Mutex class used in multithreading.

Aside from performance improvements, Struct.new can now create classes that accept keyword arguments and do/end blocks can work directly with ensure/rescue/else flows.

On library support, the following standard libraries cmath, csv, date, dbm, etc, fcntl, fiddle, fileutils, gdbm, ipaddr, scanf, sdbm, stringio, strscan, webrick, zlib have been promoted to default gems, while the favorite pp command now comes built-in with ruby eliminating the need for "require ‘pp’ " -- which is one of the most commonly written lines of code in Ruby.

Ruby developers now have the option to print stacktrace in reverse order, the intent being to reveal the main error message on top instead of the bottom of the trace. This feature is experimental and may be removed at a later release. Branch and method coverage measurement is also supported, allowing for better performance testing around invocations of different methods and branches during code execution.

Top level constant lookup has now been completely deprecated, emitting an error instead of a warning. yield_self has been added to yield a given block in its context and unlike tap, also return the block result, which can be useful for object chaining.

Ruby 2.5.0 can be downloaded from the official site.

Rate this Article

Adoption
Style

BT