Abhik Banerjee
Bored on the Edge

Follow

Bored on the Edge

Follow
Rust = Big Brain Time

Rust = Big Brain Time

'nuff said

Abhik Banerjee's photo
Abhik Banerjee
·Jul 29, 2022·

4 min read

Play this article

Table of contents

  • Why did I switch to Rust?
  • Rust ain't fast!
  • Rust is Powerful AF
  • What did I use to get back into Rust?
  • Moving Forward

Somewhere, someone quite rightly said - "Coding in Rust makes you feel like a genius.". I don't think they were saying so because of how easy it is. Quite the opposite, coding in Rust takes a fair bit of practice. As someone who has used Go, Python, Javascript and Solidity, it is a bit non-intuitive. Especially if you are coming from Object Oriented Programming Domain.

download.png

Perhaps you would find the above image funny? Thankfully, the compiler is awesome. It gives great hints, especially at Lifetime and Borrow mistakes in code. That's something I really loved.

Coming from Go, Python and JS, the mandatory addition of ; kind of bummed me out. Granted Solidity has the same semicolons, when you are developing Solidity code, it shows in the extensions or Remix.

Why did I switch to Rust?

I am not really a newbie in Rust. I used it about a year back when contributing to rust-lightning. I really have to thank the awesome organizers of Summer of Bitcoin who advised me that knowing Rust (even beginner level) was an advantage and Jeffrey Czyz & The Blue Matt for being so supportive.

It was an awesome experience and I wanted to continue using Rust but truth be told - as an undergrad freelancer, I wasn't quite sure I would be getting projects in Rust which made me take a break from Rust.

I got started with it in the first place because I wanted to build on Substrate and Solana. While those goals have changed over time, my enthusiasm for Rust hasn't.

So in 2022, when I saw the hype was getting to Rust, I decided I should revise my concepts again. So far, I am glad I made this decision even though the path hasn't exactly been smooth.

Rust ain't fast!

You read that right. Rust isn't fast unless you make it so. If you compare simple Rust code with Go and Typescript, chances are Go will come out as a winner.

The advantages of Rust only become apparent when you have a fair amount of knowledge of its advanced data structures and crates. For eg, you might want to switch from using a simple list to a Vector. Using Hashsets and Hashmaps also offers significant powerup.

It is little things like these that differentiate between a good and a better Rust developer.

Rust is Powerful AF

The thing I liked the most about Rust when I started was how Rust differentiates itself from other languages by bounds. One such example would be the Enums in Rust.

The fact that you can have an Enum which can contain a value like an example below makes so much difference.

enum Example {
 Type1(String),
 Type2(u32),
 Type3,
}

I loved the way one could define such values in Enum. More so that the different values can have different types. Apart from this, the macro system in Rust is so well-defined. It is more elegant than C in my opinion. I haven't had a proper taste of Procedural Macros but the Declarative ones are easy to get started.

I did have a hard time around Lifetime Annotations in Rust though. The notion of defining a lifetime of an element via ' took me by surprise honestly. I remember going through examples of writing Solana smart contracts in Anchor and wondering what those meant. The below video helped clear my doubts.

You might want to subscribe to the channel.

What did I use to get back into Rust?

This article is not supposed to be a "list of curated resources for learning Rust". I would have titled it that way had it been so. Honestly speaking, the Rust Book is an awesome resource recommended by every Rust dev but I am more of a video kind of guy.

That's why I followed this awesome YouTube Channel called Let's Get Rusty*.

Bogdan does an awesome job in pushing out regular content on Rust. His playlists on Rust Book and Idiomatic Rust is something I would always recommend.

Apart from this, I used Exercism's Rust Track for any practical exercises along with the occasional personal experiments on Repl.

A healthy mix of Stackoverflow and the Rust Forum helped in solving most of my code-related doubts.

That's it really. That's all I used to get back into Rust.

Moving Forward

If you haven't been living under a rock, you should have heard about Google C++ successor - Carbon. It is in an experimental state and given the success of Go and Dart, the hype is building around it quite fast. That being said, the Rust community is also growing. Even Meta plans on using this language.

Funny how I started learning Rust for developing on Solana and Substrate but now am considering learning how to develop Games in Rust using Bevy.

Going forward, I will be publishing articles on Rust as well along with the usual Blockchain kind. There won't be anything specific in that I would be focusing on whatever piques my interest. If that's your thing then feel free to subscribe to my newsletter to get my articles as they get published and leave some love on the article. Cheers!

Did you find this article valuable?

Support Abhik Banerjee by becoming a sponsor. Any amount is appreciated!

See recent sponsors Learn more about Hashnode Sponsors
 
Share this