Adventures in Rust

Tamir Bahar on April 27, 2018

In the few years since Rust came out, I've frequently found myself explaining what an amazing language Rust is. Laying out the ways in which it i... [Read Full]
markdown guide
 

Rust is one of those languages that wil force you to become a more rounder programmer because, depending on your background, it will help to introduce you to a more rigid, defensible style of programming. When learning, I loved the fact that error-handling is furnished to the programmer at such a high-level. You may also find that the community is friendly, yet typically far more advanced than the insert-popualr-language-here groups. By necessity, you will be forced to learn a lot about your program after you've written it (how it's laid out in memory, the effect of CPU context switches, etc). These are typically concepts that are lost on programmers working in more abstract environments.

Trust me, your struggles with the borrow checker will become much less frequent when you begin to really understand how it works and why it's there. I found that even when I knew, it still took a few months before I really knew. I am glad that Rust generally does a really good job with it's error messaging, also. So even though you may be having difficulty compiling your code, the error messages will go into great detail and even provide possible fixes.

 

What would you suggest for someone interested in learning rust. What resources should I go through to learn with? What would be something a rust newbie should try to build?

 

The official "book" is the best place to learn rust. It's a relatively fast-paced book but does not assume you have any familiarity with Rust (or any other systems language): doc.rust-lang.org/book/second-edit...

In terms of what to do, a nice way to get proficient in a language is via Exercism: exercism.io/

When learning a new language I like to implement the Game of Life and a Brainf*ck interpreter.

Ive never heard of exercism before looks like a great resource. Thanks!

I can really recommend the Brainf*ck interpreter. Also try implementing some optimizations such as combining operations.

 
 

I would also recommend using clippy when working with Rust. It's a linter that can help to catch common mistakes, and in general help to write more idiomatic Rust code.

I've also written about my experiences coming from C/C++ if you're interested.

 

Super awesome post. It's definitely the kind of thing that makes me want to give Rust some more time. I too gave it a bit of learning time but fell off the wagon quickly.

@vaidehijoshi we talked a bit about your short adventures in Rust, any quick tips for a total Rust newbie?

 

Don't forget to mention that Rust beginners shouldn't begin with developing Tree/Graph like data structures (and anything that requires "multiple" ownership), until they really fully understand how borrow checker and ownership work, and why ownership rules are really hard to satisfy in these cases. It can be very depressing fighting with these "cannot move out of borrowed content" messages, causing developers to give up learing Rust-lang too early.

 

Looking at the code, I believe there are several things can be optimized further in uq, e.g. holding a StdinLock rather than using stdin() for each line, having a persisted String as buffer to avoid allocating for getting string every time.

 
 

Great Post !!!

I have been recently interested in various languages and comparing them with each other. I agree that coding in Rust is not an easy task ( added that it has 3500 + open issues), yet the thought of omitting the entire garbage collection overhead and giving the responsibility to the programmer with the feature of "Ownership" is intriguing.

I love these new ideas in Rust!

code of conduct - report abuse