Hacker News new | ask | show | jobs
by deluvas 4474 days ago
Can you explain why that's not a good idea? I have no clue, really, but I'm guessing something about libraries.
1 comments

No, it's because writing software in C++ is like riding your bike in the middle lane of a highway with no helmet on.

If you're really really careful, it can work fine, and your trip will be efficient and productive. But it's really hard to do it properly -- you could hit a car (buffer overflow), you could get hit by someone (heap overflow), or your brakes might give out (input sanitization fail).

It's not that it's impossible or that it's a "bad idea", it's just that it'd be a lot safer to spend the extra resources on a motorcycle (Python) or an SUV (Rust).

C is irreducibly dangerous, but you can do quite a lot with C++ by avoiding legacy C stuff. Build almost everything on top of the STL and Boost, which are safe.

And of course there are security bugs (eg, goto fail) that would affect any language.

Fully agree, mankind would be better without C and C++.

But given they are the current mainstream options for the time of applications they are used to, better use modern C++ like you are advocating and stay as far as possible from any pure C constructs.

Additionally use static analyser, enable all warnings as errors and turn on pedantic mode.

> Build almost everything on top of the STL and Boost, which are safe.

this is not really true, you can have temporal memory safety issues using STL and boost.

The examples should be the other way around. Very safe and simple to drive but slower and not that powerful: bike an a proper bike lane (Python). Reasonably safe & fast: SUV (Rust). Really fast and you can do crazy things (drive on one wheel at 200km/h) but also enormously dangerous: Motorcycle (C/C++).
Or a tank (Ada). Seriously, Ada is alive and in version 2012 pretty okay. It depends on your application domain, of course, but if you care about safety and reliability, Ada is battle-proven.