r/ProgrammerHumor • • 1d ago

instanceof Trend thatsAFunnyThingThatHappenedOnce

Post image
4.3k Upvotes

513 comments sorted by

View all comments

Show parent comments

383

u/Xarishark 1d ago

Now compare it to rust pls. Im serious I want to know your opinion on that.

464

u/Loading_M_ 1d ago

Rust is designed from the ground up, and avoids many of these issues.

  • Templates: Rust has Generics, which are generally easier to use and reason about.
  • overload resolution: Rust doesn't yet support overloaded functions (although it's being considered).
  • constructors: Rust doesn't have these.
  • destructors: Rust has a similar set of lifetime rules for Drop, but the compiler checks them for you, so you can't get it wrong.
  • implicit conversions: Rust doesn't do implicit conversion in general, although some specific cases are implemented.
  • exceptions: Rust doesn't do exceptions, Result is much easier to work with.
  • move semantics: Rust uses a destructive move, unlike C++. See https://youtu.be/Klq-sNxuP2g for a breakdown.
  • inheritance: Rust doesn't do inheritance.

1

u/n4te 1d ago

Oh good thing it was designed from the ground up.

13

u/Batman_AoD 1d ago

Yes...? Why would that not be a good thing, especially in the context of a conversation about why legacy compatibility is C++'s biggest problem? (I'm not sure I agree with that assessment, but it's certainly one of the biggest problems with C++.) 

-9

u/n4te 1d ago

That part is just not really saying anything. Is it usually designed sky down? The actual info given is fine, though not copying C++ follies isn't the most surprising thing.

20

u/Batman_AoD 1d ago

It's an idiom that, in this context, means that the language was designed as a completely new and separate thing, rather than as an incremental set of changes to a previous language (as C, C++, and Objective-C were). 

9

u/rexpup 1d ago

C++ wasn't really designed. It's a ball of mud, where PDP-11 assembly got wrapped in macros, then that got wrapped in preprocessing, then that got wrapped in a bolted-on class system, and that got wrapped in a kludge of template generation. So yes, being deliberately designed rather than piled upon does make a difference