[OT] C vs C++

sonal13 singhalishaas60 at gmail.com
Fri Jun 23 10:17:42 UTC 2023


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?

The fact that C++ is a superset of C also means that it can be 
used to extend C programs. This is often done by adding new 
features or functionality to the program. For example, a C++ 
program could be used to add object-oriented programming features 
to a C program.

Overall, C++ is a powerful and versatile language that is 
well-suited for a wide variety of programming tasks. It is a good 
choice for both beginners and experienced programmers.

Here are some additional things to consider about C++ and C and 
check this to learn more about [c++ and 
c](https://www.interviewbit.com/blog/difference-between-c-and-cpp/).

C++ is a compiled language, which means that the code is 
converted into machine code before it is executed. This makes C++ 
programs faster than interpreted languages, such as Python.
C++ is a statically typed language, which means that the types of 
variables and expressions must be declared before they are used. 
This makes C++ programs more reliable and easier to debug.
C++ is a complex language, with a steep learning curve. However, 
it is a powerful language that can be used to create 
high-performance applications.
If you are interested in learning C++ or C, there are many 
resources available online and in libraries. There are also many 
online courses and tutorials that can help you get started.


More information about the Digitalmars-d mailing list