Rust

Lately I’ve been playing around with Rust. I’ve got to admit, I’m really starting to like the language. I’ve even made my first commit to a Rust library, haha. (see my glorious pull request here) With that being said, I’d like this post to serve as a bit of an introduction to Rust - a really opinionated and specific introduction.

How I Found Rust

I’ve been using my spare cycles to check out new languages lately. Especially if the language is from a non-OO paradigm. My work with Scala starting putting the functional style bug in me, which lead to checking out Erlang and Haskell. I’ve also checked out Clojure recently (which I would like a lot more if it wasn’t all Lispy with millions of parens). Along the way, I rediscovered D (it had been years since I last looked at it) and Rust. The first time I took a stride through the Rust tutorial, I thought, “hey, cool. Functional stuff, immutability by default, ‘if’ statements are actually expressions, nice!”. Then came the weird part. FOUR TYPES OF POINTERS. This struck me as horrifying, and I immediately threw aside my headphones and ran screaming into East Santa Monica.

Several days later I found myself again thinking about Rust. Here was a systems programming language that was built with all of the lessons learned over the past two decades. Things were made to be safely used in concurrency, you can be really explicit with the compiler, and the linker directives are declared in the source file! Things that use unsafe memory access had to be marked as such. The language itself includes algebraic data types, which means pattern matching! It really seemed awesome. Again, I checked out the website. I was browsing through the language spec when I got to the section on pointers. Again, I counted the villanous Quandry Quartet and ran screaming into Santa Monica.

Several days later, I again approached the language. After my last mental panic attack I had taken to idling in irc://irc.mozilla.org/rust - doing my best job of lurking around to see who was using the language and for what. I eventually asked about online resources to give a bit of an introduction, as the packaged tutorial was a bit lacking. That was when Rust for Rubysist was recommended to me. This tutorial actually turned things around, and I’m now able to actually do stuff in the language. The author(s?) also hang around #rust so feel free to pop in and ask questions. I hope to include more things about this emerging language in the future.

Oh, and I posted the rust code I generated while following along with the Rust for Rubyist guide, you can grab it from GitHub here.

Summary of Awesome Rust Features

  • Variables are immutable by default
  • Safe by default, unsafe code is marked with ‘unsafe’
  • Easy to spin off asynchronous tasks
  • Algebraic data types!
  • Closures!
  • Garbage collection when you want it, manual management when you don’t