Not So Rusty

2019.07.25

I ended up finsihing the Rust book in about a week. The syntax is super intuitive. I felt rather comfortable in the language almost immediately.

By incorporating some constructs typically seen in functional programming, it reduces much of the repetitive code one can see in some other languages, such as my recent adventures with Go.

For example, I used ripgrep to quickly check my use of if statements in my current project rtcoin. Right now, it's in its infancy as far as development goes, so the codebase is only around ~780 lines according to cargo count.


    rtcoin-server/src/main.rs:3
    rtcoin-server/src/db.rs:6
    rtcoin-server/src/conn.rs:11
    rtcoin-server/src/user.rs:5
    rtcoin-client/src/main.rs:2

Huh. That's including the test module at the end of the non-main files. Now, taking out instances of the word if that appear in comments or within other words like "Verify" I get 17. Not too shabby! Also of note, some of those are the if let construct common in rust for, eg, unpacking Option<T> and Result<T, U>. Without if let, it goes down to 11.

For this same project, I'm also challenging myself to use zero global state in the code itself. Rust makes global state a bit tricky to work with in the first place, but I'm excited to pull this off. Also, Rust's ownership system is helping me to explore other software designs that feel more robust and safer. I'll be carrying these lessons to other languages in the future, when appropriate.

back