Ruby 3.0.0 has been officially released. Ruby 3, whose goal is performance, concurrency, and Typing. Especially about performance, Matz stated “Ruby3 will be 3 times faster than Ruby2” a.k.a. Ruby 3×3.

Optcarrot 3000 frames

With Optcarrot benchmark, which measures single thread performance based on NES’s game emulation workload, it achieved 3x faster performance than Ruby 2.0!

These were measured at the environment written in https://benchmark-driver.github.io/hardware.html. 8c510e4095 was used as Ruby 3.0. It may not be 3x faster depending on your environment or benchmark.

Ruby 3.0.0 covers those goals by

  • Performance
    • MJIT
  • Concurrency
    • Ractor
    • Fiber Scheduler
  • Typing (Static Analysis)
    • RBS
    • TypeProf

With above performance improvement Ruby 3.0 introduces a number of new features described below.

Performance

When I first declared “Ruby3x3” in the conference keynote, many including members of the core team felt “Matz is a boaster”. In fact, I felt so too. But we did. I am honored to see the core team actually accomplished to make Ruby3.0 three times faster than Ruby2.0 (in some benchmarks). – Matz

MJIT

Many improvements were implemented in MJIT. See NEWS for details.

As of Ruby 3.0, JIT is supposed to give performance improvements in limited workloads, such as games (Optcarrot), AI (Rubykon), or whatever application that spends majority of time in calling a few methods many times.

Although Ruby 3.0 significantly decreased a size of JIT-ed code, it is still not ready for optimizing workloads like Rails, which often spend time on so many methods and therefore suffer from i-cache misses exacerbated by JIT. Stay tuned for Ruby 3.1 for further improvements on this issue.

Concurrency / Parallel

It’s multi-core age today. Concurrency is very important. With Ractor, along with Async Fiber, Ruby will be a real concurrent language. — Matz

Ractor (experimental)

Ractor is an Actor-model like concurrent abstraction designed to provide a parallel execution feature without thread-safety concerns.

You can make multiple ractors and you can run them in parallel. Ractor enables you to make thread-safe parallel programs because ractors can not share normal objects. Communication between ractors are supported by exchaning messages.

To limit sharing of objects, Ractor introduces several restrictions to the Ruby’s syntax (without multiple Ractors, there is no restriction).

The specification and implementation are not matured and may be changed in the future, so this feature is marked as experimental and show the “experimental feature” warning when the first Ractor.new.

The following small program measures the execution time of famous benchmark tak function (Tak (function) – Wikipedia), by executing it 4 times sequentially or 4 times in parallel with ractors.

def tarai(x, y, z) =
  x <= y ? y : tarai(tarai(x-1, y, z),
                     tarai(y-1, z, x),
                     tarai(z-1, x, y))
require 'benchmark'
Benchmark.bm do |x|
  # sequential version
  x.report('seq'){ 4.times{ tarai(14, 7, 0) } }

  # parallel version
  x.report('par'){
    4.times.map do
      Ractor.new { tarai(14, 7, 0) }
    end.each(&:take)
  }
end
Benchmark result:
          user     system      total        real
seq  64.560736   0.001101  64.561837 ( 64.562194)
par  66.422010   0.015999  66.438009 ( 16.685797)

The result was measured on Ubuntu 20.04, Intel(R) Core(TM) i7-6700 (4 cores, 8 hardware threads). It shows that the parallel version is 3.87 times faster than the sequential version.

See doc/ractor.md for more details.

Fiber Scheduler

Fiber#scheduler is introduced for intercepting blocking operations. This allows for light-weight concurrency without changing existing code. Watch “Don’t Wait For Me, Scalable Concurrency for Ruby 3” for an overview of how it works.

Currently supported classes/methods:

  • Mutex#lockMutex#unlockMutex#sleep
  • ConditionVariable#wait
  • Queue#popSizedQueue#push
  • Thread#join
  • Kernel#sleep
  • Process.wait
  • IO#waitIO#readIO#write and related methods (e.g. #wait_readable#gets#puts and so on).
  • IO#select is not supported.

This example program will perform several HTTP requests concurrently:

require 'async'
require 'net/http'
require 'uri'

Async do
  ["ruby", "rails", "async"].each do |topic|
    Async do
      Net::HTTP.get(URI "https://www.google.com/search?q=#{topic}")
    end
  end
end

It uses async which provides the event loop. This event loop uses the Fiber#scheduler hooks to make Net::HTTP non-blocking. Other gems can use this interface to provide non-blocking execution for Ruby, and those gems can be compatible with other implementations of Ruby (e.g. JRuby, TruffleRuby) which can support the same non-blocking hooks.

Static Analysis

2010s were an age of statically type programming languages. Ruby seeks the future with static type checking, without type declaration, using abstract interpretation. RBS & TypeProf are the first step to the future. More steps to come. — Matz

RBS

RBS is a language to describe the types of Ruby programs.

Type checkers including TypeProf and other tools supporting RBS will understand Ruby programs much better with RBS definitions.

You can write down the definition of classes and modules: methods defined in the class, instance variables and their types, and inheritance/mix-in relations.

The goal of RBS is to support commonly seen patterns in Ruby programs and it allows writing advanced types including union types, method overloading, and generics. It also supports duck typing with interface types.

Ruby 3.0 ships with rbs gem, which allows parsing and processing type definitions written in RBS. The following is a small example of RBS with class, module, and constant definitions.

module ChatApp
  VERSION: String
  class Channel
    attr_reader name: String
    attr_reader messages: Array[Message]
    attr_reader users: Array[User | Bot]              # `|` means union types, `User` or `Bot`.
    def initialize: (String) -> void
    def post: (String, from: User | Bot) -> Message   # Method overloading is supported.
            | (File, from: User | Bot) -> Message
  end
end

See README of rbs gem for more detail.

TypeProf

TypeProf is a type analysis tool bundled in the Ruby package.

Currently, TypeProf serves as a kind of type inference.

It reads plain (non-type-annotated) Ruby code, analyzes what methods are defined and how they are used, and generates a prototype of type signature in RBS format.

Here is a simple demo of TypeProf.

An example input:

# test.rb
class User
  def initialize(name:, age:)
    @name, @age = name, age
  end
  attr_reader :name, :age
end
User.new(name: "John", age: 20)

An example output:

$ typeprof test.rb
# Classes
class User
  attr_reader name : String
  attr_reader age : Integer
  def initialize : (name: String, age: Integer) -> [String, Integer]
end

You can run TypeProf by saving the input as “test.rb” and invoke a command called “typeprof test.rb”.

You can also try TypeProf online. (It runs TypeProf on the server side, so sorry if it is out!)

See the documentation and demos for details.

TypeProf is experimental and not so mature yet; only a subset of the Ruby language is supported, and the detection of type errors is limited. But it is still growing rapidly to improve the coverage of language features, the analysis performance, and usability. Any feedback is very welcome.

Other Notable New Features

  • One-line pattern matching is redesigned. (experimental)
    • => is added. It can be used as like rightward assignment.
      0 => a
      p a #=> 0
      
      {b: 0, c: 1} => {b:}
      p b #=> 0
      
    • in is changed to return true or false.
      # version 3.0
      0 in 1 #=> false
      
      # version 2.7
      0 in 1 #=> raise NoMatchingPatternError
      
  • Find pattern is added. (experimental)
    case ["a", 1, "b", "c", 2, "d", "e", "f", 3]
    in [*pre, String => x, String => y, *post]
      p pre  #=> ["a", 1]
      p x    #=> "b"
      p y    #=> "c"
      p post #=> [2, "d", "e", "f", 3]
    end
    
  • Endless method definition is added.
    def square(x) = x * x
    
  • Hash#except is now built-in.
    h = { a: 1, b: 2, c: 3 }
    p h.except(:a) #=> {:b=>2, :c=>3}
    
  • Memory view is added as an experimental feature
    • This is a new C-API set to exchange a raw memory area, such as a numeric array and a bitmap image, between extension libraries. The extension libraries can share also the metadata of the memory area that consists of the shape, the element format, and so on. Using these kinds of metadata, the extension libraries can share even a multidimensional array appropriately. This feature is designed by referring to Python’s buffer protocol.

Performance improvements

  • Pasting long code to IRB is 53 times faster than bundled with Ruby 2.7.0. For example, the time required to paste this sample code goes from 11.7 seconds to 0.22 seconds.

  • The measure command has been added to IRB. It allows simple execution time measurement.
    irb(main):001:0> 3
    => 3
    irb(main):002:0> measure
    TIME is added.
    => nil
    irb(main):003:0> 3
    processing time: 0.000058s
    => 3
    irb(main):004:0> measure :off
    => nil
    irb(main):005:0> 3
    => 3
    

Other notable changes since 2.7

  • Keyword arguments are separated from other arguments.
    • In principle, code that prints a warning on Ruby 2.7 won’t work. See the document in detail.
    • By the way, arguments forwarding now supports leading arguments.
      def method_missing(meth, ...)
        send(:"do_#{ meth }", ...)
      end
      
  • Pattern matching (case/in) is no longer experimental.
  • The $SAFE feature was completely removed; now it is a normal global variable.
  • The order of backtrace had been reversed at Ruby 2.5, and is reverted. Now it behaves like Ruby 2.4; an error message and the line number where the exception occurs are printed first, and its callers are printed later.
  • Some standard libraries are updated.
    • RubyGems 3.2.3
    • Bundler 2.2.3
    • IRB 1.3.0
    • Reline 0.2.0
    • Psych 3.3.0
    • JSON 2.5.1
    • BigDecimal 3.0.0
    • CSV 3.1.9
    • Date 3.1.0
    • Digest 3.0.0
    • Fiddle 1.0.6
    • StringIO 3.0.0
    • StringScanner 3.0.0
    • etc.
  • The following libraries are no longer bundled gems or standard libraries. Install the corresponding gems to use these features.
    • sdbm
    • webrick
    • net-telnet
    • xmlrpc
  • The following default gems are now bundled gems.
    • rexml
    • rss
  • The following stdlib files are now default gems and are published on rubygems.org.
    • English
    • abbrev
    • base64
    • drb
    • debug
    • erb
    • find
    • net-ftp
    • net-http
    • net-imap
    • net-protocol
    • open-uri
    • optparse
    • pp
    • prettyprint
    • resolv-replace
    • resolv
    • rinda
    • set
    • securerandom
    • shellwords
    • tempfile
    • tmpdir
    • time
    • tsort
    • un
    • weakref
    • digest
    • io-nonblock
    • io-wait
    • nkf
    • pathname
    • syslog
    • win32ole

See NEWS or commit logs for more details.

With those changes, 4028 files changed, 200058 insertions(+), 154063 deletions(-) since Ruby 2.7.0!

Ruby3.0 is a milestone. The language is evolved, keeping compatibility. But it’s not the end. Ruby will keep progressing, and become even greater. Stay tuned! — Matz

Merry Christmas, Happy Holidays, and enjoy programming with Ruby 3.0!

243 Replies to “Ruby 3.0.0 Released”

  1. Viagra vs viagra https://www.ecosia.org/search?q=“My Canadian Pharmacy – Extensive Assortment of Medications – 2022”

    You suggested that terrifically!

  2. us essay writing service
    best essay writing
    discount essay writing service

  3. help writing essay
    mba essay help
    community service essays

  4. order stromectol no prescription https://sanangelolive.com/members/girsagerea

    Information certainly considered!.

  5. best mba essay editing service
    essay services
    help writing college essays

  6. help write an essay
    service essay writing
    college essay help service

  7. canadian mail order pharmacies https://www.audiologysolutionsnetwork.org/profile/422019/0

    You made your position pretty nicely!!

  8. good customer service essay
    help writing a essay
    best essay writing service review

  9. canadian online pharmacies https://moaamein.nacda.com/profile/422018/0

    Helpful knowledge. Kudos!

  10. write my essay for money
    help me write a descriptive essay
    college essay writing company

  11. buy college essay
    custom essay service
    college essay help service

  12. essay writing help online
    service essays
    college essay ideas help

  13. canadian discount pharmacies https://supplier.ihrsa.org/profile/421717/0

    You suggested this well!

  14. essay write service
    cheapest custom essay writing
    custom english essays

  15. top essay editing service
    do essay writing services work
    custom essay paper writing

  16. college essay writing help
    top 10 essay writers
    help 123 essay

  17. writing essay services
    write my essay cheap
    nursing essay help

  18. buy ivermectin https://inflavnena.zombeek.cz/

    Truly many of superb info!

  19. Viagra sans ordonnance https://dsdgbvda.zombeek.cz/

    You actually stated it well.

  20. essay writers online cheap
    order cheap essay online
    essays on the movie the help

  21. custom college essay writing service
    buy an essay online
    write my essay for me cheap

  22. custom essay writing toronto
    college essay help
    write my essay

  23. Viagra great britain https://challonge.com/citlitigolf

    You actually reported it fantastically.

  24. essay writer software
    easy essay help
    college essay writer

  25. Viagra manufacturer coupon https://challonge.com/esapenti

    Really plenty of great tips.

  26. help writing essays for college
    essay writing services recommendations
    online help with essay writing

  27. buy essay cheap
    essay writing services for cheap
    looking for someone to write my essay

  28. buy an essay cheap
    who can write my essay
    essay writers review

  29. essay cheap
    macbeth essay help
    best admission essay editing service

  30. essays on the movie the help
    tok essay help
    compare and contrast essay help

  31. buy essay online safe
    medical school essay help
    custom essay help

  32. buying essays
    where can i buy an essay
    essay writing services toronto

  33. cheap essay writer
    buy cheap essay
    help me write my college essay

  34. You actually mentioned that perfectly.
    myself as a writer essay buy cheap essays write my assignments

  35. stromectol for sale online https://500px.com/p/skulogovid/?view=groups

    Many thanks. Loads of postings!

  36. You actually mentioned it perfectly!
    canada drugs pharmacy online pharmacies online pharmacies shipping to usa

  37. essay help online chat
    best custom essay service
    essay help service

  38. help with scholarship essays
    best college essay writing service
    where can i buy an essay online

  39. Factor well utilized.!
    help on writing an essay top 10 essay writers write essay service

  40. Viagra 5 mg 500px.com/p/phraspilliti

    With thanks. Quite a lot of content!

  41. Nicely put. Regards!
    walgreens online pharmacy trust pharmacy canada web medical information

  42. write essay service
    custom essay meister
    argumentative essay helper

  43. You actually expressed that wonderfully.
    what are the steps to writing an essay https://dissertationwritingtops.com/ pre written essays for sale

  44. Info clearly regarded!.
    how to write college application essays write my essay writing essay website

  45. i need help with my essay
    custom essay writing reviews
    customized essay writing

  46. Valuable data. Many thanks.
    indian pharmacy prescription drugs prices online drugstore

  47. mba essay editing service
    services essay
    help me write an essay

  48. Nicely put. Thank you.
    best canadian mail order pharmacies viagra generic online pharmacy cialis canada

  49. Nicely put, Thanks.
    college essay writing service https://topswritingservices.com/ custom of writing letters

  50. 3commensurate

  51. single date online
    best online dating service
    plenty of fish login page

  52. Fantastic info. Regards.
    how to write an cause and effect essay macbeth essay help best content writing websites

  53. Fantastic knowledge. Kudos!
    describe yourself college essay https://service-essay.com/ professional dissertation writing service

  54. dose for stromectol https://glycvimepedd.bandcamp.com/releases

    Fine knowledge. Regards.

  55. buy stromectol https://web904.com/buy-ivermectin-online-fitndance/

    You actually revealed that really well.

  56. Viagra vs viagra vs levitra https://aoc.stamford.edu/profile/goatunmantmen/

    Whoa a lot of beneficial information!

  57. top single service
    dateing
    senior bi log in

  58. Cheers. I enjoy this!
    cheap pharmacy online canadian pharcharmy onlinecanadian online pharmacy shoppers pharmacy

  59. This is nicely put! .
    essay writing for high school students https://dissertationwritingtops.com/ best thesis writing services

  60. Cheers, Numerous facts.
    what to write a college essay about cheap custom essay writing services the best essay writing service

  61. Cheers, Helpful information!
    prescription drug canadian viagra generic pharmacy canadadrugs

  62. Beneficial information. Thank you.
    buy essay online https://quality-essays.com/ professional custom writing service

  63. Kudos, Loads of knowledge.
    teaching essay writing essays writers professional writing services rates

  64. You said it very well.!
    college essay application https://freshapps.space/ essay writing service cheap

  65. Thank you. Awesome stuff!
    prescription drugs from canada pharmacy drug store buy prescription drugs online

  66. buy stromectol https://ktqt.ftu.edu.vn/en/question list/order-stromectol-over-the-counter-10/

    Nicely put, Kudos.

  67. Valuable data. Appreciate it!
    pharmacy online prescription [url=https://canadadrugspower.com]drugs from canada with prescription[/url] cheap pharmacy online https://canadianpharmacyonlinedb.com

  68. Many thanks, I like it.
    cuny college essay how to write an argumentative essay online writing help

  69. canadian pharmacies that ship to us https://ktqt.ftu.edu.vn/en/question list/canadian-pharmaceuticals-for-usa-sales/

    Valuable content. Thanks a lot.

  70. Incredible all kinds of wonderful data!
    how to write introduction essay write my essay speech writing service

  71. gay teens chat
    free gay radom web cam chat
    gay teen cam chat

  72. dirty gay video chat free
    free ohio gay chat rooms
    gay univere men chat

  73. stromectol scabies treatment https://reallygoodemails.com/orderstromectoloverthecounter

    You’ve made the point!

  74. need a personal loan quick, i need a loan desperately. i need education loan i need loan, i need personal loan urgent, cash advance loans till payday, cash advance loans, cash advances, cash advance loans what do i need. Money management have acquired investment, provides business loans. bad credit loan direct lenders fast loan need bad credit loan direct lenders.

  75. ffree gay chat
    gay tranny webcam chat
    chat-avenue/gay

  76. cialis tablets australia pinshape.com/users/2441621-canadian-pharmaceutical-companies

    Good stuff. Kudos.

  77. Kudos. A good amount of write ups!
    how to write an editorial essay resume writing service resume writing services

  78. chat gay miami
    free chat on gay webcam
    snap chat gay solo

  79. free gay chat lines los angeles https://gaymusclechatrooms.com/

  80. gay boy teen boys webcam chat rooms
    cleveland gay chat
    wisconsin gay chat

  81. no 1 canadian pharcharmy online https://www.kadenze.com/users/canadian-pharmaceuticals-for-usa-sales

    Awesome information. Cheers!

  82. gay chat rooms of pa
    anonymous gay chat
    gay discord chat

  83. pharmacie de garde aujourd’hui ixelles pharmacie en ligne rouen pharmacie chu amiens , pharmacie de garde aujourd’hui gratuit therapie comportementale et cognitive duree , traitement zona therapie de couple wikipedia pharmacie rue beaulieu saint just saint rambert therapie act formation therapies cognitivo-comportementales pdf traitement efficace contre les vertiges .
    pharmacie en ligne emla pharmacie en ligne test covid pharmacie de garde waterloo aujourd’hui , pharmacie ile beaulieu nantes pharmacie escudier boulogne billancourt . pharmacie veau pharmacie de garde zone faya pharmacie auchan bethune des therapies alternatives . pharmacie bailly commande en ligne pharmacie bailly saint lazare prix pharmacie amiens nord colvert , pharmacie escudier boulogne billancourt pharmacie lafayette bordeaux , traitement endodontique incendie pharmacie amiens pharmacie gadilhe aix en provence Avapro prix sans ordonnance, Vente Avapro sans ordonnance Avapro sans ordonnance Canada Avapro sans ordonnance Canada Avapro livraison Canada. pharmacie bordeaux ouverte traitement jambes lourdes et douloureuses pharmacie beaulieu puilboreau pharmacie avignon aubagne therapies ciblees oncologie , pharmacie lafayette ivry pharmacie lafayette amiens orthopedie . pharmacie de garde aujourd’hui essonne therapie comportementale et cognitive en gironde pharmacie de garde uzerche

  84. usa casino online
    casino sign up bonus
    free bonus slots

  85. cialis from canada https://onlineviagra.fo.team/

    Cheers, Helpful stuff.

  86. mobile slots
    deposit bonuses
    casino reviews

  87. generic for cialis https://onlineviagra.flazio.com/

    Regards. Numerous facts!

  88. free women dating
    zoosk online dating site
    best dating website

  89. best gay dating sites for southwest florida
    gay trucker dating
    gay sadistic men dating cite

  90. Generic cialis tadalafil https://viagraonlineee.wordpress.com/

    Regards! Valuable information.

  91. best dating apps for gay men
    which senior gay dating app has most members lakeland fl
    victim met killer on gay dating site new yorlk

  92. free for online chatting with singles
    dating web sites for free
    lets-casual-dating

  93. absolutely free local dating site https://freephotodating.com/

  94. hispanic gay dating sites
    best gay dating
    dating site for older gay men

  95. online gambling real money
    online casinos no deposit
    casino reviews

  96. more casino games
    best casino deposit bonus
    best online casino us

  97. avast secureline vpn
    best vpn provider
    buy vpn anonymously

  98. top online casino real money
    online casinos real money
    mobile online casino

  99. free vpn ps4
    safe free vpn
    express vpn free download

  100. free no deposit bonus casino
    no deposit bonus casinos
    casino online real money usa

  101. best free vpn for pc
    free vpn browser
    best buy vpn router

  102. free spins casino
    [url=”https://onlinecasinosdirectory.org”]no deposit sign up bonus[/url]
    no deposit on line casinos

  103. hotspot vpn free
    cyberghost vpn free download
    free vpn chrome

  104. casino games for money
    no deposit online casino real money
    casino welcome bonus

  105. best cheap vpn service
    best free vpn for mac
    vpn for windows free download

  106. best online casino welcome bonus
    casino games that pay real money
    casino usa online

  107. ipvanish vpn free
    best free vpn windows
    best vpn for crypto trading

  108. how to use vpn to buy crypto https://superfreevpn.net/

  109. trust.zone vpn
    vpn gratuit
    best vpn for pc

  110. no deposit bonus online casino
    online casino win real money
    casino bonus no deposit

  111. cash casino games
    no deposit casinos
    casino welcome bonuses

  112. best casino reviews
    blackjack online real money
    bonus casino online

  113. writing a dissertation in a day
    writing dissertation methodology
    buy dissertations

  114. best no deposit bonus
    no deposit free bonus casino
    free online casino no deposit

  115. doctoral dissertation help thesis
    phd dissertation
    books thesis dissertation help

  116. online casinos for usa players
    online spins
    casino free bonus

  117. doctoral dissertation defense
    buy dissertation
    psychology dissertation

  118. online usa casino
    no deposit bonuses
    mobile gambeling

  119. dissertation only phd
    ma dissertation writing service
    dissertation writing

  120. creative writing course in mumbai
    dissertation defense questions
    dissertation completion pathway

  121. writing help
    help-seeking dissertation
    help-seeking dissertation

  122. help dissertation thesis advice
    thesis vs dissertation
    help with dissertation topic

  123. online dissertation help
    online edd no dissertation
    writing dissertation and grant proposals

  124. powerpoint for creative writing
    a dissertation
    dissertations writing

  125. dissertation proposal writing
    dissertation proposal writing services
    online dissertation help

  126. online free slots
    card game slots
    slotmachinesfree

  127. dissertation defense presentation https://writing-a-dissertation.net/

  128. 2architectural

Leave a Reply

Your email address will not be published.

You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*

%d bloggers like this: