April 1, 2016
3 min read time

From C to Rust

Technology moves forward, always. And for tech companies to move forward, they must embrace the latest technologies. And for this reason, we, at Varnish Software, are proud to make our biggest announcement yet since the creation of the company: Varnish is switching to Rust!

I'm sure low-level developers have already heard about Rust, but for the others: Rust is a system programming language with high-level features, like trait mechanism and closures. It is specially fit for the kind of high performance, highly threaded architecture Varnish is built upon and should help us reach new heights of efficiency.

Embrace change, but which one?

As I wrote, we must adapt to the ever changing field of technology, but change for the sake of change isn't smart, so we made sure to thoroughly evaluate all candidates.

We obviously started looking at Go, since it's what the "cool kids" use, plus it has a syntax similar to C that would have eased the transition. But, we quickly realized that the mascot of Go is a gopher (go/gopher, we admit it's well-thougt), and it would irremediably conflict with our own rodent, the cute blue bunny. So, it was a no-go.

So, maybe we shouldn't try to to be cool, after all, Varnish isn't about that, it's aimed at performance and security. Hence we turned our gaze to C#, as it looks like a modern Java implementation, seems pretty popular and it would be a great occasion to get Varnish on Windows. Then we realized our last batch of beer may have been a bit too strong.

And finally, we stumbled on Rust, which was the perfect candidate: modern, concurrency-minded and low-level too. There's no garbage collector, the syntax is almost familiar, but with some  sexy bits to keep up entertained, and the packaging tool, Cargo is a breeze to use.

The best part is that it's used actively by Mozilla (they started the project, actually) for their next browser. This point is crucial to us because that means we would be writing code in the same language as one of the major browser vendors, i.e. Varnish's clients. This is a huge interoperability win for us!

And finally, Rust should lower the entry barrier. As it's driven by a modern company, it is sure to be more attractive to new contributors than C, which is an obscure, decade-old language that nobody uses anymore.

The migration

Obviously, this change will not happen overnight, but we already made good progress re-writing all the Varnish Plus software, and the new package should roll out to our customers via the regular repositories in a few weeks. Hopefully, all the packages, from Varnish Custom Statistic to Varnish High Availability to Varnish Administration Console will be feature-equivalent to their C-counterparts.

As to Varnish Cache, it is being rewritten right now in a branch that should be merged pretty soon in the master repository very soon. If you are interested in the code, you can find it here. While you may find this earlier, we want everything to be up and in top-notch condition for the 5.0 release this September.

Join us for this wonderful journey!

Photo (c) 2011 by various brennemans used under Creative Commons license.