When I am learning a new programming language, I like to have a small project to work through to guide my learning.
I struggled to learn Clojure. It was radically different from any code I had written previously. However, it seemed really cool and I wanted to be able to use it.
Around the time, my friend Tony discovered Game about Squares, and we made a friendly bet about whether he could solve all the puzzles before I could write a solver for them. Tony won.
However, it turned out a project like this was exactly what I needed to pull all the concepts together. The result was solver-of-squares. Not only did this let me pull together the various ideas of the language, but it helped me to explore some interesting corners of language, like transient
and persistent!
.
I have been using Clojure for a long time now, so I consider the project a success.
Rust has been on my to-learn list for a few years now. I spent a few years writing C++ professionally, so the idea of memory safety without a garbage collector was interesting to me. That safety extending to concurrency was honestly mind boggling.
I am struggling to learn Rust. It is not a small language, and it does not appear simple at first. I did not find any of the concepts particularly challenging, but I find that the combination of them requires me to design programs differently than I have before.
It would be easy for me to dismiss Rust, although doing so would bother me. I don’t like to give up on learning something. Once again, I needed a small project to help bring everything into focus.
I decided to port my solver-of-squares project to Rust, and today I am making solver-of-squares-rs public.
There are still some things to address on the project.
The heuristic I use is not admissible. This means that the output of the program, while correct, may not be optimal. Solutions today may require more steps than strictly necessary to solve a puzzle.
The performance needs some more attention. After doing some profiling, I see that the majority of the time spent in the application is copying strings from state to state. I think I would like to work a solution that requires less copying. In order to do that, I will have to change the structures of the application a bit.
There are probably stylistic or other issues with the Rust code itself. Constructive criticism and PRs are welcome, and I will probably ask plenty of questions.
This feels like a good first step in my Rust journey, and I am excited to figure out where to go next.