This version of the site is now archived. See the next version at v5.chriskrycho.com.

Rust and Swift

Comparing two exciting, new, apparently (but not always actually) similar programming languages.

Background

In summer 2015, I started learning Rust. Then, in September 2015, I started learning Swift. The superficial similarities between the two languages are obvious, and they hit their stride at roughly the same time: Rust’s 1.0 release was in May 2015 and Swift’s 2.0 release1 was in June 2015. Both cite inspiration from languages like Haskell, while retaining a C-like2 syntax which is more approachable to many of the developers inclined to pick up the language.

So, when I started reading the Swift book, comparisons were inevitable. For all that the two are very similar at a superficial level, they also make some very different choices in terms of language design and philosophy—and those choices are interesting!

Parts in the Series

This list is updated whenever I publish a new post in the series. You can also subscribe to the dedicated #rust-and-swift RSS feed, or to the more general #rust and #swift RSS feeds.

  1. Thoughts after reading the introduction to the Swift book.
  2. Basic types and the syntax around them.
  3. Operators, including overloading, and thoughts on brevity.
  4. Language design tradeoffs, highlighted by string manipulation.
  5. The value (and challenge) of learning languages in parallel.
  6. Collection types and the difference between syntax and semantics.
  7. Pattern matching and the value of expression blocks.
  8. Functions, closures, and an awful lot of Swift syntax.
  9. Sum types (enums) and more on pattern matching.
  10. Classes and structs (product types), and reference and value types.
  11. Hopes for the next generation of systems programming.
  12. Properties: type and instance, stored and computed.
  13. Methods, instance and otherwise.
  14. Indexing and subscripts, or: traits vs. keywords again.
  15. Inheritance: a Swiftian specialty (for now).
  16. Initialization: another area where Swift has a lot more going on than Rust.
  17. More on initializers!
  18. Deinitialization: ownership semantics and automatic reference counting

Some Notes on the Series

I am not by any means a programming language theory nut. (Or, at least, I wasn’t. This project, alongside a few other things, might be making one of me.) I am also not an expert. My opinions are considered, but not necessarily deeply informed, and you’ll see places where I have added corrections along the way as I got new information from feedback received along the way.

I also freely admit to a bit of a bias toward Rust, between the two. I like Swift, but I really like Rust. I think I come by this fairly, in that it’s just a matter of my own language-design preferences. I like Python better than Ruby, and in terms of how the languages feel, Rust is more like Python and Swift more like Ruby.

But—full disclosure—I’ve also made something of a personal investment in the future of Rust, in that I run a podcast focused on the language, from which I actually earn (a very small amount of) money.

One other thing: as of February 2016, I haven’t had a chance to build anything serious in either language—though I hope to change that over the course of this year. So these are very much surface-level impressions of the two languages. My thoughts and feelings about the two may change over time.

One last bit: the series literally started as a series of comments in a Slack team I participate in. You’ll note a substantial shift in the tone, structure, and content as I went along. The first post was really just off-the-cuff responses as I started reading. Starting with the second post, I was a good deal more intentional about what I was doing. As the series goes along, there is more and more of this, and it’s also informed by my work on New Rustacean.


  1. which functioned somewhat like its 1.0, since its actual 1.0 was the point it was announced and served as a public beta

  2. really, ALGOL-like, of course 😉