The most exciting journey of 2020
Usually, I spend quite a bit of my time traveling or playing D&D. All was good and sound up until the year 2020 kicked in, and… well, you know what happened next. Travel got banned, tabletop players self-quarantined and all of a sudden I got lots of free time. Even though it wasn’t voluntary, it was something to deal with. I remembered that I tried Rust during 2019 Hacktoberfest and quite liked it. “That’s it!” — I thought — “I can learn a new tool I like and what’s even more important to spend some time.”
“That’s it!” — I thought, — “I can learn a new tool I like and what’s even more important spend some time”.
The Journey begins
Although I tried Rust for a few days and even created several PR’s to Open Source projects using it, I never actually had an opportunity to come back and use this language in production. And about half of a year is quite a long term. Long enough for me to almost completely forget something, I started learning and left. I believe it’s quite good actually because I didn’t have all that messy knowledge, which was barely enough to understand that I like a thing, but not worth building the whole experience on it.
I have started from the beginning by visiting the Get Started section of the Rust website and then following The Rust Programming Language book, which is used as “official” learning material.
Maybe The Real Treasure Was the Friends We Made Along the Way
For most of my career, I have used Python, JavaScript, or TypeScript. And though the latter is a statically typed, it’s still optional and often mixes with dynamically typed JS. I have started with C and Java, but that experience was brief before moving on.
With Rust, it was a refreshing experience in statically strictly typed languages. However, I would appreciate if Rust had a bit more introspection features like the ones Andrei Alexandrescu tells about in his The Most Average Function There Is talk (actually a great talk about the D lang).
Now, I will share some of the main points which stuck in my mind during this journey:
- **Love your types
**There are benefits of latent dynamical typing, but when switching to the strictly statically typed language, which still allows us to ignore explicit typings (yes, I’m talking about TypeScript), don’t omit them. It’s almost unbelievable how one can mess up with types and null/undefined values. Rust handles it for us withOption
enum and usually able to catch on the compile phase. But in TypeScript, when we useany
type, nothing protects us. - Be lazy. Write tests. Don’t spend ages debugging
We are lazy. Let’s admit that we don’t like doing something we think isn’t critical. Sometimes we think: “Nah, it’s an elementary function, what can go wrong here?” Usually, quite a lot 😉. Rust, with its rich compile-time errors, shows in how many ways we can forget some real minor things and later shoot ourselves in the leg. - **Performance is born within algorithms, much less within compilers and processors
**This is sometimes forgotten when we start learning. C is faster than JavaScript? Intel Xeon E7 will do the job much quicker than Intel Core i3, right? Well… You already get where I’m going, didn’t you? - **Platforms don’t limit language choices that much (wasm, lambda)
**I was quite surprised when I found projects like yew (WebAssembly based client framework) or AWS Lambda environment for Rust. Today you can use almost every language for every platform if you try hard enough.
Learning materials to consider
To start with, go to the Rust site and lurk around.
Listed under the “Get Started with Rust” section “the book”, Rustlings course and Rust by Example are all excellent resources which one should check on the way to calling themselves a Rustacean.
However, just like with any other tool, you learn best when using it for solving real tasks. It can be a wide variety of things:
- Contribute to Open Source projects you like or even use
Search GitHub’s ‘trending’ repositories for Rust projects and - Write your scripts using Rust instead of Python or Bash
- Sell your engineering manager idea of using Rust for one of your next non-core modules or R&D projects
- Create a pet project using it
All these ways will give you an understanding of real-world problems and limitations of the language, as well as the ability to compare the ways you solve similar tasks with your current language and a new one.
Conclusion
Today is almost two months since I re-started learning Rust. I must admit that there wasn’t an opportunity to use it extensively in my team, but I believe it is an advantageous experience. Mostly because of the parallels I drew between it and TypeScript environment I mostly live in.
Besides, the main goal, to entertain me, was met for 100%.
I hope that you found something useful here and wish you to stay safe and interested in learning new during these challenging times.