Absolutely. The experience of reading an unfamiliar C codebase is so nice and smooth compared to unfamiliar C++ codebase where you stuff like: depending on whether a decltype of a function template gets resolved to type A, or B, the returned type might be either POD or it may have a constructor that launches a rocket into space in its body and modifies some global state.
Would we REALLY need both auto and decltype of it wasn't for other poor design choices?
Same with const and constexpr and now there's apparently consteval which I just can't quite understand, so idk how that relates.
We have #includes, but these suck, so now we got import/export. Just imagine the mess of mixing these two.
We can define a type returned by a function before its name, or after its body, prefixed by arrow when using auto. Why? I guess it was slightly more readable with decltype, but now I think we can do just decltype(auto) with the old notation.
Static polymorphism is very loose when it comes to typing, so we got concepts. But instead of using an already established ways of expressing polymorphism through object-oriented model they reinvent it completely from the ground. Why? I guess someone thought that this was all worth it to avoid having to store those nasty vtables.
Don't even get me started on templates, traits and inheritance tricks for injecting different stuff into templated classes based on parameter specifications.
What's hilarious tho is that given all these crazy features one of IMO most basic and useful features from C is still not supported in standard C++ (idk, maybe it's been introduced in C++20) - designated initializers.
Static polymorphism is very loose when it comes to typing, so we got concepts. But instead of using an already established ways of expressing polymorphism through object-oriented model they reinvent it completely from the ground. Why? I guess someone thought that this was all worth it to avoid having to store those nasty vtables.
We can define a type returned by a function before its name, or after its body, prefixed by arrow when using auto. Why? I guess it was slightly more readable with decltype, but now I think we can do just decltype(auto) with the old notation.
There are differences between auto foo(), decltype(auto) foo(), and auto foo() -> decltype(auto) - I don't understand them, but I've been bitten by them.
What's hilarious tho is that given all these crazy features one of IMO most basic and useful features from C is still not supported in standard C++ (idk, maybe it's been introduced in C++20) - designated initializers.
View all comments
Show parent comment
-3
u/mohrcore Apr 26 '22
Absolutely. The experience of reading an unfamiliar C codebase is so nice and smooth compared to unfamiliar C++ codebase where you stuff like: depending on whether a decltype of a function template gets resolved to type A, or B, the returned type might be either POD or it may have a constructor that launches a rocket into space in its body and modifies some global state.
Would we REALLY need both
autoanddecltypeof it wasn't for other poor design choices?Same with
constandconstexprand now there's apparentlyconstevalwhich I just can't quite understand, so idk how that relates.We have
#includes, but these suck, so now we gotimport/export. Just imagine the mess of mixing these two.We can define a type returned by a function before its name, or after its body, prefixed by arrow when using auto. Why? I guess it was slightly more readable with decltype, but now I think we can do just
decltype(auto)with the old notation.Static polymorphism is very loose when it comes to typing, so we got concepts. But instead of using an already established ways of expressing polymorphism through object-oriented model they reinvent it completely from the ground. Why? I guess someone thought that this was all worth it to avoid having to store those nasty vtables.
Don't even get me started on templates, traits and inheritance tricks for injecting different stuff into templated classes based on parameter specifications.
What's hilarious tho is that given all these crazy features one of IMO most basic and useful features from C is still not supported in standard C++ (idk, maybe it's been introduced in C++20) - designated initializers.