[OT] C vs C++

Abdulhaq alynch4048 at gmail.com
Tue Aug 30 11:20:49 UTC 2022


On Friday, 26 August 2022 at 21:16:20 UTC, Dukc wrote:
>
> 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?

I'm a polyglot developer (going back to assembler, LISP, even 
COBOL for a few weeks), but most of my professional coding has 
been in Python, Java, and older 4GLs (LOL). However I have used C 
and C++ a lot in my hobby code and I've learnt over time that I 
now understand them better than many 'professionals'.

Around 20 yrs ago I decided to write a chess playing program that 
would make moves based on a strategy rather than brute force. I 
first wrote it in Java (around 1.4.2) and surprise, surprise it 
was dog slow. So I rewrote it in C++ and I was very disappointed 
to find that it was still very slow, in nodes per second, 
compared to other engines. Finally I rewrote it in C, and saw 
good performance. I later realised this was because in Java and 
C++ I was using 'new' for each computed new position (node). In C 
I just made a huge flat array up front at the start.

Anyway, to learn C++ I had used some sort of Teach Yourself C++ 
in 24hrs book (yes, really). It taught all about the wonders of 
inheritance etc.

Later, I started reading Herb Sutter's Guru of The Week column. I 
decided that there were too many gotchas and reluctantly 
abandoned C++ for hobby work. I also read a book with interviews 
with many famous software engineers, and most of them hated C++ 
(https://www.goodreads.com/book/show/6713575-coders-at-work).

At this stage I was helping to engineer high level designs for 
commercial aircraft using Qt, VTK, SciPy, python, CAD kernel 
software - we were doing good, technical work to a high standard. 
It was professionally held together with good quality python code 
calling libraries written in C++ and Fortran.

Onwards, and I read Andrei's TDPL. I was excited by this! My 
first foray into D was exciting but ultimately I had to write too 
many tools to build a tool to build a tool. I also did not see a 
clear direction for D, and decided to sit it out (where I am 
today).

Then, I read Bjarne's A Tour Of C++, which is excellent. I 
practised with it and interviewed for a couple of C++ jobs. I 
realised that they knew less about C++ than me, and were living 
in the world of C++ 98. Also, the pay was not very good! I did 
not pursue those jobs.

Finally, now to answer your question, I would choose to use C++ 
over C if I was coding in a small team. For a bigger team? I 
might well just sit it out and keep looking for work in 
python/java.


More information about the Digitalmars-d mailing list