▲ | motorest a day ago | |||||||
> What do you think of C and C++ coming with extensive guides for best practices and what features to not use? I feel that this is a disingenuous point and that you know better than this. For example, the poster child of C++'s "don't use this feature" cliche are exceptions, and it's origins are primarily in Google's C++ stye guide. https://google.github.io/styleguide/cppguide.html#Exceptions If you cross-reference your claims with what Google's rationale was, you will be forced to admit your remark misrepresents the whole point. You do not need to read too far to realize Google's point is that they have a huge stack of legacy code that is not exception-safe and not expected to be refactored, and introducing exceptions would lead their legacy code to break in ways that is not easy to remediate. So Google had to make a call, and they decided to add the caveat that if your code is expected to be invoked by exception-free code, it should not throw exceptions. Taken from the guide: > Because most existing C++ code at Google is not prepared to deal with exceptions, it is comparatively difficult to adopt new code that generates exceptions. I wonder why you left this bit out. If this is how you try to get D to shine, then you should know why it isn't. | ||||||||
▲ | WalterBright a day ago | parent [-] | |||||||
C++ has a lot of features which are not best practices. For example, you're not supposed to use the builtin arrays anymore, in favor of vector<>. Google's guide is not the only one. There are the Scott Meyers series "Effective C++" with things like "declare destructors virtual in polymorphic base classes". D's destructors in polymorphic are always virtual. This brings up another issue with C++ - conflation of polymorphic structs with non-polymorphic structs. The former should always be passed by reference, the latter maybe or maybe not. What C++ should have done is what D does - structs are for aggregation, classes are for OOP. The fundamental differences are enforced. How does one enforce not passing a polymorphic object by value in C++? Some googling of the topic results in variations on "don't do that". | ||||||||
|