Ruby creator floats new concurrency model

The new concurrency and parallelism model, called Guild, would feature thread safety, but isn't expected before 2020

Ruby creator floats new concurrency model
Credit: Jarno

Developers using the open source Ruby dynamic language are in for some big changes. The language is set to feature a new concurrency and parallelism model, called Guild, in the Ruby 3 upgrade tentatively slated to arrive before 2020.

Plans detailed at a technical conference in Kyoto, Japan this week cite intentions to equip Ruby for a programming landscape that increasingly has moved to multi-core processing. Currently, Ruby supports concurrency via threads, but making thread-safe programs is hard because of a need to manage object mutations. Guild overcomes this issue via a concurrency model enabling parallel execution.

"Since threads provide no data protection, it is very difficult to write correct programs," Ruby founder Yukihiro Matsumoto said. "Guilds are isolated [from] each other and do not share mutable states, basically like an actor model that many other languages have." Ruby needs a new concurrency model because it already has a thread model that cannot be removed, as it maintains compatibility in the language, Matsumoto said.

The conference presentation from Heroku's Koichi Sasada, a Ruby core committer, maps out intentions for Guild, described as a "new concurrency abstraction." Each Guild has at least one thread; threads in different Guilds can run in parallel, but threads in the same guild can't because of a Giant Guild Lock capability. Mutable objects should belong to one Guild, but there can be communication between Guilds.

Multi-threaded programming is difficult, with risks including race conditions among threads, Sasada noted. There can be trade-offs in performance versus safety, it's difficult to tune performance, mutable objects must be shared correctly, and debugging is difficult.

"Guild is part of our Ruby 3 experiment," Matsumoto said, but he also noted that the name, Guild, as well as its behavior could be changed by the time it arrives.

From CIO: 8 Free Online Courses to Grow Your Tech Skills