Re:Why Is C Faster Than Java (2009)
by marginalia_nu on Monday December 27, 2021 @11:12AM
(#29703651)
I'm not convinced this statistic is saying more than that these bugs are easily identifiable. There is a lot of tooling for identifying memory errors, and virtually none that could identify something like log4shell.
[ Parent
| on HN ]
Re:Why Is C Faster Than Java (2009)
by adgjlsfhk1 on Monday December 27, 2021 @12:28PM
(#29704530)
they are more easily identifiable, but they are also very simple. when writing C, you probably write a potential memory safety bug roughly every 100 lines. Even if you detect 99% with automated tooling that's still a pretty sizable attack surface.
Re:Why Is C Faster Than Java (2009)
by marginalia_nu on Monday December 27, 2021 @12:31PM
(#29704550)
> probably write a potential memory safety bug roughly every 100 line
If that is what your C code looks like, then yeah, you should probably not be writing C code.
Re:Why Is C Faster Than Java (2009)
by adgjlsfhk1 on Monday December 27, 2021 @01:26PM
(#29705166)
every array access and string comparison is a potential vulnerability in C. I'm not saying that in practice, all of them will be vulnerable, just that every one of those is a place where you could miss a check and end up with a memory bug.
Re:Why Is C Faster Than Java (2009)
by marginalia_nu on Monday December 27, 2021 @02:02PM
(#29705604)
That's kind of a disingenuous way to reason about it. You absolutely can bounds check your memory accesses in C, and bounds-checked accesses are as safe in C as they are in any other language.
Re:Why Is C Faster Than Java (2009)
by adgjlsfhk1 on Monday December 27, 2021 @02:21PM
(#29705815)
the point isn't that it's impossible to write C that's safe, it's that doing so requires 100% success rate of a human implementing something correctly. furthermore, the main cases where C can get a performance benefit over safer languages are where there is a complicated invariant that ensures safety. the problem is that these are incredibly easy to break during refactoring, or when a different dev modifies the code later. compilers are much better then humans at verifying that code is correct.