Saturday, April 20, 2024
HomeRuby On RailsRuby 3.1.0 Launched

Ruby 3.1.0 Launched


We’re happy to announce the discharge of Ruby 3.1.0. Ruby 3.1 retains compatibility with Ruby 3.0 and in addition provides many options.

YJIT: New experimental in-process JIT compiler

Ruby 3.1 merges YJIT, a brand new in-process JIT compiler developed by Shopify.

Since Ruby 2.6 launched MJIT in 2018, its efficiency enormously improved, and at last we achieved Ruby3x3 final yr. However although the Optcarrot benchmark has proven spectacular speedups, the JIT has not benefited actual world enterprise functions.

Lately Shopify contributed many Ruby enhancements to hurry up their Rails software. YJIT is a vital contribution, and goals to enhance the efficiency of Rails functions.

Whereas MJIT is a method-based JIT compiler and makes use of an exterior C compiler, YJIT makes use of Fundamental Block Versioning and features a JIT compiler inside it. With Lazy Fundamental Block Versioning (LBBV) it first compiles the start of a way, and incrementally compiles the remaining when the kind of arguments and variables are dynamically decided. See YJIT: a primary block versioning JIT compiler for CRuby for an in depth introduction.

With this expertise, YJIT achieves each quick warmup time and efficiency enhancements on most real-world software program, as much as 22% on railsbench, 39% on liquid-render.

YJIT remains to be an experimental function, and as such, it’s disabled by default. If you wish to use this, specify the --yjit command-line choice to allow YJIT. It is usually restricted to Unix-like x86-64 platforms for now.

debug gem: A brand new debugger

A totally rewritten debugger debug.gem is bundled. debug.gem has the next options:

  • Enhance the debugging efficiency (it doesn’t decelerate the applying even with the debugger).
  • Assist distant debugging.
  • Assist wealthy debugging frontend (VS Code and Chrome browser are supported at present).
  • Assist multi-process/multi-thread debugging.
  • Colourful REPL.
  • And different helpful options like report & replay function, tracing function and so forth.

Ruby had bundled lib/debug.rb, nevertheless it was not nicely maintained and it had points about efficiency and options. debug.gem replaces lib/debug.rb fully.

error_highlight: Advantageous-grained error location in backtrace

A built-in gem, error_highlight, has been launched. It consists of fine-grained error location in backtraces:

$ ruby take a look at.rb
take a look at.rb:1:in `<most important>': undefined technique `time' for 1:Integer (NoMethodError)

1.time {}
 ^^^^^
Did you imply?  occasions

At the moment, solely NameError is supported.

This gem is enabled by default. You possibly can disable it by utilizing the command-line choice --disable-error_highlight. See the error_highlight repository for particulars.

IRB Autocomplete and Documentation Show

The IRB now has an autocomplete function, the place you’ll be able to simply kind within the code, and the completion candidates dialog will seem. You should use Tab and Shift+Tab to maneuver up and down.

If documentation is put in when you choose a completion candidate, the documentation dialog will seem subsequent to the completion candidates dialog, displaying a part of the content material. You possibly can learn the complete documentation by urgent Alt+d.

Different Notable New Options

Language

  • Values in Hash literals and key phrase arguments will be omitted. [Feature #14579]
    • {x:, y:} is syntax sugar for {x: x, y: y}.
    • foo(x:, y:) is syntax sugar for foo(x: x, y: y).
  • The pin operator (^) in sample matching now takes an expression. [Feature #17411]

    Prime.each_cons(2).lazy.find_all{_1 in [n, ^(n + 2)]}.take(3).to_a
    #=> [[3, 5], [5, 7], [11, 13]]
    
  • Parentheses will be omitted in one-line sample matching. [Feature #16182]

    [0, 1] => _, x
    {y: 2} => y:
    x #=> 1
    y #=> 2
    

RBS

RBS is a language to explain the construction of Ruby applications. See the RBS repository for particulars.

Updates since Ruby 3.0.0:

  • Generic kind parameters will be bounded. (PR)
  • Generic kind aliases are supported. (PR)
  • rbs assortment has been launched to handle gems’ RBSs. (doc)
  • Many signatures for built-in and customary libraries have been added/up to date.
  • It consists of many bug fixes and efficiency enhancements too.

See the RBS changelog for extra data.

TypeProf

TypeProf is a static kind analyzer for Ruby. It generates a prototype of RBS from non-type-annotated Ruby code. See the documentation for particulars.

The primary replace since Ruby 3.0.0 is an experimental IDE help referred to as “TypeProf for IDE”.

The VS Code extension exhibits a guessed (or explicitly written in an RBS file) technique signature above every technique definition, attracts a pink underline underneath the code which will trigger a reputation error or kind error, and completes technique names (i.e., exhibits technique candidates). See the documentation for particulars.

Additionally, the discharge consists of many bug fixes and efficiency enhancements.

Efficiency enhancements

  • MJIT
    • For workloads like Rails, the default --jit-max-cache is modified from 100 to 10000.
      The JIT compiler not skips compilation of strategies longer than 1000 directions.
    • To help Zeitwerk of Rails, JIT-ed code is not cancelled
      when a TracePoint for sophistication occasions is enabled.

Different notable modifications since 3.0

Customary libraries updates

  • The next default gems are up to date.
    • RubyGems 3.3.3
    • base64 0.1.1
    • benchmark 0.2.0
    • bigdecimal 3.1.1
    • bundler 2.3.3
    • cgi 0.3.1
    • csv 3.2.2
    • date 3.2.2
    • did_you_mean 1.6.1
    • digest 3.1.0
    • drb 2.1.0
    • erb 2.2.3
    • error_highlight 0.3.0
    • and so on 1.3.0
    • fcntl 1.0.1
    • fiddle 1.1.0
    • fileutils 1.6.0
    • discover 0.1.1
    • io-console 0.5.10
    • io-wait 0.2.1
    • ipaddr 1.2.3
    • irb 1.4.1
    • json 2.6.1
    • logger 1.5.0
    • net-http 0.2.0
    • net-protocol 0.1.2
    • nkf 0.1.1
    • open-uri 0.2.0
    • openssl 3.0.0
    • optparse 0.2.0
    • ostruct 0.5.2
    • pathname 0.2.0
    • pp 0.3.0
    • prettyprint 0.1.1
    • psych 4.0.3
    • racc 1.6.0
    • rdoc 6.4.0
    • readline 0.0.3
    • readline-ext 0.1.4
    • reline 0.3.0
    • resolv 0.2.1
    • rinda 0.1.1
    • ruby2_keywords 0.0.5
    • securerandom 0.1.1
    • set 1.0.2
    • stringio 3.0.1
    • strscan 3.0.1
    • tempfile 0.1.2
    • time 0.2.0
    • timeout 0.2.0
    • tmpdir 0.1.2
    • un 0.2.0
    • uri 0.11.0
    • yaml 0.2.0
    • zlib 2.1.1
  • The next bundled gems are up to date.
    • minitest 5.15.0
    • power_assert 2.0.1
    • rake 13.0.6
    • test-unit 3.5.3
    • rexml 3.2.5
    • rbs 2.0.0
    • typeprof 0.21.1
  • The next default gems are actually bundled gems. You should add the next libraries to Gemfile underneath the bundler surroundings.
    • net-ftp 0.1.3
    • net-imap 0.2.2
    • net-pop 0.1.1
    • net-smtp 0.3.1
    • matrix 0.4.2
    • prime 0.1.2
    • debug 1.4.0

See NEWS
or the commit logs
for extra particulars.

With these modifications, 3124 recordsdata modified, 551760 insertions(+), 99167 deletions(-)
since Ruby 3.0.0!

Merry Christmas, Completely satisfied Holidays, and luxuriate in programming with Ruby 3.1!

Obtain

  • https://cache.ruby-lang.org/pub/ruby/3.1/ruby-3.1.0.tar.gz

    SIZE: 20103517
    SHA1: e4e8c20dd2a1fdef4d3e5bd5a3461000dd17f226
    SHA256: 50a0504c6edcb4d61ce6b8cfdbddaa95707195fab0ecd7b5e92654b2a9412854
    SHA512: 76009d325e961e601d9a287e36490cbc1f3b5dbf4878fa6eab2c4daa5ff2fed78cbc7525cd87b09828f97cbe2beb30f528928bcc5647af745d03dffe7c5baaa9
    
  • https://cache.ruby-lang.org/pub/ruby/3.1/ruby-3.1.0.tar.xz

    SIZE: 14709096
    SHA1: 92b603c2a69fb25d66c337a63e94280984edea11
    SHA256: 1a0e0b69b9b062b6299ff1f6c6d77b66aff3995f63d1d8b8771e7a113ec472e2
    SHA512: a2bb6b5e62d5fa06dd9c30cf84ddcb2c27cb87fbaaffd2309a44391a6b110e1dde6b7b0d8c659b56387ee3c9b4264003f3532d5a374123a7c187ebba9293f320
    
  • https://cache.ruby-lang.org/pub/ruby/3.1/ruby-3.1.0.zip

    SIZE: 24388179
    SHA1: e37435956d6f840a0e8758d7374bc7e0e346105f
    SHA256: a3bfcd486d09c065d46421da0ff3d430ce4423fefd80cea63c6595d83ae4af0e
    SHA512: 67db71144e06da2c1c25eaf413d1417c99a4b18738a573f9e3371c11ea242eee9dcbdc3de17336f25ab5060039fe034e57298943d344be9cd9eb33bb56e2e1c6
    

What’s Ruby

Ruby was first developed by Matz (Yukihiro Matsumoto) in 1993,
and is now developed as Open Supply. It runs on a number of platforms
and is used all around the world particularly for net improvement.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments