logoalt Hacker News

fasterik • yesterday at 9:49 PM • 5 replies • view on HN

It is a matter of skill to a large extent, though. A skilled programmer will write fewer bugs on average than an unskilled one. They'll know the patterns to avoid and have a higher bar for quality. Nobody can write 100% bug-free code, independent of programming language. Also, job title might correlate with skill but it doesn't rule out incompetence at the highest levels.


Replies

kragen • yesterday at 11:01 PM

Sometimes writing shitty code is a result of competence, not incompetence. I've seen much better programmers than I ever will be writing terrible code because it was the fastest way to get a prototype running and find out whether the problem was worth writing good code for.

tikhonj • today at 1:13 AM

Writing safer C is a matter of skill.

Writing safe C is a matter of either radically different (much, much slower) process or better tooling or both. Skill is not sufficient.

ambicapter • yesterday at 10:36 PM

It doesn't really matter, the most skilled programmers are usually working on harder stuff, so the bug rate remains fairly consistent.

rfgplk • today at 10:25 AM

C++ actually has numerous footguns that even experienced developers are completely unaware of. Main reason being is that C++ follows three models in parallel

* the C++ standard

* the CPU arch details

* the OS details

The standard itself delegates a large chunk of functionality to be "platform specific" which will inherently depend either on the CPU or the underlying OS. In fact C++ itself is entirely silent about the ISA other than loosely specifying the virtual machine the language is supposed to run on. So you can get scenarios where some code is perfectly safe on one arch (say alignment doesn't matter) while being severe UB/a failure condition on another (alignment matters and you fault the second you touch misaligned data). There are also other issues like integer over/underflow, fp issues, SIMD issues, memory access issues, stack/heap issues; all of which you MUST address.

Other languages don't quite have these problems because the compiler/runtime handles them and they instead give you a unified interface behind which to write your code.

Neywiny • yesterday at 10:07 PM

I think it's mostly a testing thing. Valgrind is a friend a lot of people haven't heard of for c/c++. Setting up good regression tests is an art. Maintaining them is even harder.