News for hackers. Stuff that matters.
Re:The two types of C programmers (a provocative thesis) by kps on Sunday April 23, 2023 @06:47PM (#35681478)
> it's not possible for human beings to write correct C code

It's not possible for human beings to write correct code.

The hardest bug I ever found in a C program, one that took cumulative weeks of work until a tractable reproduction was found, came down to a ‘<’ that should have been ‘<=’. No language would have stopped that.

Yes, different languages have different levels of expressiveness, and can preclude or expose different kinds of errors. You'll never have a stray pointer in Python, and you'll never OOM making an accidental copy in C.

Re:The two types of C programmers (a provocative thesis) by preseinger on Sunday April 23, 2023 @07:23PM (#35681769)
obviously yes

yet c code is inarguably more error-prone than basically any other language

Re:The two types of C programmers (a provocative thesis) by lelanthran on Monday April 24, 2023 @03:37AM (#35684710)
Nope. Many errors in JavaScript, python, PHP, etc are caught at compile time in C.

Of course, the errors that do get through might be more severe in C than in python, but not always.

After all, the most expensive and destructive RCE ever was in a piece of Java software.

Re:The two types of C programmers (a provocative thesis) by deterministic on Sunday April 23, 2023 @06:55PM (#35681552)
Not true. Check out CompCert, seL4 etc.
Re:The two types of C programmers (a provocative thesis) by tialaramex on Sunday April 23, 2023 @08:22PM (#35682206)
I assume this was a logic error, that is, the code as written was a valid C program that didn't do what you meant.

In that case this could have been caught with more careful unit tests, which would have exercised the erroneous condition, and potentially with fuzzing to excite corner cases. C is... not great for either of these.

Re:The two types of C programmers (a provocative thesis) by gavinhoward on Sunday April 23, 2023 @08:34PM (#35682293)
I don't know why you say that C is bad for exercising error conditions or fuzzing. In my experience, it's the best at those.
Re:The two types of C programmers (a provocative thesis) by tialaramex on Monday April 24, 2023 @06:21AM (#35685700)
It doesn't come with either capability, so you're adding third party tooling to get these working.
Re:The two types of C programmers (a provocative thesis) by gavinhoward on Monday April 24, 2023 @09:01AM (#35687140)
Well, sure, but that's true of any language.
Re:The two types of C programmers (a provocative thesis) by tialaramex on Monday April 24, 2023 @11:23AM (#35688756)
Nope, when I write tests in my Rust the out of box cargo test will check those tests pass.

If I wrote inline Markdown documentation for part of the Rust code with an example, cargo test will try to build my example, and check it works - not much good having a purported "example" which doesn't even work, is it? And yet many languages don't do this.

Re:The two types of C programmers (a provocative thesis) by gavinhoward on Monday April 24, 2023 @02:41PM (#35691442)
You said fuzzing and exercising error conditions. Rust's tooling does not do that. You need something to generate those tests.

Fuzzing is still not part of the default Rust tooling.

Re:The two types of C programmers (a provocative thesis) by GoblinSlayer on Monday April 24, 2023 @04:13PM (#35692549)
Mere existence of a test runner is infinitesimal compared to your proposed careful testing. Saying this as someone who wrote my own test runner, it's a few lines of code.