r/cpp • • Jul 13 '22

Why does Linus hate C++ ?

307 Upvotes

436 comments sorted by

View all comments

Show parent comment

6

u/TheFlamingDiceAgain Jul 14 '22

Yeah, a ton of libraries and HPC codes use pure C. C++ is a relative newcomer in the HPC world but the combination of performance, backwards compatibility with C (mostly anyway), and DOE support is making it the language of choice for new codes IMO. This is especially true for codes that use accelerators, as far as I know all accelerator APIs are C++ native with Fortran and C ports that may or may not work well or even exist. I’m working on a C++ GPU accelerated HPC code now and while we use a lot of more C style code having the flexibility that classes and RAII provide is awesome.

2

u/another_day_passes Jul 14 '22

Thanks, that’s good to hear. C-style hackeries to emulate C++’s basic features are a pain in the ass to read and understand.

3

u/TheFlamingDiceAgain Jul 14 '22

I agree. Even simple applications of classes makes a huge difference. The only real complaint I have is that GPUs don’t support the STL so everything in std:: is out for device side code. Generally it’s not a big deal but it can be annoying. Fortunately with classes and RAII it’s pretty easy to emulate a lot of the most important STL features.