this post was submitted on 15 Jun 2023
10 points (100.0% liked)

Rust Programming

8144 readers
47 users here now

founded 5 years ago
MODERATORS
 

cross-posted from: https://lemmy.one/post/123519

Skip to around 24m:00s

top 5 comments
sorted by: hot top controversial new old
[–] [email protected] 11 points 1 year ago (1 children)

He does, but the title makes it sound like he's criticising when he's just explaining some context.

He says they write their engines to be closely modelled on the specs, and that the web and the web spec is an object-oriented platform.

When asked if he'd use another language for Ladybird he first answers Swift - well actually he first jokes that he'd first design a new language, then says that he looked at Rust and likes a lot of things about it. When asked about why-not-Rust he says he likes OO languages and this project should be in an OO language because so is the spec, and Rust is not OO-friendly, “it's, like, OO-hostile”.

[–] [email protected] 2 points 1 year ago (1 children)

That's probably why I like Rust so much. I've felt for a long time now that after the concept of null, the widespread embrace of OO is probably the second worst decision in programming. While it was certainly better than the goto hell that preceded it, inheritance I think has ultimately proven to be a trap.

[–] [email protected] 4 points 1 year ago

To be fair, OO is not so strictly linked to inheritance, and one could conceive Rust structs and traits as a sort of OO system in some ways. For example, in the way that different struct types may implement a given trait and run a method with a common name and interface.

Still, I would say the design Rust accommodates is different from typical OO design.

[–] [email protected] 4 points 1 year ago

One of the things I like about rust.

[–] [email protected] 1 points 1 year ago

OO programming is such an overloaded concept that the answer here is "kinda".

Rust does make some patterns like the "sea of pointers" of OO languages a bit difficult (mostly due to borrow checking). It also doesn't feature data inheritance.

However, rust promotes a style of programming where encapsulation is key (notably to provide safe APIs around unsafe parts), and while the encapsulation unit is the module arguably structs with invariants are still "objects", in that in code that emphasizes maintainability you don't interact with their data directly but through their methods, this bundling data with behaviour. It also features static polymorphism through generics and trait, and dynamic polymorphism through either enums or through trait objects.

My personal take away is that rust has OOP, the good parts.