Fundamentals 4 min read

New Features in Ruby 3.0.0 Preview 1: RBS, Ractor, and Scheduler

Ruby 3.0.0 Preview 1 introduces RBS for static type definitions, experimental Ractor for actor‑model concurrency, and a new Scheduler API for lightweight thread management, accompanied by examples and a list of supported synchronization methods, highlighting the language’s evolving capabilities.

Laravel Tech Community
Laravel Tech Community
Laravel Tech Community
New Features in Ruby 3.0.0 Preview 1: RBS, Ractor, and Scheduler

Ruby 3.0.0 Preview 1 has been released, bringing several new features to the language.

RBS is a language for describing Ruby program types. It enables type checkers and other tools to understand class and module definitions, method signatures, instance variables, inheritance, mixins, and supports advanced types such as unions, method overloads, generics, and duck‑typing interfaces.

Ruby 3.0 ships with the rbs gem that can parse and handle RBS type definitions. An example definition:

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

Ractor (experimental) is an actor‑model concurrency abstraction that provides parallel execution without thread‑safety concerns. The following code runs two Ractors in parallel to compute prime?, roughly doubling speed:

require 'prime'

# n.prime? with sent integers in r1, r2 run in parallel
r1, r2 = *(1..2).map do
  Ractor.new do
    n = Ractor.recv
    n.prime?
  end
end

# send parameters
r1.send 2**61 - 1
r2.send 2**61 + 15

# wait for the results of expr1, expr2
p r1.take #=> true
p r2.take #=> true

Scheduler (experimental) introduces Thread#scheduler to intercept blocking operations, allowing lightweight concurrency without changing existing code. Currently supported classes/methods include: Mutex#lock, Mutex#unlock,

Mutex#sleep
ConditionVariable#wait
Queue#pop

,

SizedQueue#push
Thread#join
Kernel#sleep
IO#wait

, IO#read, IO#write and related methods such as #wait_readable, #gets, #puts Not supported: IO#select For more details, see the official release notes: Ruby 3.0.0 Preview 1 released .

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Schedulertype-systemRubyractorrbs
Laravel Tech Community
Written by

Laravel Tech Community

Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.