[Info-vax] Memory Safe Programming Languages

Arne Vajhøj arne at vajhoej.dk
Fri Mar 8 10:15:24 EST 2024


On 3/8/2024 9:38 AM, bill wrote:
> On 3/8/2024 8:14 AM, Simon Clubley wrote:
>> On 2024-03-07, bill <bill.gunshannon at gmail.com> wrote:
>>> And, on another note regarding C and Ada.  The original GNAT
>>> compiler converted Ada into C and compiled it with GCC.  Now,
>>> it seems to me that points at two possible concepts.  One is
>>> that if Ada can be done in C then it has all the same flaws
>>> and warts.  Not sure I would like to go  in that direction.
>>> The other is much more interesting.  And that is the concept
>>> that C can, obviously, be just as safe as Ada.  The question
>>> then becomes why isn't it?  See my first paragraph.   :-)
>>>
>>
>> Well, that's a load of nonsense and shows a total lack of understanding
>> of how compilers work. All compiled languages are ultimately compiled
>> into assembly language opcodes. That doesn't mean they are only as safe
>> as the assembly language they are compiled into.
> 
> Well, I did discount explanation 1.  :-)
> 
> But, explanation 2 still stands.  If the "safe" code written in
> Ada can be converted to C then, obviously, the same "safe" code
> could be written directly using C.  The question really is why do
> programmers choose  not to.

Programmers are human. They try their best but they make mistakes.

If a large number of programmers write a huge application, then
there will be big number of mistakes made. Inevitable.

And this is where the language comes in:

mistakes causing compile time error => mistakes get fixed during development

mistakes causing runtime error => mistakes get fixed during development 
if found in test *or* result in unavailability of functionality in 
production if not found in test

mistakes causing undefined behavior => mistakes get fixed during 
development if found in test *or* result in unavailability of 
functionality or data corruption or data leak or combination in 
production if not found in test

>> OTOH, it could sound like the reasoning of someone trying to desperately
>> claim that C is somehow as safe as Ada. :-)
> 
> It is.  It is not any shortcoming in the language that makes C
> "unsafe".  It is the practices of the programmers.

The definition of a safe language is not a language that allows
safe code - the definition of a safe language is a language that
enforces safe code.

Arne




More information about the Info-vax mailing list