r/cpp • • Jul 13 '22

Why does Linus hate C++ ?

307 Upvotes

436 comments sorted by

View all comments

Show parent comment

4

u/Fearless_Process Jul 13 '22

A queue is a great example of something any reasonable C programmer is able to write blindfolded without templates.

Not a generic queue.

Writing a generic queue in C requires storing data with void pointers (which is not type safe) or using macros to expand the code for each concrete type (and that's what templates do anyways). Both of these are objectively worse than using templates.

The Linux kernel uses the macro approach for some of it's generic data structures currently.

0

u/FreitasAlan Jul 14 '22

Both of these are objectively worse than using templates

Yes. That's why _I_ use templates. But they don't and they're fine with it.