[OT] C vs C++

MrJay mrjcraft2021 at gmail.com
Tue Aug 30 21:33:39 UTC 2022


On Friday, 26 August 2022 at 21:16:20 UTC, Dukc wrote:
> C++ is meant as an advancement of C. And it's used as one. Dmd 
> was written in C++ until version 2.069, and countless other 
> programs, both open and closed source still use it. It makes 
> sense - it's a superset of C (well, almost), so one can always 
> fall back to C features when the more complex features of C++ 
> don't justify themselves.
>
> Yet, many of the most well-known and successful programmers 
> [don't see it like 
> that](https://harmful.cat-v.org/software/c++/coders-at-work). 
> Can it be that C++ is so complex that even conservative use of 
> it makes your codebase so unreadable that even the archaic C is 
> a better choice? Think how crazy this is - the cream of of our 
> profession resort to pointer / length pairs over `std::vector`, 
> and copy-pasting the module name to every public declaration 
> over using namespaces.
>
> There has to be HUGE downsides in C++ for this competent people 
> to resort to this drastic avoidance. They do say what the 
> downsides of C++ are about: too big a language to learn well, 
> so code ends up using features the reader does not know. Still, 
> if this is the case one would think it had been long since 
> generally aknowledged: C++ guidebooks would tell to avoid 
> less-known language features absent strong reasons, and later 
> languages ought to have more pressure to be more minimalist 
> like Go and less "CISC" like D or Rust. Yet, complex D features 
> like ranges (okay, more of a Phobos feature), operator 
> overloading, CTFE, objects and templates don't seem to be 
> commonly hated.
>
> This inconsistency in our attitude towards language complexity 
> is interesting in my opinion. I want to hear your opinions, 
> would you rather use C or C++ in your job if you had to pick 
> one ("it depends"-answers okay). But most importantly, why? 
> What do you make of that C++ complexity seems to be so 
> appreciated and so at contempt at the same time?

C and C++ is very complicated, I recently had to choose between C 
and C++, but I ended up choosing D instead. the reasons why are.
1. to many baskets not enough eggs.
2. Community designed complexity.

* To many baskets not enough eggs
C was designed to be a systems level programming language, it 
became a general purpose language because of community and 
industry effort, C++ was not designed to be anything it is an 
extension on C it was designed to be C plus extra features, as 
C++ became designed they want there cake and to eat it to, 
meaning that they want every good feature from many other popular 
languages like Haskell, or Python or whatever, however the 
difference between what D has done and C++ is doing that D was 
for the most part designed to Read fast Write fast and Run Fast, 
its on the home page, C++ is designed to be fast, and every other 
feature that C++ tries to add is just a bonus if they can even 
get it to work, for example I cant image C++ with a GC, however 
they talk about adding usability features, and it sure sounds 
like that would be a feature that would help their target 
audience, the designers talk about adding features to help 
scientists but its just talk unless they actually do it, and a GC 
would help, but they are not willing to make sacrifices to make a 
general purpose language, D is a general purpose language, it 
sacrifices Speed when it needs to when you want to just test an 
idea, but you can also make it as fast as C or C++. the design 
has clean edges even if its very broad, while C++ is also very 
broad but it has very rough edges.

* Community Designed complexity
When I tried to learn C++ the part that made me the most confused 
was the community, C style code tends to be faster than C++ style 
code, at least by my metrics and the metrics I have seen, so I 
want to use C to make faster programs, but I like many of the C++ 
libraries and some of the nice features, however when I go to 
learn C++ so much code is in C++ style as a beginner I really 
didnt want to decipher it all, so I just wanted to use C instead 
but then I find out about this awesome C++ library and the cycle 
continues, though this issue was self inflicted, all I had to do 
to fix the issue was to not care about how fast my code is, but 
that is the whole purpose of using C and C++, typically use that 
your code is fast. so why use C++ for ease of use, for me it was 
supposed to be for speed. so again like what I mentioned above 
its meant to be for speed but the code people write is because 
its "Correct" code, because that code according to someone is 
easier, which tends to be slower.

the community the language design in some ways.



More information about the Digitalmars-d mailing list