DEV Community

Sohail Pathan
Sohail Pathan

Posted on

Share your experiance with RUST Programming language

Hey Devs,
I want to learn Rust programming. Have any of you tried using it for small projects or in production?

I'm curious to know:

  • What are your observations about Rust?
  • Is the learning curve steep?
  • Is it easy to implement API calls in Rust?

I'd love to chat more!

Top comments (3)

ranjancse profile image
Ranjan Dailata

I haven't tried but who knows, in the future I might learn and work with it.

Observations - Rust programming seems to be an easy one if you are coming from a strong C, C++ background.

Learning curve is steep, it's not an easy one.

API development is ok, but why would you go with Rust?

Rust: Well-suited for low-level operations, performance-critical applications where speed is paramount (e.g., game development, real-time systems), and situations requiring precise control over resources.

The below quote is from rust-gentle-intro

The big difference from C and C++ is that Rust is safe by default; all memory accesses are checked. It is not possible to corrupt memory by accident.

iamspathan profile image
Sohail Pathan

Thanks @ranjancse. Fortunately, I come from an era where the first programming language was C/C++ only.

speratus profile image
Andrew Luchuk

I have used Rust for a number of small projects. I'm no expert, but I certainly do have opinions about it.

TLDR: Don't let Rust's steep learning curve deter you from trying it out. I think that it is the programming language of the future.

Why I chose Rust

I wanted to get into low level development because up until learning Rust, all my experience was with higher level languages with garbage collectors. I wanted to learn a lower-level language that compiled directly to machine code and didn't have an intervening VM or interpreter.

For this, Rust was ideal because it allowed me to get into lower-level programming without risking creating projects that inadvertently destroy my computer due to improper memory management.

What about Rust's Learning Curve?

Compared to what I was used to, Rust's learning curve was very steep. Rust's borrow checker enforces seemingly arbitrary rules that are difficult to understand (at least coming from the perspective of a Java/Python/Ruby/JavaScript developer). If your main body of experience is with languages like C/C++, you may find these rules natural and desirable because you have already integrated best practices into your development habits. But be warned, Rust's borrow checker is quite the beast.

On top of that, Rust's type system is easily the most purely mathematical type system I have ever encountered. By that I mean that Rust's type system is strongly modeled after functional type systems where the goal is to achieve an almost mathematical description of a thing's properties. I'm sure that there are more purely functional type systems out there, but I haven't used the languages that implement them, nor do I plan to at this stage.

Also, be prepared to handle every possible error your application could generate. Rust's error handling model is essentially "oh, your application through an error? Deal with it yourself". Rust does not have an exception system. While this might seem a little extreme, in practice it means that Rust applications are hard to crash (The only times I ever experienced a Rust application crashing are when it was integrated into a much larger third-party application which was not written in Rust).

Should I Still learn Rust?

In my opinion, YES, you should!

Despite the warning about Rust's learning curve above, I think there are some definite advantages to Rust that merit learning and using it.

  • It's designed to be perfectly memory safe, meaning memory leaks should not be possible. (Yes, I know it doesn't always achieve this, but making that a goal is still better than not even trying).
  • Consequently, in theory, Rust has more security built into it by default than many other low-level languages.
  • This means that as adoption increases, I believe Rust will slowly edge out C and C++ (and other languages) when it comes to developing applications that require any level of security.
  • Adopting Rust early helps drive further adoption, which will hopefully cascade into the programming community at large moving closer to best practices when it comes to memory safety.
  • I also believe that Rust has some major advantages over Python when it comes to machine learning, namely it is faster and safer, so I think that it has the potential to replace Python as the de facto language for machine learning (though this is not likely to happen any time soon).

A Brief Note on using Rust for APIs

You asked whether it's easy to implement API calls in Rust. I, unfortunately, have very little experience with API calls in Rust, but what I can say from the little I have worked with them is this:

Writing API servers in Rust is less convenient than it would be in, say, Python, but the only Rust library I have used to create an API server is Rocket (which as I understand it is no longer the preferred option for web development).

Finally, how difficult is it to call APIs in Rust? I don't know the answer to this because I have never tried to do so, but I have little doubt that with the use of the right crate, it could be made almost as easy as it is in a language like Python.

Final thoughts

I think that if you are interested in learning Rust, you should definitely go for it. I think that it has a number of significant advantages that will become more and more valuable in the future and that as a result, it will continue to gain market share.

Learning Rust is hard, but I think that ultimately the payoff from learning Rust will be worth overcoming its difficulty.