Tag Archives: golang

Brief first impressions of Rust

I had a little play with Rust this week. I’d been meaning to for a long time, but the arrival of 1.0 motivated me to spend a few hours playing around with the tools and the tutorial. I haven’t actually written anything myself yet – I’m sure I’ll have some different, perhaps more valid thoughts after I do that. I’ll probably write a web server – that’s been my go-to hello world program for the past 20 years or so.

But just working through the first couple of chapters of the excellent free, online Rust Book I’ve come away with some impressions. For better or worse I’m comparing Rust to Go and to a lesser extent to C and C++.

Something that Go promised was good tooling and strong opinions on source code organization. I like to tooling just fine, but the source code organization bugs me – I don’t like having all my code and the code I depend on under a single directory. Rust’s source code organization is much more appealing to me – a top level directory with a configuration file Cargo.toml and then a src/ directory with my code. Dependencies are downloaded and stashed somewhere (who cares? I don’t).

Even playing around with the simple examples in the book I was missing “go fmt” and “goimports”. I haven’t gone deep enough into Rust to know if there’s an equivalent that everyone else is using or if the community has the (incorrect) opinion that source code formatting is a lifestyle choice. One of the most charming things about Go and Python are standardized source code formatting. In my team at work we’re using clang-format to (mostly) enforce a consistent style to Objective-C.

For the actual code itself there’s a steep learning curve that I’m still at the bottom of, staring up. I know that the whole point of Rust is a type system that is powerful enough to allow programmers to express complexities of thread safety and resource ownership, but that means that it’s really complicated. I like that it’s explicit and designed to be easily parsed. I like that there’s type inference so I don’t have to type the confusing names of these types all the time. I still have a lot of learning to do.

After my brief time with Rust I’m excited that we have a language that is expressive enough to provide memory and concurrency safety while remaining explicit and predictable. I just hope that I and others are able to become comfortable with the syntactic line noise to use it effectively, and that we find the right problems so we can use it appropriately.