[OT] C vs C++

Dukc ajieskola at gmail.com
Thu Sep 8 21:15:27 UTC 2022


On Thursday, 8 September 2022 at 14:50:01 UTC, Atila Neves wrote:
>> One could be what the top comment on that video says: "It 
>> wasn't the language itself, it was the people, and how they 
>> chose to use the language, and how they chose to show everyone 
>> how smart they were by using every possible feature of the 
>> language to its largest extent possible".
>
> That same person claims that "but the worst ANSI C I have 
> encountered was easier to fix than the worst C++ I have 
> encountered". Not in my experience.

Going crazy with macros will certainly make C as hard to read as 
any C++. But I think there may be a point in this otherwise. In C 
one pretty much only has to avoid being clever with the 
preprocessor, and it's hard to totally mess up the readability. 
But in C++ there are so much complex features that the code can 
have much worse readability issues than those caused by typical C 
problems (poor naming, no comments, lots of global state, 
oversized functions).

Worse, the complex C++ features are often recommended by the 
guidebooks, as opposed to macro trickery which is officially 
advised against.

Maybe the conclusion is that C++ is virtually always better than 
C in itself, but it's use is teached so badly that it often ends 
up worse.

> And that's part of the problem: we're all shaped by our own 
> past experiences, and that's easy to see when looking at what 
> different programmers prioritise. I think it's all a reaction 
> to being burned before and avoiding *that*, but we've all been 
> burned in very, very different ways.

Since D is a fairly complex language, I think we should talk more 
about when we should avoid the most complex features, such as 
traits. I suspect typical D programmers are not burned by 
overengineered language features as much as C programmers. Don't 
get me wrong, traits are great, but they do have a complexity 
cost in readability and error message quality. Sometimes a less 
perfect but simpler feature is the better choice even in D.

Related to getting burned by C++: Teoh made [an interesting 
rant](https://forum.dlang.org/post/mailman.216.1614033303.24831.digitalmars-d@puremagic.com) about that before.


More information about the Digitalmars-d mailing list