Language of the Month: Rust

I found it hard to believe, that it’s been 4 years now since I finished the previous installment of “language of the month” column, in which I pick a programming language and dive in for a month to see something new. In that 4 years I have learned a lot of programming for sure – though probably very little computer science, and barely any new languages. It’s time to chance, and for the revival of this I’m checking out Rust.

A bit about the LotM first, though. I was previously learning Javascript, Prolog, Lua, and Scala. Each time aim is to go beyond the tutorials and example code, and do something more that lets me discover the the language’s real face – strengths and weaknesses included. At the beginning of the month announcing the language like in this post, and at the end of the month in another post recap what have I learned.

Getting started

First start with a confession – I actually wanted to try out “the language that John Carmack is playing with these days”, but then messed up since that is Racket, not Rust. I guess I’m not the only one making this mistake, and never mind, that will be good for another month! I guess maybe Rust has enough mindshare on Hacker News to stick in my mind.

So then, Rust is a systems programming language that aims to be safe, fast, and play with threads nicely. Its Wikipedia article has a bit more too. Searching for books, tutorials, examples, and projects that use it didn’t turn up as many sources as the previous languages I tried (though it’s much younger language too, so that’s only fair, I guess). On the other hand, it has an extensive official book, so that was a good place to start.

First Impressions

So far I’ve spent two half-evening with Rust, besides collecting the learning material I went through the first few sections of the book (no I’m in the middle of section 4, Effective Rust).

Setting up Rust was pretty simple, I got to know Cargo, its package manager (and sort of build system, and sort of tooling, I guess), and did code the guided examples (both the binary and library ones), though the testing and documentation sections just read through.

So far it’s relatively straightforward, interesting, but I have seen very little where its strength lies. Having first class concept of documentation in code, directly including tests, debug & release builds by default, easy project setup boilerplating are good, though I guess those sort of should be default for every new language as “best practice”.

What I’ve seen a bit instead, is quite a bit of arbitrariness in language. I do accept that it would be strange if first time seeing a new language  everything made sense, and try to cut it some slack. Still, for example why is there so much mixing between lowercase and uppercase type names, as well as abbreviated and not abbreviated versions, eg. String  and &str ? I wonder. Having seen a few expression compositions in the tutorial projects, they also feel quite arbitrary (ie. the method names don’t give a good idea what they are supposed to be doing – why .unwrap() after a thread .join() ? Will get there, but it’s hazy at the moment.) That might be just the issue of the tutorials, so I give that time too. And try to remember, that even though e.g. Python feels so “homely” now for me, there must have been some time when it wasn’t. Curiosity will help with this, and Rust has my attention.

In the meantime onwards with the documentation, and I’m looking for some project ideas and others’ existing projects to look at (suggestions are welcome).