this post was submitted on 28 Dec 2023
112 points (96.7% liked)

Rust

6005 readers
1 users here now

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

!performance@programming.dev

Credits

  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

founded 1 year ago
MODERATORS
 

Traits now support async fn and -> impl Trait (with some limitations), the compiler got faster, version = in Cargo​.toml is now optional, and many small functions have been stabilized!

you are viewing a single comment's thread
view the rest of the comments
[–] xav@programming.dev 13 points 10 months ago (1 children)

I find it's a mix between ML languages and C++, and knowing one of them would help yes. If you're tired if chasing a wild pointer because of a subtle use-after-free in a multithreaded monster under gdb, you'll love #rust.

[–] tatterdemalion@programming.dev 15 points 10 months ago* (last edited 10 months ago) (3 children)

Honestly the only things that are similar to C++ are small amounts of C-like syntax, RAII, smart pointers, and iterators. And even so, Rust improves those features a lot. The list of things that Rust rejects from C++ is much larger; Rust does not have:

  • new and delete (perhaps discouraged in modern C++)
  • function overloading
  • inheritance (replaced by composition or traits)
  • friend classes (replaced by modules)
  • exceptions (replaced by Result values)
  • 6 different kinds of first-class constructors (hallelujah)
  • templates (replaced by constrained parametric polymorphism)
  • variable mutability by default

Rust does OOP very differently and leans harder into functional paradigms.

[–] xav@programming.dev 4 points 10 months ago* (last edited 10 months ago)

You could argue that C++'s new is Rust's Box::new, and delete is replaced by RAII. Same concepts but way better ergonomy.

[–] taladar@sh.itjust.works 3 points 10 months ago

A lot of Rust concepts were also influenced by Haskell even though Rust uses different terms for them.

[–] 5C5C5C@programming.dev 3 points 10 months ago

The way I often describe it is "Rust makes functional programming feel as intuitive as object oriented programming".

Pedantically, Rust does offer a subset of object oriented programming paradigms so one could argue that it counts as an object oriented language, but the design patterns that work the best with the language are all coming from functional programming, all without feeling too alien to someone coming from a strictly object oriented background (.. which was my own path into Rust).