DEV Community

Cover image for Why Rust is a great language to learn
Alexandru-Dan Pop
Alexandru-Dan Pop

Posted on • Edited on • Originally published at blog.alexandrudanpop.dev

Why Rust is a great language to learn

I was looking at Rust today πŸš€. The reason is I understand the importance of knowing a systems language.

Systems languages can help us develop lower-level things like:

  • web servers
  • browsers
  • OS modules
  • CLI tools
  • embedded apps
  • web assembly apps

Why Rust will be successful?

Simple - successful technologies are the ones used by big tech giants in important projects.

I think Rust has a bright future given it is backed by Mozilla but also indirectly by Microsoft.
Did you know that Microsoft is actively using Rust for a couple of their critical projects like Azure and Windows, leveraging the powers of Rust while benefiting from it being memory safe?

Not just that, Rust already brings value to NPM, Dropbox, and Yelp.

Let's not forget that Rust can already be compiled into Web Assembly. While WASM is not that popular yet, it surely has potential for the future because it can bring computation heavy apps like games, interactive diagrams, or data visualization software to life.

Why Rust could be used over C/C++

Well... like many other important things in programming that are many times overlooked ... security! πŸ›‘οΈ Lot's of important system-level code currently runs in C/C++, and new vulnerabilities are found periodically. Most bugs are related to memory issues.

70% of all security bugs are memory safety issues (source here).

Rust is memory safe while being as fast or even faster than C or C++! 🧠 Even if you can still write code that has memory issues in Rust, the Rust compiler will do its best to warn you of those issues.

Rust is modern

Rust was designed to have good DX from the start:

  • package manager - Rust libs can be easily distributed as crates
  • crates.io - can be used to explore Rust libraries
  • modern testing tools
  • workspaces

πŸ‘‡ Leave a comment πŸ‘‡
Let me know if you used, learned, or intend to learn Rust. What was your experience with it? Is it as good as advertised?

Leave a 🧑 & πŸ¦„. For more interesting content also check out my Twitter.

Top comments (19)

Collapse
 
leob profile image
leob • Edited

I've toyed a bit with Rust and really liked its "FP" (functional programming) feel - I was surprised how many things in Rust reminded me of Haskell. It's a very subtle and elegant language, much more so IMO than Golang. I'm more interested in those kind of features, which allow you to raise the abstraction level and write succinct software, than in its low level "system" capabilities a la C++.

It would be interesting to see how it works if you develop a complete web app in Rust - backend and frontend - and compare that to developing a complete web app (backend + frontend) in JS or TS. As another commenter said, as it evolves further it might even become a viable alternative for "scripting" languages for this kind of task.

But I'm not really holding my breath for its market share in the jobs or projects marketplace, looks like it's going to remain niche for the foreseeable future. Pity because I do think it's one of the nicer and better languages.

Collapse
 
alexandrudanpop profile image
Alexandru-Dan Pop

Yes! One thing I forgot to mention in the article is the functional-style programming that Rust seems to have. You can do FP in Rust, but you can also use imperative programming with side-effects when FP is not possible.

Collapse
 
leob profile image
leob

The only thing that's not there (I've been told) is tail recursion, but for the rest the FP capabilities are quite complete ... but yes you can do imperative & "mutable" too. But the nice thing is that Rust gives you all the tools to do "safe" and "correct" programming, I was amazed at what the compiler can do (as a result the compiler is still noticeably slower than Golang's ...)

Collapse
 
thefluxapex profile image
Ian Pride

Learning Rust right now and I'm enjoying it! I don't like the file sizes, but it's not that bad; I'm a so-called hobbyist and write most of my software for myself (with some exceptions); usally cli tools, so I like as small of an application as I can (πŸ’•FortranπŸ’• ).

I just wrote the same program in Fortran and Rust and my Fortran bin without dependencies is 24k while the Rust one is 2.4MB. Admittedly, the Fortran AppImage with dependencies is 2.1MB, but it's still smaller and an average of 50ms faster (after a 1000 test loop) than the Rust one. And admittedly, Fortran isn't necessarily the best option for everything, but I usually find ways to do most everything I need in it and I also admit that I've been writing Fortran for many years, while I just started Rust so I'm sure my refactor for Fortran is probably better than what I wrote in Rust.

I learn for fun and personal use so none of the other reasons for using it matter to me.

I do like what they claim to accomplish, trying to get rid of lots of issues with other languages, but I'm not experienced with any of that enough to say much about it.

Nice article though and thanks for sharing!

Collapse
 
alexandrudanpop profile image
Alexandru-Dan Pop

One thing I forgot to mention is the functional-style programming that Rust seems to have. You can do FP in Rust, but you can also use imperative programming with side-effects when FP is not possible.

Collapse
 
javiersalcedopuyo profile image
Javier Salcedo

I'm currently learning it as a mostly C family dev, and, even though it has its unique challenges like ownership, the modules system and so on, I really love it so far.
It's amazingly fast, and Cargo is just ❀️.
It is simply a joy to use

Collapse
 
alexandrudanpop profile image
Alexandru-Dan Pop

Glad to hear you like it. There is also a nice web framework - Rocket.rs , I think this is what I will try next.
rocket.rs/

Collapse
 
kayis profile image
K

I think, it's a good language to learn, because it tries to get on a performance level with C/C++ and still delivers some high level features that you wouldn't expect from such a language.

Sure, some parts like lifetimes are often more cumbersome than simply writing a few lines of JavaScript, but on the other hand you get stuff like pattern matching and powerful macros, which are missing in JavaScript.

I think Rust is a serios contender to system programming langauges and if it gets a bit more sugary on a syntactical side of things, it could even take some use-cases away from scripting languages. Rusts integration with WebAssembly could help a great deal here.

Collapse
 
youroff profile image
Ivan Yurov

Quite funny and sad to read this in the scope of recent events: "I think Rust has a bright future given it is backed by Mozilla"

Collapse
 
alexandrudanpop profile image
Alexandru-Dan Pop • Edited

Yes, it is very sad that Mozilla had to lay off so many people lately, but I still think it's a good company that will succeed long term.

I like that their business model also focuses on developer tools and dev documentation.

Collapse
 
youroff profile image
Ivan Yurov

Oof... I'm not so optimistic. They basically slaughtered whole MDN team, doesn't look that their business model has anything to do with dev docs. :(

Thread Thread
 
alexandrudanpop profile image
Alexandru-Dan Pop

I guess time will tell, from what I read MDN will still be around and worked on, but there are no clear steps on how they will move forward yet.

While Mozilla is not a tech giant - they are still around, they don't seem to go anywhere, and I appreciate them for building Rust, among other things.

In the article that's why I'm also mentioning Microsoft - that's a huge company investing in Rust for their pretty critical systems.

Collapse
 
youroff profile image
Ivan Yurov • Edited

And yeah, I spent some time digging into rustc internals for a student project in formal verification, it was hard but fulfilling experience. Also it has undervalued potential for building web-backends, check this out: dev.to/youroff/ultra-fast-backend-...

Next time I'm building graphql for a greenfield project, I'm def doing it with rust.

Collapse
 
alexandrudanpop profile image
Alexandru-Dan Pop

There definitely seems to be some gems in this ecosystem - haven't got the occasion to look at those yet, but will soon when I get some free time:

Collapse
 
mayne_wong profile image
Mayne Wong

Mozzila -> Mozilla

Collapse
 
alexandrudanpop profile image
Alexandru-Dan Pop

Fixed, thanks!

Collapse
 
islamuddin profile image
islamuddin

We are 34 rust coders here and working together to learn, work, and code rust together. Following the dev community.
chat.whatsapp.com/CkJTxjlYCfhEQsm0...
We have practiced The Book Rust and Embedded Rust Discovery Book and practicing on rust web projects too.

Collapse
 
andrewbaisden profile image
Andrew Baisden

Optimistic I do wonder how Rust can be the most loved language in that stackoverflow study yet there don’t seem to be that many commercial jobs available for it yet. Is everyone just using it in personal projects?

Collapse
 
gklijs profile image
Gerard Klijs

It's not really a system language anymore. You can do a lot with writing little code yourself. Altrough it's not like Java.. yet. See also youtu.be/L6DvTCr6TF0.