4 ms·
> most people who criticise C about it's "insecurities" use sloppy code when they criticise C, which always bothers me If you're really really lucky, your cowo
by MaulingMonkey 11y ago
> most people who criticise C about it's "insecurities" use sloppy code when they criticise C, which always bothers me
If you're really really lucky, your coworkers will only write sloppy code by accident. But unless you're only working on toy projects, statistics will catch up to you and sloppy code will happen. To err is human.
By NASA standards, I suspect most of your code has been written "sloppy". As has most of mine.
> but programming languages aren't safe, only code can be safe, and that depends entirely on the developer.
Languages can be safe in the sense that they can force code to be safe in specific ways, or at least warn you better with unsafe opt-ins or better static analysis.
We agree that the developer is to blame for the thousands of overflow CVEs out there.
One developer recognizes they're not an infallible robot, nor are their coworkers, nor is the new intern they're about to hire, and uses the tools at their disposal - static analysis, "safe" languages, etc. - to catch and fix some large percentage of certain mistakes they, and those they work with, make.
Another developer scoffs at the first for "blaming their tools" and tries to avoid mistakes with sheer willpower. By not setting up static analysis, maybe they save enough time to do an additional 10-20 code reviews over the course of the project.
All else being equal, who will end up with safer code?
> Yes, it's "easier" to introduce some bugs in C than Ruby (or Go, or whatever), but that's because whoever wrote that code with the bug didn't know C well enough.
If this is true, nobody knows C well enough. Find me a programmer who's written a sufficiently large C project without a single bug, and I will worship them as a living god.
> Is that C's fault? Same can be said about any language, really.
I don't care about fault, per se. But sure, let's blame C. And every other language. Let's not blind ourselves against their faults, and the possible ways we might improve them, and the possible ways we might adapt ourselves to them.
Let's not saddle ourselves with stone axes for the rest of our lives.
> If you don't know that String#match returns nil on unsuccessful matches and try to call MatchData#[], you'll get a NPE (something along the lines of "undefined method `[]' for NilClass"). This is very similar to dereferencing a NULL pointer in C[1].
Hence the point of talks such as "Null References: The Billion Dollar Mistake", and why some languages are designed to avoid letting you access potentially null/nil/nothing variables without checking that they aren't first.