Interview with Steve Klabnik: How Rust Compares to Other Languages and More

Published Oct 28, 2014Last updated Aug 04, 2017

How the Rust Programming Language Compares to C++, Ocaml, Go, and Erlang

With 273 repositories on GitHub, Steve Klabnik is known for his contribution to open source projects, where he is in 15 organizations. He is currently ranked #32 on the all-time Rails Contributors list, and has written the guide Rust for Rubyists. Rust is a relatively new programming language for developing reliable and efficient systems. As of June 2014, Steve has joined Mozilla to work on the official Rust Documentation.


rust

Would you recommend coding newbies to learn Rust or should they learn some other language like Ruby first?

ruby
I think that they should use whatever gets them excited. Pick something, anything, and just try it. If you don’t like it, try something else. Humans are all different, and there’s no single answer here. That said, I think Ruby is a fantastic first language. Rust has a significant lack of resources because it’s so new, and so it’s much harder as a first language.

You’ve said before that Rails makes it hard to do ‘true’ TDD and unit testing difficult. How does Rust compare?

Rust has unit testing built right into the language, but it’s just the basics: asserts and such. We expect others to build neat stuff on top of that as the community grows.

How would you compare Rust to other system programming languages such as C++? Why do you think it should replace C++?

Historically, programming languages have had a tradeoff: you can have a language which is safe, but you give up control, or you can have a language with control, but it is unsafe. C++ falls into that latter category. More modern C++ is significantly more safe than it used to be, but there are fundamental aspects of C++ which make it impossible to ever be truly safe. Rust attempts to give you a language with 100% control, yet be absolutely safe. It does this through extensive compile-time checking, so you pay little (and often no!) cost at runtime for its safety features. This safety issue isn’t just about programmer convenience, though. C++ is unsafe in ways which cause serious security vulnerabilities.

For example, in the last Pwn2Own competition, Firefox had some serious vulnerabilities, due to C++ being unsafe. And so did the other browsers on that page. Many of these errors would have been compile-time bugs if those browsers were written in Rust, and the runtime ones would not have produced a security vulnerability.

For applications which requires high performance, people choose C++ but C++ is definitely too complicated, and Java might be too heavyweight due to the nature of running on top of JVM. There’s D which tries to be a better C++, but looks like only few care. Now there’s Go which starts taking off. Do you think that Rust could beat Go in this place?

go lang
Rust and Go are very different languages, and comparing them doesn’t make a lot of sense. It’s like asking if Ruby and C are competing. Now, it’s true that there are some programs that are written in C that could be written in Ruby, but the languages make fundamentally different tradeoffs. There are certain kinds of applications which Rust can work well in that Go never can. For example, writing a Ruby gem in Rust is pretty easy, but you can’t do that with Go. Two garbage collectors fighting over each other’s memory is a bad time. That said, Rust makes you care about a lot of details which you don’t have to worry about if you’re coding in Go, and so if you’re happy with Go’s downsides, programming in Go make more sense than in Rust. As always, it really depends on what your requirements are, and what tradeoffs you’re willing to make.

If all we’re talking about is safety, performance, and functional programming. Do you think that Rust could be better than OCaml? Or would Rust begin to make people aware of functional programming? As people are talking about functional programming, but few really pick one functional programming language to develop stuffs.

ocaml

Rust is vaguely functional, but it’s not full-blown. OCaml is a better functional language than Rust. That said, it might make it easy to start to use some functional concepts, because you don’t have to go whole-hog. This is why OCaml is often easier than Haskell, for example.

Rust is quite an ambitious language which tries to be performant, therefore low level in some degree, while retaining safety and convenient at the same time. For systems programming, C dominates everything else. Do you think that Rust could replace C in such place?

Absolutely, you can use Rust anywhere you’d use C. There are practical reasons why you may choose not to, for example, there aren’t nearly as many libraries. But Rust can work well with C libraries...

For concurrency, Rust seems to support everything from Go and Erlang. Do you think Rust could replace them in those places?

erlang
So this question is complicated, and changing. We’re currently removing Rust’s green threading support, because 1:1 threads make sense as a default for a systems language. However, they will be available in a library. Rust has some strong advantages in the concurrency department due to its ownership model. For example, sharing mutable state across a concurrency boundary without a mutex is a compile-time error in Rust. This is super huge on the correctness side. Erlang is the king in this space, so if you can afford a garbage collector, and you don’t mind Erlang’s more eccentric syntax, it’s still the leader for building resilient software.

Do you see yourself going back to improve Rails with what you’ve learned from Rust? What are your plans for the future?

My work is less and less in Rails these days, and so I don’t expect to. You never know though! My plan is to continue supporting the Rust ecosystem in every way that I can. For now, that involves continuing to work with Mozilla, but I’m not an oracle. Anything can change.😃

How has philosophy affected the way you code?

In general, I think more about the meta-stuff around my code than I did before. For example, I spend a lot more time thinking “is the software I’m building ethical?” or “are there other ways of looking at this?” I’ve also found certain connections to be productive when trying to understand both topics. They inform each other. For example, Plato’s ‘theory of forms’ has helped me understand OOP, and functional reactive programming has helped me understand process philosophy.

What projects do you find inspirational?

Tor

If I had to pick one, I would have to say Tor. It’s a project that has helped so many people, and is so vitally important to the world.

What are your favorite tools?

95% of the software I use is in this list: vim, bash, firefox, tmux, irssi, git, and xmonad. I use them for everything.

Despite working primarily on open source projects, you seem to take a negative attitude toward it, where you say open source is a mega-capitalist conspiracy. Can you elaborate on your opinion?

Haha, that pull quote from this article is one of the most misunderstood of mine. When I say ‘conspiracy,’ I don’t mean a bunch of people in a room, making evil plans. I mean it in a loose sense: a bunch of people benefit from perpetuating the idea of open source. If you’re not familiar with the history of the term ‘open source,’ this article is pretty good. But basically, the Free Software movement was one based on an ethical imperative.

"Open Source" is a similar idea, stripped of ethics, and re-packaged so that companies benefit, not users. I have participated in open source because it’s a good way to change the world, but that doesn’t mean I don’t understand that many other people have made a ton of money off of the work that I’ve given them for free. If I hadn’t done that work for free, they would have had to pay someone else to do it instead, possibly even me! That’s just the reality of the situation.

You have a lot of strong opinions about the capitalism and its relationship to technology. What are some ways you think tech can create a better world and do you think it’s possible for technology to veer away from encouraging capitalism?

Technology and capitalism have always gone hand-in-hand. The Luddites, for example, would break textile equipment, because they saw the effect technology would have on their work. I’m not a luddite, but I’m also keenly aware that my role as a programmer is to automate others out of their jobs. So where do we go from here? Well, I’d like to think that with enough automation, people won’t actually need to work as much. And we wouldn’t have to, except that the profit from my automation work isn’t captured by me: it’s captured by my employer.

A simple way to think about it is this: If I make one unit of software per day, and then I learn some new vim keyboard shortcuts, and that lets me make two units of software per day, I still have to work eight hours per day. I can’t suddenly start working four and collect the same amount of money, because I’m paid by the hour, not by my productivity. And likewise, if I come into a factory and write some software for robots that replace the workers, the same work is getting done, but instead of them being able to take the time off, instead they’re out of a job. I would like to see a world where we as humans have more free time to explore our passions, dreams, and desires. Technology can build that world, but capitalism never can. Well, it’s not the end game, at least 😉

Discover and read more posts from Steve Klabnik
get started
Enjoy this post?

Leave a like and comment for Steve

1
7
7Replies
Philosopher Rex
2 years ago

I think Steve needs to look up the definition of capitalism in the dictionary. Like a lot of people schooled by the State, he seems to be applying an orwelliafied version of the word. Most every technology and product we have today is because of capitalism. Too many people see the effect of ‘fascism’ (the mixing of State and Elite Corporate power), and then assume this is capitalism - it absolutely is not, again, get a dictionary and look it up.

“Fascism is more appropriately called corporatism, for it is a perfect merger of State and Corporate power” – Benito Mussolini (a man who knew a thing or two about fascism)

Fallon
2 years ago

Exactly NONE of the technologies we have today are a result of Capitalism, you don’t need a dictionary, you just need to pick up a history book!

We wouldn’t even be here if SHARING wasn’t what humans did as a normal course of evolution. That’s not to say the evolution of the attempted harnessing of the twin evils of Greed & lust for Power are bad, it’s not.

However, when you use those things, they have to be controlled, and our control over them hasn’t been a strong point lately! There is nothing different about private or state control, only the rules of engagement are different, you’re a prisoner of rhetoric, not reality.

As always, history is your friend, not the dictionary, and EVERY single technology and every basic foundation of religion, government, science, mathematics, astronomy is traceable to 2 or 3 civilizations. And remember that technology is the practical application of these things, not a standalone item itself, and you’ll understand that it is derivative!

Philosopher Rex
2 years ago

Exactly NONE huh? That sounds really balanced and generous of you – you too need to look up the definition of capitalism. You wouldn’t even be able to comment through such a system as we are using now without it. History can be your friend if you read BROADLY, and are not gullible to the history written by conquerors – I don’t know what history you’ve been reading, but I strongly suspect it was written by those who get paid by the State – the dog does not bite the hand that feeds it. If you read history written by Anarchists, you get a wildly different view. Spend some of your time studying the works of Murray Rothbard and perhaps you’ll have have more balance in your perspective --> http://mises.org

Fallon
2 years ago

Written by the state? As I said, a total prisoner of rhetoric, which renders you unable to think independently. You don’t even notice that you failed to address ANY of the points raised, just blow it off as STATE stuff and dogs biting hands, LOL!

Where do you think the guys that wrote your dictionary were educated? What planet are you on?

It must be wonderful to live in such a simplistic world… until it crashes!

USLiberty2012
2 years ago

Exactly, what the media calls capitalism is fascism. Almost everyone you see on TV saying they support capitalism, don’t even know what it means.

LeRoyce Pearson
a year ago

I agree that capitalism is an important in the matter of advancing technology, but I don’t think that was what Steve was getting at. He talks about the fact that he can write software that harms other people by putting them out of the job, which points to the idea that, while capitalism advances technology quickly, its end goal isn’t to help other people.

harshit rastogi
3 years ago

why does steve profile is redirected to some other person .

Show more replies

Get curated posts in your inbox

Read more posts to become a better developer