Skip to main content

My first foray into Rust: Querying data from the Federal Reserve of St. Louis

I’ve been enamoured by the Rust typing system and safety for some time now. After attending a couple of Udemy courses, I decided to get my hands dirty on an actual project. So I thought to replicate something I’ve done before in Python, which is to create a library that would help to obtain data from the Federal Reserve of St. Louis (FRED) data REST API.

Here are some of the deepest impressions that Rust has left on me in my little project.

Gitlab Repo Crates.io

First of all, let me just say that the typing system does not disappoint. Coming from Python where errors are often caught at runtime, being able to catch so many errors at compile-time was refreshing, albeit frustrating at times. While I’m sure many other programming languages offer static typing, I’m just commenting from my own point of view as a Python user.

Secondly, the idea of ownership and borrowing trips me up frequently. The concept of every variable having only one owner scope and having to deal with understanding how memory is allocated on the stack or heap is not something that a Python user like me deals with. Dealing with such issues has given me a different perspective of coding/programming that I believe will help me become a better developer.

Thirdly, I really really love how easy it is to define your own types via structs and enums in Rust. It opens up a whole world of possibilities of what we can do (again, coming from a Python user). It reminds me of the concepts I’ve read on Software Foundations Vol. 1 on how mathematical proofs can be thought of as computer programs.

Finally, I found that the Rust ownership rules together with the ability to flexibly define custom types forces me to think clearly about how my program should look like. Sure it’s a pain sometimes, having to define additional types and not being able to take a more laissez-faire approach to programming. But I really do think that if I keep at it, it will make me a better developer.

Looking forward to doing more projects in Rust…