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.
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
endRactor (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 #=> trueScheduler (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 .
Laravel Tech Community
Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.