From: Neil Audsley (Neil.Audsley(at)cs.york.ac.uk)
Date: Tue 29 Oct 2002 - 13:22:21 GMT
C did not claim to be a strongly typed language, nor particularly high level (to quote K&R from the original 1975 Technical report "C is not a 'very high level' language..."). The fundamental concept was that pointers are to memory locations - it is upto the programmer to ensure that there is something valid in memory to point to. Also remember that the original C library was written (by M. Lesk, not K&R) to ensure code took as little space as possible (PDP-11 was the first target). Yes gets() could overflow the buffer - that is why subsequent C libraries give you fgets() which you cant overflow. Yes Algol68 did somethings better ... but there again it was designed as an application programming language, not one for writing OSs. On Tue, 29 Oct 2002 13:11:48 -0000 "David Crocker" <dcrocker(at)eschertech.com> wrote: > > > Neil Audsley wrote: > > >> > Please remember that C was designed for writing Operating Systems in > (specifically > the first incarnations of UNIX). K&R shouldnt be critised for what people > have > misused their perfectly good language for! > << > > That doesn't excuse "gets", which is obviously intended for use in > applications. And even as a language for writing operating systems and other > systems software (e.g. all the sorts of components that routinely turn out > to have buffer overflow problems), it could so easily have been much, much > better. Treating arrays and pointers as the same thing in a language that > claimed to be strongly typed was asking for trouble. > > Fortunately C++ provides a way around this (i.e. ban arrays, using library > classes instead to represent all collections). But C++ is also very badly > designed in a few places (e.g. only an idiot would mix overloading, > automatic type conversion and default parameters in the same context; in > contrast, Algol 68 showed how to provide overloading safely many years ago). > > David Crocker > Escher Technologies Ltd. > www.eschertech.com > > > -- ========================================================================= Dr. Neil C. Audsley Email: Neil.Audsley(at)cs.york.ac.uk Senior Lecturer Phone: +44-1904-432787 Department of Computer Science, Fax: +44-1904-432767 University of York, York. Y010 5DD, UK