News

Automatic Concurrency Arrives in Ritchie

Ritchie figures out when to overlap network calls to save time.

Tahir Hashmi · 19 November 2026

It's been six weeks of gruelling R&D here at ritchie.dev. The headline feature that got delivered is Automatic Concurrency, but under the hood, it required so much work that we ended up rewriting the compiler from scratch — for the fourth time!

Let's take a look at what it took to get here.

What's New

  1. Automatic Concurrency! Ritchie compiler figures out which operations can be executed concurrently to save wall time over blocked I/O. You get this benefit without having to write explicit forks, async/await, promises, futures, etc.
  2. RITE was thoroughly revised and rigorously checked. It is now in a shape where it can be used as an abstract machine and architecture that we can build against and match or exceed, but not fall short of.
  3. The error handling model was revised to decouple it from concurrency. Previously concurrency was enabled only inside a handled block. Now Automatic Concurrency is always on, independent of error handling syntax.
  4. Much more compact and competent Ritchie Skill for coding agents.
  5. A new Ritchie at a Glance page for you to get familiar with the language.

Automatic Concurrency

When you write something like:

sequential.riRitchie
Int a = @Remote.getA() // 300ms latency
Int c = a * 2
Int b = @Remote.getB() // 200ms latency
Int d = b + c          // 500ms sequential

each statement is executed one after the other in the order in which they were written. That means the final statement has to wait for the earlier ones to return before it can execute and it ends up waiting for the sum of the latencies of each call.

Ritchie is able to recognise remote calls, work out the data dependencies between them and dispatch the calls concurrently whenever it can. Thus, the first and third statements of the above snippet run concurrently and the last line can execute as soon as the slowest call returns, i.e. after 300ms.

This works without any additional keywords or manual bookkeeping. What's even more interesting is that Ritchie also keeps track of error handling and externally observable effects when deciding how to schedule calls. E.g. naive concurrent scheduling of the following snippet can leak confidential data:

naive.riRitchie
@Auth.check(token)     // can raise an error
print("confidential")  // only if auth check succeeded

The above snippet assumes that @Auth.check() raises an error if authentication fails. Ritchie's implicit error handling means that the second line must not run in case of auth check failure because the auth check error will be returned to the caller. In this scenario, Ritchie is able to work out that it must wait for the response of the auth check, ensure that it succeeded and only then proceed with printing confidential data.

Fun fact: this was exactly the snippet that broke in the first implementation of Automatic Concurrency and triggered the whole compiler rewrite!

For a more detailed walkthrough of Automatic Concurrency and our error handling model, read Magically Thriving with Evolving Requirements.

Under the Hood

The compiler rewrite was undertaken with great deliberation after we started seeing a whack-a-mole pattern of errors, which pointed to a weakness in design. We were not convinced that we could build something as complicated as Automatic Concurrency on a weak base. So here's how the design was strengthened.

Ritchie now has an intermediate representation (IR) that we call ritchie-min or kernel, interchangeably. Many Ritchie features were already implicitly specified as rewrites into a subset language (how a += b is exactly a = a + b, to take the simplest example). However, this subset language was only "in the head" and the implementation often short-circuited it.

Coming up with a formal specification of the kernel language allowed us to:

  • more rigorously specify high level features in terms of lower level behaviour
  • verifiably prove that those features were indeed implemented as lowering rewrites
  • design the runtime model in terms of the kernel language semantics and prove correctness over a smaller subset

This, crucially, allows us to switch from Go to another backend language for code generation at some point. Perhaps the biggest reason for doing this would be the memory model mismatch between Ritchie and Go. However, the speed of development with the Go compiler, its extensive standard library and its concurrency and networking capabilities put that rewrite quite far into the future.

Working through these changes also led us to start running "evals" for Ritchie coding with agents. While it's too early to officially publish benchmark numbers, we can reveal that:

  • we have over four thousand Ritchie programs generated and saved on disk and multiples of that being written and thrown away during design and development.
  • Ritchie code generation in terms of token usage is already competitive with mainstream languages.

The Road Ahead

Automatic Concurrency is the first of many whole-program automations that are in scope for Ritchie and its runtime. With the new architecture in place, we can aim for greater automation in resilience, resource management and runtime optimisation.

The best way to see where it's headed is to try it: head over to the Playground, throw your trickiest sequence of remote calls at it, and see what Ritchie does with them.