With Rust alpha 2, Rust has finally reached a level of stability where I feel comfortable exploring it and not worrying about spending more time updating my code due to Rust changes than I will spend time actually coding and learning Rust.
For my first Rust experiment I ported Kevin Beason’s smallpt to Rust. The result can be found here. The code hasn’t been squished into 99 lines, but is instead slightly more readable than the original. The reason for picking smallpt as a first project was to get a feel for Rust’s math library and try some simple threading with dataparallel loops. And of course render a nice image in the most inefficient way possible!
So far I’m quite happy with Rust: The functional inspired syntax is nice and simple. Pattern matching and struct destructuring is quite powerful and makes for some very safe code patterns in combination with Option and Result. The scoped thread I used for dataparallelism was quite simple to use and it would be easy to wrap the whole thing in a dataparallel for_each method, which might be my next little Rust project. However, the borrow checker, which is Rust best and most unique selling point, is also the hardest part about Rust. Even in my tiny project with only a tiny amount of parallelism, I had to fight the borrow checker and try to interpret compiler errors. I am sure that if I spend enough time with Rust, me and the borrow checker could become best of friends, but there is a steep learning curve to it. Hopefully it will be worth it and I can transfer the ownership idioms and patterns that I learn in Rust back to my other projects in other languages.