The COVID19 lockdown has been a pretty challenging time for everyone. Staying sane without the social interactions we normally have can be difficult. I took the time to learn a new programming language. This served several purposes.

  1. It helped focus my mind, and keep me relatively sane, and brought my wife and daughter moments of peace. :)
  2. I collect programming languages. This is something I blame on university where every new concept was accompanied by a new language to introduce it.
  3. I believe that understanding multiple programming languages and paradigms makes me a better programmer.

Additionally, there are other considerations in learning Rust:

Working in a world full of kubernetes, I’ve come to appreciate the small download size of compiled languages like Rust, Go and C/C++ over what feels like the bloat of JIT’d languages, and scripted languages that all need to carry around an immense amount of machinery just to provide a runtime for apps written with these languages.

Startup times: Compiled languages have it hands down here. Equivalent programs in a compiled language compared to a JIT’d language are significantly faster at delivering the first byte. Again, in a kubernetes world, this can have significant advantage.

Thinking ethically, the fewer bytes we transfer and the less work we need to do at runtime, the less energy we use. This is a win for the planet and a win for your pocket. Leaner applications using less memory, and taking fewer CPU cycles, mean you need fewer resources to run those apps. For a single app, that might not mean a lot, but if you are running tens or hundreds of them, that can make a big difference to the impact on your wallet.

So how long did my journey take? I spent about two months dabbling with a toy project, plus any number of attempts to read the The Rust Programming Language. The process is ongoing though. I’m no where near entirely proficient with the language, albeit that I feel significantly more confident than I did at the start of this exercise.

My toy project; Uploader - An application to watch a directory and move the files to cloud storage. When I first thought this might be a good project with applicability to services that we write at FINBOURNE, I immediately thought of Go. In searching around though, I couldn’t find a good “file watching library” that would also watch subdirectories. So I changed tack; What if I used this to help me learn Rust? After all, I learn best while doing; the exploratory process helping to frame the unknowns of the problem domain. Lots of pre-reading doesn’t stick unless I’m also doing. Little did I realize that this project would turn out quite well as a learning exercise. It managed to hit on the following points of interest:

  • async/await
  • trait usage
  • fake objects for testing, based on a trait
  • threading
  • web server
  • testing
  • signal handling
  • errors, and error handling
  • logging
  • ownership
  • lifetimes

Now to be fair, many of those touch points would have been covered with a contrived learning application, but I was surprised at the breadth it managed to cover. And it also manages to be a useful program, with real world application. Though it may never see service as I intended it, it has served its purpose in helping me learn Rust. I could have written it in C## in a couple of hours; but I’d have missed out on this golden learning opportunity.

#rust #living-in-lockdown #coding #programming #coding-skills #coding-life #codinglife #development

Learning Rust in Lockdown
1.20 GEEK