Ruci and My First Experiences with Rust

I recently finished CIS 198, a minicourse at Penn on the Rust programming language. Rust is a language that "runs blazingly fast, prevents segfaults, and guarantees thread safety." It provides functional programming features while also giving you low-level control when needed. The feature that initially caught my interest is that Rust is memory safe without the need of a garbage collector. I never knew how much I would appreciate memory safety until I spent many late nights tracking down memory bugs in our operating systems project written in C. Rust achieves memory safety through its ownership model. When you first start with Rust, this will probably be something you hate. I definitely did. However, I now view it as one of the best features of Rust. It forces you to know how the variables and structures are used throughout your program and thus leads to better code. Code that results in nasty, hard-to-find bugs in other languages results in a compiler error (usually with a helpful message) in Rust.

Rust error message example

Example error message in Rust

Everyone knows the best way to learn any new programming language is by building something in that language. My final project was ruci, a UCI chess engine. Ruci was not only my first major project with Rust, it was also my first experience with artificial intelligence. So, it introduced me to concepts such as Alpha-Beta Search and Quiescence Search while also giving me valuable experience with Rust. The thing that most surprised me while working on ruci was how little I had to fight with the borrow checker (since I fought with it so much on previous assignments). I believe it was a combination of having more experience with Rust and designing and writing a program from scratch, therefore having a better understanding of the data structures and how they're used. The engine still needs a lot of work as it is extremely slow, but I look forward to working on it whenever I have free time during the upcoming semester.

Rust is a language that I am really excited about. I can definitely see it as the future, and I hope to see more and more people give it a chance. It has a steeper learning curve than a lot of languages, and you will probably become extremely frustrated with the borrow checker when you first start out. Stick with it. It will be extremely rewarding, and you'll avoid so many bugs in your future projects! If you run into problems, please take advantage of Rust's amazing community on /r/rust, #rust-beginners, and Stack Overflow. We are more than willing to help :).