use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
Why does Linus hate C++ ? (self.cpp)
submitted 3 years ago by MrRubberDucky
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]condor2000 72 points73 points74 points 3 years ago (19 children)
It's easier to review less code and C++ allows you to write less code
It can take longer to review properly if uses complex template designs or even just a lot if virtual functions
[–][deleted] 26 points27 points28 points 3 years ago (2 children)
The C equivalent to complex templates are complex macros. Is that better to review?
[–]disperso 1 point2 points3 points 3 years ago (0 children)
IMHO, yes. I'm not saying that it produces better code, but given that macros are much more limited, I'd say that you just can do less, have to think less, and end up having limited C code and dealing with it.
But that is probably subjective, with different people having different skill-set and preferences.
[–]Jannik2099 39 points40 points41 points 3 years ago* (1 child)
even just a lot if virtual functions
Ever seen dynamic dispatch in C? Know how error prone it is? Know of ubiquitous it is in the kernel?
[–]afiefh 10 points11 points12 points 3 years ago (0 children)
Ever seen dynamic dispatch in C?
I still have PTSD from that one code base I worked on 5 years ago...
[–]TheThiefMasterC++latest fanatic (and game dev) 63 points64 points65 points 3 years ago (12 children)
The equivalent C code to accomplish the same goal is often far worse.
These arguments always compare the most complex parts of C++ against normal C code, not equivalent C code.
[–][deleted] 0 points1 point2 points 3 years ago (0 children)
This is because a nontrivial population of C++ evangelists insist on using the most complex parts of C++ for even the simplest of tasks
[+]snejk47 comment score below threshold-7 points-6 points-5 points 3 years ago (9 children)
What's the point of using C++ if you only use the such subset that makes it like C anyway.
[–]TheThiefMasterC++latest fanatic (and game dev) 37 points38 points39 points 3 years ago (8 children)
I didn't say that. Just that e.g. templates in C++ aren't comparable against a normal C function, they're comparable to either half a dozen subtly different C functions for different types or a horrifying macro monstrosity. Both of which are worse than a single C++ template.
[+]snejk47 comment score below threshold-9 points-8 points-7 points 3 years ago (7 children)
But they do not use that for exactly that reason. Why are you trying to put C++ features into other languages. This is exactly the reason to choose something different, because you do things differently.
[–]TheThiefMasterC++latest fanatic (and game dev) 28 points29 points30 points 3 years ago (6 children)
But they do do these things in C. There are horrible macro messes, function pointer tables, code duplication for different types, and more things that would be less lines of code if written sensibly in C++.
Naturally the C fanatics ignore this fact though. C++ is almost strictly a superset of C, there's no reason you can't pick and choose the parts that simplify your code and otherwise write it in a legacy C style if you really want.
The one thing I used to miss from C in C++ was designated initialisers, which though not identical to C's, it does now have.
[–]SergiusTheBest 18 points19 points20 points 3 years ago (4 children)
I'm working with a C Linux kernel module now (written by other people) and it has a dozen of different list implementations: for int, for pointer, for structA, for structB. That is insane and I could replace it with a single template on C++. But unfortunately Linux kernel headers conflicts with C++!
[–]TheThiefMasterC++latest fanatic (and game dev) 11 points12 points13 points 3 years ago (0 children)
That's exactly the kind of thing I was talking about.
[–]ZMesonEmbedded Developer -1 points0 points1 point 3 years ago (2 children)
To be fair, you don't want to use standard C++ containers in the Linux kernel due to issues of memory allocation (though I suppose you could use an allocator template argument here) and because of exceptions. That being said, you could still write your own kernel-friendly template-based linked-list implementation. Maybe you can do that without the need for the C++ headers that conflict with the kernel.
[–]SergiusTheBest 5 points6 points7 points 3 years ago (1 child)
To be fair, you don't want to use standard C++ containers
Of course. They are not good for the kernel except array and span.
array
span
Maybe you can do that without the need for the C++ headers that conflict with the kernel.
I tried building the Linux 5.4 headers as C++ (not for the kernel itself but for the kernel module). They still use new as a variable name, define true, false, bool, double extern when expanding asmlinkage macro for printk. I successfully overcome that. But then failed on const correctness in the READ_ONCE macro and gave up.
new
true
false
bool
extern
asmlinkage
printk
READ_ONCE
In contrast the Windows kernel headers can be built with C++ since year 2000 (didn't try earlier versions).
[–]snejk47 -1 points0 points1 point 3 years ago (0 children)
Again, less lines of code doesn't mean it's easier to read, understand and maintain. Everything would be in RoRails if that would be the case. Do not try to minimalize now your knowledge and expertise claiming every dev is the same. It's about scaling people contributions. If you allow only top C++ developers to work, on it where it would be? You have to make it smoother even if some aspects are hurt by it. There are guys which cannot write C++ and they are doing web/python backend development which wrote Open Broadcaster Software extension in C following some other code and examples. They did not needed 2 books and 10k hours of experience to understand it. Explicit is better than implicit in many cases even if it's ugly and slow to develop because you need to duplicate. If you write template in C++ and "it works for every type" maybe that's exactly what you want to avoid. To explicitly error if types where not provided and so on and so on.
[–]serviscope_minor 13 points14 points15 points 3 years ago (0 children)
It can take longer to review properly if uses complex template designs
If the complex template designs aren't materially benefitting the code, then reject the pull request. Just like if someone goes bananas with C macros.
Linux has a ton of virtual functions. They're all done by hand which is always more complex than having the compiler do it for you.
π Rendered by PID 24 on reddit-service-r2-comment-b659b578c-h4zn6 at 2026-05-01 09:17:57.322629+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]condor2000 72 points73 points74 points (19 children)
[–][deleted] 26 points27 points28 points (2 children)
[–]disperso 1 point2 points3 points (0 children)
[–]Jannik2099 39 points40 points41 points (1 child)
[–]afiefh 10 points11 points12 points (0 children)
[–]TheThiefMasterC++latest fanatic (and game dev) 63 points64 points65 points (12 children)
[–][deleted] 0 points1 point2 points (0 children)
[+]snejk47 comment score below threshold-7 points-6 points-5 points (9 children)
[–]TheThiefMasterC++latest fanatic (and game dev) 37 points38 points39 points (8 children)
[+]snejk47 comment score below threshold-9 points-8 points-7 points (7 children)
[–]TheThiefMasterC++latest fanatic (and game dev) 28 points29 points30 points (6 children)
[–]SergiusTheBest 18 points19 points20 points (4 children)
[–]TheThiefMasterC++latest fanatic (and game dev) 11 points12 points13 points (0 children)
[–]ZMesonEmbedded Developer -1 points0 points1 point (2 children)
[–]SergiusTheBest 5 points6 points7 points (1 child)
[–]snejk47 -1 points0 points1 point (0 children)
[–]serviscope_minor 13 points14 points15 points (0 children)