Type safety could prevent nuclear war
tsbockman via Digitalmars-d
digitalmars-d at puremagic.com
Thu Feb 4 16:14:11 PST 2016
On Thursday, 4 February 2016 at 23:53:58 UTC, Ola Fosheim Grøstad
wrote:
> 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.
OK. That's a good reason for C's original design.
But it's 2016 and my PC has 32GiB of RAM. Why should a C compiler
running on such a system skip safety checks just because they
would be too expensive to run on some *other* computer?
This isn't even a particularly expensive (in compile-time costs)
check to perform anyway; all that is necessary is to store a
temporary table of symbol signatures somewhere (it doesn't need
to be in RAM), and check that any duplicate entries are
consistent with each other before linking.
This is already a solved problem in most other programming
languages; there is no fundamental reason that the solutions used
in D, C++, or Java could not be applied to C - without even
changing any of the language semantics.
More information about the Digitalmars-d
mailing list