Rails as the stable layer while Rust handles the hot paths

ProjectsCommunity Digest0 replies

Community DigestMember#1

Ben Halpern's DEV post "Long Live Rails" (https://dev.to/ben/long-live-rails-3p21) argues that the recent wave of Rust adoption at 37signals and DHH's talk of going "pencils down" on hand-typed code is not a concession for Ruby on Rails, but a sign of how the framework is evolving. The article responds to reactions to DHH's Rails World 2026 appearance, where he reportedly described large Rust speedups and sub-millisecond startups once AI agents take over the borrow checker, while joking that reading Rust feels like "pouring acid in my eyes."

Rust inside the monolith

Halpern describes work on Forem, the Rails monolith behind DEV, where dozens of internal Ruby modules have been replaced with Rust. An autonomous rust-loop ports CPU-bound and allocation-heavy Ruby hot paths into an in-process Rust extension (gems/forem_native) using magnus and rb-sys. He frames this as a strength of Rails rather than a weakness: dropping Rust into a Rails codebase has become accessible enough that the old choice between a monolith and a separate Go or Rust microservice is no longer forced.

The split puts a pure-Rust forem_core crate with no Ruby dependencies next to a thin magnus wrapper that borrows Ruby string buffers in place, avoiding serialization and memory copies. Ported areas listed in the post include:

  • Markdown pre-processing, frontmatter normalization, and reading-time tokenization, reported as roughly 54x faster with zero Ruby heap allocations.
  • Home feed ranking and dynamic pgvector SQL expression assembly, reported as about 20x faster with 97% fewer Ruby objects allocated.
  • HTML sanitization, SVG icon rendering, mention parsing, URL normalization, subdomain routing, CSRF/JWT verification, and secret scrubbing on agent transcripts.
  • Removal of pure-Ruby dependencies such as gemoji, emoji_regex, and wcag_color_contrast from the Gemfile.

Halpern notes that cloning Forem does not require cargo to run bin/dev, since small precompiled platform binaries load quickly, and that ported functions are checked by RSpec differential specs against the legacy Ruby reference.

Conventions as the durable layer

Drawing on his earlier "Design for Churn" piece, Halpern compares AI-era codebases to gardens: implementation code turns over cheaply, while schemas, routing, boundaries, and contracts are the perennial beds. Rails, in his view, is that bed, and its shared conventions make the codebase legible to both new hires and coding agents. He cites other DEV authors on Rails being AI-ready and on Rust's strict compiler giving agents a tight feedback loop.

He also points to bin/rails query, landing in Rails 8.2 and backported to earlier versions via rails-query-command, as an example of Rails making a necessary thing first-class: a read-only, structured-JSON way for developers and agents to ask a Rails app safe questions about its data, replacing bespoke wrappers. Forem, he says, built its own read-only Postgres gateway for similar reasons.

The closing argument is that Rails endures through taste and integration, not language purity, and that replacing hot compute loops with Rust can happen happily inside the monolith.

No replies yet