Ruby

What’s new in Ruby 2.6

The dynamic web language gets a just-in-time compiler — with a twist
Pro
(Image: Ruby)

7 January 2019

Ruby 2.6, the latest version of the venerable dynamic language, is now available as a production release.

The new
Ruby 2.6 adds an initial implementation of a JIT (just-in-time compiler) to improve performance of program execution. Ruby’s JIT compiler writes C code to disk and produces a C compiler process to generate native code. The JIT compiler is supported when Ruby is built by the GCC compiler, Clang, or Microsoft Visual C++, which must be available at runtime.

Other new features in Ruby 2.6 include:

  • In a change to the language, $SAFEis a process global state and 0 can be set again.
  • Improved performance of callwhen block is passed in as a block parameter.
  • Proc#callhas been sped up.
  • The experimental RubyVM::ASTmodule, which has a parse method that parses a code of string and returns AST nodes. Also, the parse_ filemethod parses a code file and return AST nodes.
  • The experimental RubyVM::AST::Nodeclass surfaces location information and children nodes from Node
  • Constant names may start with a non-ASCII capital letter.
  • Endless ranges, which work as if they have no end, are introduced.
  • Transient Heap (theap) is introduced, with theapserving as a managed heap for short-lived memory objects that are referenced by specific classes.
  • Unicode support is now at version 11.
  • Bundler, for managing gem dependencies, is now a default gem.

Download Ruby 2.6
You can download Ruby 2.6 from the Ruby project web site.

Previous version: Ruby 2.5
Arriving on Christmas Day 2017, Ruby 2.5.0 is the first stable release in the 2.5 series.

It boosts performance by 5 to 10% by removing trace instructions from bytecode that has been found to be overhead. A dynamic instrumentation technique is used instead. Also, block passing by a block parameter has been made three times faster than it was in Ruby 2.4, through use of the Lazy Proc allocation technique.

Other features that improve performance include:

  • Document generation has been boosted by switching from the legacy lexical analyser from IRB to Ripper.
  • The Mutexclass has been rewritten to make it smaller and faster. Mutex can be used to manage access to shared data from concurrent threads.
  • ERB generates code from a template at twice the speed as version 2.4.
  • Performance has been improved in built-in methods including Array#concat, Enumerable#sort_by, and String#concat.

Other improvements in Ruby 2.5 include:

  • Struct/newcan create classes that accept keyword arguments.
  • Do/endblocks will now work directly with ensure/rescue/else.
  • The pp.rb library loads automatically.
  • An option has been added to print backtrace in reverse order. The intent is to get the main error message without needing to scroll.
  • To improve testing, support is offered for branch and method coverage measurement. Branch coverage reveals which branches are executed, while method coverage indicates which methods are invoked.

Ruby 2.5 also features a bug fix in which the SecureRandom library, for generating random numbers, which now prefers OS-provided sources over OpenSSL. Also, standard libraries such as cmath, csv, date, dbm, and ipaddr have been promoted to gems.

Download Ruby 2.5
You can download version 2.5 by opening this tar.gz file or this Zip file.

 

IDG News Service

Read More:


Back to Top ↑

TechCentral.ie