Paul Krill
Editor at Large

Ruby 3 brings parallel execution

news
Jan 4, 20212 mins

Major Ruby update introduces an experimental feature called Ractor that promises thread-safe parallel execution

women spinning plates asynchronous programming synchrony multi tasking by graemenicholson getty ima
Credit: graemenicholson / Getty Images

Ruby 3.0.0, an upgrade to the beloved open source dynamic language, arrived as a production release on Christmas Day. Highlights of the new version include parallel execution and type description capabilities.

Parallel execution comes in the form of an experimental feature dubbed “Ractor,” which is an Actor-model-like concurrency abstraction intended to provide parallel execution without thread safety concerns. Developers can make multiple ractors and run them in parallel. These parallel programs can be made thread safe because ractors cannot share normal objects. Communication between ractors is supported by message-passing. However, to limit sharing of objects, Ractor introduces restrictions to Ruby’s syntax.

Ruby 3.0.0 also introduces RBS, billed as a language to describe the types of Ruby programs. Ruby 3.0.0 ships with the rbs gem, which allows parsing and processing type definitions written in RBS. Type checkers including type profilers and other tools supporting RBS will understand Ruby programs better with RBS definitions.

RBS is intended to support commonly seen patterns in Ruby programs. Advanced types can be written including union types, method overloading, and generics. Duck typing with interface types also is supported. 

Aside from Ractor and RBS, Ruby 3.0.0 offers a host of other capabilities:

  • Fiber#scheduler, for intercepting blocking operations. Previously identified as Thread#scheduler, the capability allows for lightweight concurrency without changing existing code.
  • Memory view, another experimental feature, is a C-API set to exchange a raw memory area, such as a numeric array or a bitmap image, between extension libraries. These libraries also can share the metadata of the memory area that consists of the shape, the element form, etc.
  • Improved performance in the Ruby MJIT (Method-based Just In Time) compiler.
  • Separation of keyword arguments from other arguments.
  • Hash#except built in.
  • A rightward assignment statement.
  • An endless method definition.
  • The addition of find pattern.

Developers can download Ruby 3.0.0 from ruby-lang.org. Ruby 3.0.0 was unveiled as a preview on September 25, 2020. This was followed by a subsequent preview on December 8 and a release candidate on December 20.

Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorld’s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorld’s audience of software developers and other information technology professionals. Paul has won a “Best Technology News Coverage” award from IDG.

More from this author