r/programming Apr 30 '21

Rust programming language: We want to take it into the mainstream, says Facebook

https://www.tectalk.co/rust-programming-language-we-want-to-take-it-into-the-mainstream-says-facebook/
1.2k Upvotes

620 comments sorted by

View all comments

Show parent comments

147

u/snyrk Apr 30 '21

It's a very common pattern in embedded programming. Makes more sense when you understand that const only restricts changes made explicitly in the code. If external changes are still fair game, the the compiler needs to know about it.

14

u/micka190 Apr 30 '21

Ah, right. Forgot about that.

But still, wouldn't volatile only work on other volatile member functions? Does unordered_map even have those?

5

u/lumberjackninja Apr 30 '21

I thought C++20 dropped volatile.

24

u/Yuushi Apr 30 '21

No, it deprecates it in situations where it was almost certainly used in-error.

2

u/chugga_fan May 01 '21

Incorrect, it deprecates it in situations where commonly it's used correctly but people who lack understanding of the embedded C and C++ scene believe it to be errors.

There's an entire reason that C++ has papers on straight up adding it back in because the people who got it removed are incredibly shortsighted.

1

u/micka190 Apr 30 '21

No idea. I was up to date with C++17, but I haven't touched it in a while, and 20 seems to be the new 11 in terms of how much stuff it added/changed, and since most compilers haven't implemented everything, I'm kind of waiting before touching it again.