josefrichter

josefrichter

I was looking at some news about Ruby 3 (see Ruby 3.0.0 Released | Ruby) and came also across this GenServer implementation which I thought I’d share here:

What do you folks think about Ruby 3? What kind of applications does it open in Ruby world that were previously not feasible? How does it compare to Elixir, what might be the implications, good or bad.

Just to be clear, I am curious about your opinions, not in some pointless Ruby vs Elixir flamewar. I love both Elixir and Ruby and I am pretty sure many people in this forum feel the same.

Showing Posts 1 to 9

subbu

subbu

I haven’t read Ruby 3 feature list yet, but IMO, GenServer gets its power from OTP/BEAM and its ability to run long running processes. You can store arbitrary data in the process and use it however you want. I am not sure actor model is powerful without a VM. What do others think?

al2o3cr

al2o3cr

Some quick observations:

  • mixing mutable objects with an idiom intended for immutable data feels weird; an instance of Stack is threaded through every call, but functions like Stack#push mutate the data inside it, leading to code with hidden connections:
    case msg
    in [:push, value]
      push(value) # <= mutates self
      [:noreply, self]
    end
  • corollary: If a handler accidentally returns a reference to state to a caller, now you’ve got unsynchronized access to a shared mutable data structure :skull_and_crossbones:

  • the handle_cast / handle_call idiom is very dependent on pattern-matching in function heads; while it’s not semantically different to have a single body with a giant case, it doesn’t seem as readable to me.

  • overall, I’m not sure if trying to exactly reproduce the gen_server plumbing is the right approach. I’ll be very interested to see what people build with more Rubyish idioms.

dimitarvp

dimitarvp

As others pointed out, the runtime is much more important than the actor model (the model is not some magic by itself). After all, we have actor systems implemented in many languages and I’ve heard people walk away from Akka and Orleans disappointed due to lack of part of the guarantees that the BEAM VM has (although let’s be objective here, most users of these libraries are satisfied).

If people use some sort of a linter / static code checker in combination with Ruby’s actor support that ensures only immutable data are passed around (I believe you can achieve this in Ruby with the .freeze method), then it could work. But then you also need a reliable messaging inbox implementation for all actors.

Me too.

egze

egze

Wondering if the start_link even makes sense in Ruby? Does it really link anything?

lucaong

lucaong

I think it’s a great feature that has the potential to bring a solid concurrency pattern to Ruby. I think that it is quite amazing that Ruby adopted the actor model: this has the potential to make Ruby even better than it already was.

Is this making Ruby preferable to Elixir/Erlang for concurrency? Most likely not, because of the issues with mutability mentioned above, and the lack of a VM designed from the beginning for safe concurrency. But I believe that’s not the point: this feature makes Ruby better, and applicable to more problems than it used to be.

I think about this as beneficial “cross-pollination” between languages, not as a competition.

As an engineer that loves both Ruby and Elixir, this feature makes me happy, as it expands the creative space of my favorite tools. If I am designing specifically for concurrency, I will still reach for Elixir. But in a project that fits Ruby better, this makes it possible to introduce concurrency where needed, using a pattern I like.

As for the GenServer implementation, I look at it more as an example to understand how Ractors work, than as a piece of code I would introduce in a real app. It wouldn’t make real sense to port exactly OTP GenServers to Ractors, as the underlying system is different. In Ruby, I would use the actor model idiomatically, without trying to mimic OTP too closely.

kokolegorille

kokolegorille

It seems they also have ractor supervisors, so it might make sense.

dimitarvp

dimitarvp

I have seen several Rust libs (frameworks?) that employ the actor model and they all go subtly different about it compared to the OTP, which is good and we might need the innovation. It’s nice that not everyone is trying to yet again prove the impossible thesis that shared state with naked OS threads will work for sure this time. :003:

ityonemo

ityonemo

Yeah, I’d say gen_server interface is the worst. Ok. I’m exaggerating (I also appreciate that there is a reason why gen server looks like it does), but I really take Dave thomas famous “dogs breakfast” criticism to heart. Only reason I don’t use a package to organize it is because I think it’s bad form to add an unnecessary abstraction layer into the mental model for a commonly accepted pattern… One of these days I’ll do “isaacs best practices with gen_server” video, but I’m baffled by why someone working with ruby would ever want to repeat what exists verbatim, except that maybe they are worried about losing relevance to elixir.

gregvaughn

gregvaughn

It’s funny how things come together. I don’t know the Ruby 3 feature list, but I learned of an actor framework in Ruby that was strongly influenced by OTP (GitHub - celluloid/celluloid: Actor-based concurrent object framework for Ruby · GitHub) about the same time I heard of Elixir in 2013, and even then, I was more interested in Elixir because it was running on BEAM and could take advantage of its guarantees.

— All posts loaded —

Where Next? Top

Trending in Discussions Top

SyntaxSorcerer
This is the start of my Elixir learning journal/journey. I plan to share my journey in this thread and am open to all feedback, construct...
New
bartblast
This is where the projects in the Hologram Showcase get posted: apps built with Hologram and libraries made for it. New ones go up usuall...
New
budgie
Never used it. I know it’s well-liked by some and the authors have put a lot of work into it. Aside from that, is there a community cons...
New
karolina.curiosum
Hi everyone! This is our fourth edition. Last year, 1,000+ developers took part. The more of you who answer, the more useful the results...
New
fredwu
Over the years I’ve tried dozens of time tracking and invoicing apps, and Harvest was the only one I liked. Primarily due to its relative...
New
budgie
I have a project that I’d like to build in Elixir, but there’s a statistical decision engine component that will likely use hierarchical ...
New
cvkmohan
Hi all, a short report from production, and a thank-you to @josevalim, @chrismccord and everyone behind Elixir, Phoenix and LiveView. Wh...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
261 13183 112
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
PJUllrich
On November 23, 2026, an unauthorized third party exploited a vulnerability in hex.pm (CVE-2026-129514, CVSS 10.0) that let them run comm...
New
charlenopires
Hi everyone :waving_hand: I’ve been working on PhiaUI, an open-source UI component library for Phoenix LiveView, and I wanted to share i...
New
akoutmos
@hugobarauna, Dr. Dimitrios Koutmos (my brother) and I (Alex Koutmos) have been hard at work on writing a book on how you can use Elixir ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews