Five Years of Rust

Today is Rust's fifth birthday! :tada: We wrote an article highlighting some of the biggest changes since 1.0 back in 2015. What have been some of your favourite improvements to Rust from these past five years?

37 Likes

I like many small qol improvements!

  • std::time::Instant implements Debug, so it’s easy to quickly time blocks of code (I used to maintain a crate for that)
  • fs::read_to_string is :heart:, there used to be files crate for that.
  • I like that we no longer need extern crate and ::! Originally I was against this, but now I love it, once again, Lang Team knows better than me :slight_smile:
  • Implementing std::error::Error is trivial now
  • We were able to swap our hash map implementation to a state of the art one! We didn’t do std::unordered_map on this one!
  • Iterator::find_map
  • Trailing commas in standard macros
19 Likes

Other small QoL improvements that I really like and haven't yet been mentioned

  • HashMap's Entry API
  • dbg! macro
  • matches! macro

Major QoL improvement (don't know if this was before or after 1.0 release)

  • every crate automatically publishing it's docs on docs.rs! and the generated docs are amazing
10 Likes

My favourite improvement is not related to the language: the welcoming community.

The community is growing but manage to keep the welcoming tone. This is not easy tasks when the audience get broader and broader and deserve some heads up!

16 Likes

This 100x. It’s a safe environment to ask questions in and try ideas out and learn.

But kudos also to all the efforts everyone is making getting rust to be just that bit better - it sure adds up to a lot over 5 years!

7 Likes

The new module and path rules have been great.

The gradual extension of the standard library, including ManuallyDrop, MaybeUninit, and conveniences like raw pointer methods - .add() and .read() have been a boon.

Some things remind us that everything is just a step on the long path towards Rust. Slice patterns are a natural Rust feature, it might have been in Rust 1.0 in another universe, but here we've seen it be gradually completed.

10 Likes

Beginner here. I really like the community and active user in Discord.

I like dbg! macro very much. Easy to debugg similar to JavaScript :slight_smile:

2 Likes

I believe one of the most valuable thing about the Rust, is it's community.
I was in many different communities, Python, Java, PHP and JS but Rust community is very different.
You are awesome :heart: :heart:

4 Likes

I've just recently gotten in to Rust, ~8 months or so, but my favorite thing by far, so far is async stabilization. I think that Rust has some of the most amazing and powerful async support of anything anywhere and it really brings an amazing new concurrency model to an already powerful language.

I also agree with the others that the Rust community is really amazing. Everyone can work together despite experience level and that is a cool thing.

3 Likes

For me the most valuable changes were NLL and new module system. Before that, working with modules was really hard, especially for newcomers (like me these days)

How did you print the debug detail in JavaScript? I try console.log and feel that it is very bad.

When concatenating strings, console.log isn't great. console.log("thing: " + thing); prints thing: [object Object].

But if you leave out the string concatenation, printing single object with no string concatenation usually gives good output.

For instance, this code:

let x = {a: 1, b: 2, c: {d: 3, e: 4}};
console.log(x);

Produces this debug in Firefox:

And that can be expanded into a form pretty similar to rust's dbg!():

And in node, it produces this:

> let x = {a: 1, b: 2, c: {d: 3, e: 4}};
undefined
> console.log(x);
{ a: 1, b: 2, c: { d: 3, e: 4 } }

Node also automatically expands to a horizontal layout when necessary:

> console.log({one_long_identifier_word: 4, two_long_identifier_identifier_words: 5, three_long_identifier_identifier_identifier_words: 7})
{
  one_long_identifier_word: 4,
  two_long_identifier_identifier_words: 5,
  three_long_identifier_identifier_identifier_words: 7
}

All in all, I think it's very similar to the functionality present in dbg!() and other Rust debug printing tools.

1 Like

In our project, when x is a deep structure, built dynamically, like a JSON response from some API, when we debug with console.log, it often show like this:

parameters: { fields: [Object] }

It is pretty useless.

Fair!

My JS experience is pretty domain-limited, so it makes sense that there are situations like that which I haven't run into.

dbg!()

.await

1 Like

I meant JavaScript, not Rust.

you just type in JS debugger; simillar to dgb!();

I would definitely say NLL are the #1 improvement. I gave up on learning Rust a few years ago because of how limiting lifetimes were. I tried again after NLL (without realizing there was a change in the language) and I thought to myself "Why did I give up last time? This isn't that bad." I believe NLL is the reason I was able to stick with Rust.

5 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.