Type safety could prevent nuclear war

Ola Fosheim Grøstad via Digitalmars-d digitalmars-d at puremagic.com
Thu Feb 4 15:53:58 PST 2016


On Thursday, 4 February 2016 at 23:35:46 UTC, tsbockman wrote:
> Just because *sometimes* the source code of the other module 
> must be compiled independently, is a poor excuse to skip 
> obvious, useful safety checks *all* the time.

The context is a compilation system for building big software on 
very slow CPUs with kilobytes of RAM.

C was designed for always compiling independently and compiling 
source files that are bigger than what can be held in RAM, and 
also for building executables that can fill most of system RAM. 
So the compilation system was designed for using external memory 
(disk) and that affects C a lot. The forerunner for C, BCPL was a 
bootstrap language for writing compilers. So C is minimal by 
design.

BTW, C++ programmers sometimes use similar unsafe hacks of 
"pruned header files" to break dependencies and speed up 
compilation. So this is not unique to C, but C++ introduced the 
mangling of types into names to support overloading of functions 
on parameter types, which is why C++ detects (some) type issues 
at link time.



More information about the Digitalmars-d mailing list