logoalt Hacker News

Panzerschrek • today at 4:50 PM • 3 replies • view on HN

> the mess in C++ is way worse

What is mess in C++? Yes, it has some shady parts and is more complex than C, but this complexity provides expressiveness and type safety. And you can always use only features from C++ you find useful.

> also contribute to projects that introduce C++ into a C code base, and I really wish they hadn't done this.

What is problematic in these projects other than unfamiliarity of C++ for developers previously used only C?


Replies

_gabe_ • today at 5:15 PM

> What is mess in C++?

Just a couple examples:

How do you make a shallow copy of an object in C++, how do you do the same thing in C? Knowing I can just memcpy _any_ struct in C and have a valid shallow copy is pretty huge.

How do you create a stable ABI in C++? How do you make one in C? In C, knowing that all my exported functions will mostly just work and be stable as long as I don’t change the interface is also huge and allows you to create cross language bindings pretty trivially.

➕ show 2 replies
lelanthran • today at 5:24 PM

> And you can always use only features from C++ you find useful.

Ah, the old "programmers just need to be more disciplined when using C++".

Yeah, C programmers have never seen that argument before...

uecker • today at 5:46 PM

My macro-vector types are type safe. In fact this is the point.

I do not think C++ is more expressive or type safe.