Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Nobody can write "safe C" because C is inherently not safe. See my other comment about it. Safe means something like "if the program breaks some semantic rule, it will be caught and diagnosed". It's not a statement about the program being correct or not, but the consequences of if it were to be incorrect. Even tiny, trivial programs have the potential to be incorrect without diagnosis.

> C has been proven time and time again to be almost impossible to write correctly.

Silly hyperbole.



Without writing safe C you cannot write correct C. If your C is unsafe it is incorrect by definition.


That is obviously untrue by the definition of unsafe that I've been explicitly using.

I've been sticking with the concept of unsafe language, whereas you're talking about an unsafe program.

The two are related. An unsafe program misbehaves when given bad inputs. It's behavior is undefined.

An unsafe language is an unsafe program with regard to bad inputs, which consist of certain kinds of incorrect programs. (Those which are not diagnosed).

It's easy to write unsafe programs in unsafe languages. If we only focus on the program's functional requirements and none of them speak about what to do with bad inputs or in bad situations, we can end up with a program which is perfectly correct but unsafe. It will behave as specified on the correct inputs.

If you happen to be advocating Rust due to misunderstanding this kind of material, you're in it for the wrong reasons.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: