Introduction to the Pony programming language

Pony, a sort of "Rust meets Erlang," makes it easier to develop fast, safe, efficient, and highly concurrent programs.
313 readers like this.
Best of Programming

Zagrev on Flickr. CC BY-SA 2.0

At Wallaroo Labs, where I'm the VP of engineering, we're are building a high-performance, distributed stream processor written in the Pony programming language. Most people haven't heard of Pony, but it has been an excellent choice for Wallaroo, and it might be an excellent choice for your next project, too.

"A programming language is just another tool. It's not about syntax. It's not about expressiveness. It's not about paradigms or models. It's about managing hard problems." —Sylvan Clebsch, creator of Pony

I'm a contributor to the Pony project, but here I'll touch on why Pony is a good choice for applications like Wallaroo and share ways I've used Pony. If you are interested in a more in-depth look at why we use Pony to write Wallaroo, we have a blog post about that.

What is Pony?

You can think of Pony as something like "Rust meets Erlang." Pony sports buzzworthy features. It is:

  • Type-safe
  • Memory-safe
  • Exception-safe
  • Data-race-free
  • Deadlock-free

Additionally, it's compiled to efficient native code, and it's developed in the open and available under a two-clause BSD license.

That's a lot of features, but here I'll focus on the few that were key to my company adopting Pony.

Why Pony?

Writing fast, safe, efficient, highly concurrent programs is not easy with most of our existing tools. "Fast, efficient, and highly concurrent" is an achievable goal, but throw in "safe," and things get a lot harder. With Wallaroo, we wanted to accomplish all four, and Pony has made it easy to achieve.

Highly concurrent

Pony makes concurrency easy. Part of the way it does that is by providing an opinionated concurrency story. In Pony, all concurrency happens via the actor model.

The actor model is most famous via the implementations in Erlang and Akka. The actor model has been around since the 1970s, and details vary widely from implementation to implementation. What doesn't vary is that all computation is executed by actors that communicate via asynchronous messaging.

Think of the actor model this way: objects in object-oriented programming are state + synchronous methods and actors are state + asynchronous methods.

When an actor receives a message, it executes a corresponding method. That method might operate on a state that is accessible by only that actor. The actor model allows us to use a mutable state in a concurrency-safe manner. Every actor is single-threaded. Two methods within an actor are never run concurrently. This means that, within a given actor, data updates cannot cause data races or other problems commonly associated with threads and mutable states.

Fast and efficient

Pony actors are scheduled with an efficient work-stealing scheduler. There's a single Pony scheduler per available CPU. The thread-per-core concurrency model is part of Pony's attempt to work in concert with the CPU to operate as efficiently as possible. The Pony runtime attempts to be as CPU-cache friendly as possible. The less your code thrashes the cache, the better it will run. Pony aims to help your code play nice with CPU caches.

The Pony runtime also features per-actor heaps so that, during garbage collection, there's no "stop the world" garbage collection step. This means your program is always doing at least some work. As a result, Pony programs end up with very consistent performance and predictable latencies.


The Pony type system introduces a novel concept: reference capabilities, which make data safety part of the type system. The type of every variable in Pony includes information about how the data can be shared between actors. The Pony compiler uses the information to verify, at compile time, that your code is data-race- and deadlock-free.

If this sounds a bit like Rust, it's because it is. Pony's reference capabilities and Rust's borrow checker both provide data safety; they just approach it in different ways and have different tradeoffs.

Is Pony right for you?

Deciding whether to use a new programming language for a non-hobby project is hard. You must weigh the appropriateness of the tool against its immaturity compared to other solutions. So, what about Pony and you?

Pony might be the right solution if you have a hard concurrency problem to solve. Concurrent applications are Pony's raison d'être. If you can accomplish what you want in a single-threaded Python script, you probably don't need Pony. If you have a hard concurrency problem, you should consider Pony and its powerful data-race-free, concurrency-aware type system.

You'll get a compiler that will prevent you from introducing many concurrency-related bugs and a runtime that will give you excellent performance characteristics.

Getting started with Pony

If you're ready to get started with Pony, your first visit should be the Learn section of the Pony website. There you will find directions for installing the Pony compiler and resources for learning the language.

If you like to contribute to the language you are using, we have some beginner-friendly issues waiting for you on GitHub.

Also, I can't wait to start talking with you on our IRC channel and the Pony mailing list.

To learn more about Pony, attend Sean Allen's talk, Pony: How I learned to stop worrying and embrace an unproven technology, at the 20th OSCON, July 16-19, 2018, in Portland, Ore.

Sean is VP of Engineering at Wallaroo Labs and a member of the Pony core team. His turn-ons include programming languages, distributed computing, Hiwatt amplifiers, and Fender Telecasters. His turn-offs include mayonnaise, stirring yogurt, and sloppy code. He is one of the authors of Storm Applied.


Strike one: A programming language pitch that includes zero code examples.
Strike two: zero code examples on the homepage, the "discover" page, all the way down to the FAQ, actually.
Strike three: But it *does* have a Code of Conduct, which tags along nicely with all the "safeties" resulting in something that sounds too much like a corporate-friendly-bondage-and-discipline language (

Oh, come on! The links to the tutorials with code examples are at the conclusion of the post.

In reply to by Erez Schatz

Or, another way to look at the article and home page...

A programming language pitch that focuses on the key design features - check!

A well-organized site that leaves code to the "learn" page, where language elements are really well-explained - check!

Code of conduct, which primarily solicits participation in a polite, constructive and professional fashion - check!

In reply to by Erez Schatz

Marketing wise, those all are good points. But I'm on the other side of the developer-marketer line, and for me seeing the amount of emphasis on marketing vs. the lack of "show me the code" are exactly reasons NOT to give this another look.

In reply to by clhermansen

A very informative blog post.
This is an AMAZING time to be in Tech - especially if you're into programming. So many fcuking exciting languages. I already have my eyes on Nim once it reaches 1.0, and Crystal too with its fantastic web frameworks (Geany, Amber, Kemal).
But right now I'm slowly learning Julia via a very well-done Udemy course. I just need to allocate more time.
Oh, Kotlin also looks good but I'm wondering if Kotlin.Native will eventually deliver the goods down the road. That should really shake things up.

To me, Nim is frigging disruptive. I keep peeking the forums. And let's not forget the Delphi-esque FreePascal/Lazarus IDE juggernaut. I think I will get more into that down the road so that I can effortlessly develop crossplatform GUI apps with a syntax that's near & dear to my heart since I'm a big Niklaus Wirth fan. ;-)

Hopefully Pony will get more exposure as it appears to have some really nice features. it FAST in terms of runtime execution?? Speed is EVERYTHING now. Developers want it all! ;-)

I am using the Pony runtime and you will not see a single lock, everything is made using lock-free data structures. I do not know that much about Pony but the runtime is fantastic. Sylvan Clesch had done an outstanding work

Creative Commons LicenseThis work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.