Fixing C's Biggest Mistake
areYouSureAboutThat
areYouSureAboutThat at gmail.com
Thu Dec 29 21:50:00 UTC 2022
On Thursday, 29 December 2022 at 20:38:23 UTC, Walter Bright
wrote:
>
> ..... The *actual* billion dollar mistake(s) in C are:
>
> 1. uninitialized data leading to undefined behavior
>
> 2. no way to do array buffer overflow detection
>
> because those lead to malware and other silent disasters.
>
> And it's good to have a state that a memory object can be
> initialized too that cannot fail.
I would argue, the billion dollar mistakes are really the fault
of the users of the C programming language, and not the language
itself.
Those sames users can make billion dollar mistakes in any
language. Perhaps, not those particular ones you mentioned, but
others. Even in the most safest language possible, a programmer
could leave an API exposed, that wasn't meant to be exposed...
The programmer can actually do runtime bounds checking in C. e.g.
Create your own vector type with bounds checking.
The programmer can also initialise everything to a known state in
C. One could also use calloc instead of malloc, or create a their
own memory allocator.
The C standard library didn't help either. It too could have been
designed in a more memory safe manner. But like C itself, it is
minimal, perfomance oriented, and not designed to get in your way
and make things difficult for you.
Even if C did all these things for you, and more, it's likely C
programmers would have found a way to remove them, turn them off,
created their own vector that doesn't do bound checking, create
their own memory allocater that doesn't initiaslise its
allocations ...
e.g -release -noboundscheck .. sound familiar?
More information about the Digitalmars-d
mailing list