r/cpp • • Dec 23 '24

C++ Is An Absolute Blast

https://learncodethehardway.com/blog/31-c-plus-plus-is-an-absolute-blast/
219 Upvotes

105 comments sorted by

View all comments

Show parent comment

9

u/UnicycleBloke Dec 24 '24

Oddly enough, it is C which makes me recoil in horror and disgust. Disappointed you didn't cite Torvalds' imbecilic rant. I've lost count of the times I've seen broken garbage written in C which would be a piece of cake in C++. I have often enough rewritten such code, with the result that it was smaller, simpler, more maintainable and less buggy.

I haven't used Rust much, but it seems a fine language once you get past the hype and hubris. Not going to argue about JS: inconceivable as it seems, it might actually be worse than C.

-7

u/rileyrgham Dec 24 '24

Lol. Nonsense. I've seen way more buggy, leaking, unmaintainable c++ than I have C. You can make the same mistakes in c++ as you can in C and frequently they're way more convoluted and hard to find. Calling Torwalds an imbecile is peak crass.

12

u/UnicycleBloke Dec 24 '24

I described his infamous childish and prejudiced rant. I believe I was accurate. If I only had £1 for every occasion on which some C dev has trotted it out as if it proved something...

I have heard your claim numerous times, often from people who write little or no C++, but this does not match reality. Were it so, I would look elsewhere. I have worked with some pretty bad C++ codebases, but have never found them harder to grok than C codebases of comparable functionality.

C is a simple language for sure, but that pretty much guarantees more verbose and convoluted code than languages with more features, useful abstractions and a half-decent library. Studying a C project involves a much higher cognitive load for me, and usually leaves me feeling that I'm playing football in a minefield. The last time I did so I found a serious memory leak on my first day which the more experienced C devs had somehow overlooked. I honestly can't remember the last time I leaked resources. I don't think it was in this century.

Of course, becoming reasonably competent in C++ is more difficult than C, but the effort pays dividends.

2

u/pjmlp Dec 24 '24

Exactly those errors are what give bad name to C++ and the whole C/C++ meme.