What's New in Ruby 2.5?

Sam Backus

@SamBackus

sbackus@patientslikeme.com

Happy Holidays!

Follow along

$ rbenv install 2.5.0

or

$ rvm install 2.5.0

 

Speed Improvements!

Speed Improvements!

  • About 5-10% performance improvement by removing all trace instructions from overall bytecode

  • Block passing by a block parameter (e.g. def foo(&b); bar(&b); end) is about 3 times faster than Ruby 2.4 by “Lazy Proc allocation”

  • Mutex is rewritten to be smaller and faster

  • ERB now generates code from a template twice as fast

  • Improve performance of some built-in methods

  • IO.copy_stream uses copy_file_range(2) to copy offload

Oldest call first, most recent call last.

Print backtrace and error message in reverse order

Note: the order is reversed only when the backtrace is printed out to the terminal directly.

rescue/else/ensure are now allowed to be used directly with do/end blocks

Array#prepend/append

as aliases of unshift/push

Kernel#yield_self

Enumerable#any?, all?, none?, and one? accept a pattern argument.

String#delete_prefix

String#delete_suffix

Hash#slice and Hash#transform_keys

Follow along

$ rbenv install 2.6.0-rc2

Speed improvements!

  • Proc#call is 1.4x faster
  • block.call is 2.4x faster when passed a block
  • Transient Heap is introduced, making small and short lived hash objects 2x faster.

Speed improvements!

New JIT compiler

slower startup time

faster runtime

New JIT compiler

How to use: Just specify --jit in command line or $RUBYOPT environment variable

yield_self aliased to then

Endless ranges (1..)

Array#union 

Array#difference

Array#filter is a new alias for Array#select

Merge Bundler as Default gem

You no longer need  to gem install bundler

References: 

Ruby 2.6

By Sam Backus

Ruby 2.6

What's new in Ruby 2.6

  • 339