Learning Rust: First Impressions

For the past few weeks I’ve been learning Rust by working on the Matasano Crypto Challenges (apparently I am not unique in this).

It seems quite suited to the task. Fast, easy to write, with a simple FFI (which I’m judging based on the excellent readability of its OpenSSL bindings) and good string and vector libraries (except for the curious lack of functions for “first n elements” and “last n elements”).

For 90% of my code things flow as smoothly as they would in Ruby. Unfortunately I spend 95% of my time on that last 10%, mostly locked in combat with the compiler.

My understanding of Rust’s pointer borrowing rules is fuzzy, but I’m not always sure whether the problem is me or the compiler. For example, sometimes


will fail to compile but

let x = do_thing1();

will work fine. I assume that this is a compiler bugs rather than a language specification bug. Rust 0.7 should be out in the next couple of weeks, hopefully it will fix some of these quirks. Apparently the language has changed quite a bit in the few months since version 0.6 (but I had difficulty installing the git version on Arch).

Apart from these issues, I love the language. It’s like working in C with sane strings and lambdas and destructuring, and compiler errors instead of segmentation faults.

Matasano Crypto Challenges

I’m most of the way through the second set of problems. They’ve been great so far. I don’t get much chance to do this kind of algorithmic reasoning these days - it’s a lot of fun (and probably good for me, despite the insomnia it seems to have induced).

An odd thing I like about it is how haphazardly the problem descriptions seem to have been thrown together. They give enough information and enough of a primer to get you started, but there’s not enough information in their structure for you to rely on cues in the problem description itself. When I did Stripe’s Capture the Flag last year I found myself basing my approaches on the information (detailed, carefully constructed) level introductions, which felt a bit like cheating.