Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site cornell.UUCP Path: utzoo!linus!decvax!harpo!floyd!vax135!cornell!hal From: hal@cornell.UUCP (Hal Perkins) Newsgroups: net.lang Subject: Re: I/O operations in programming languages Message-ID: <5189@cornell.UUCP> Date: Tue, 30-Aug-83 21:24:08 EDT Article-I.D.: cornell.5189 Posted: Tue Aug 30 21:24:08 1983 Date-Received: Wed, 31-Aug-83 23:22:55 EDT References: <666@mit-eddie.UUCP>, <110@csd1.UUCP>, <1796@allegra.UUCP> Organization: Cornell Computer Science Lines: 55 Something's not quite right here. The claim is that the C language contains I/O operations because any language that can be used to write useful, portable programs must contain I/O operations. I don't agree, and I don't think the argument holds together. First, I think it is reasonably obvious that the C programming language itself does not contain I/O commands in the sense that FORTRAN, COBOL, PL/I or Pascal do. In these languages, I/O operations have special syntactic forms and semantics that, in most cases, could not be defined by procedures or functions written in the language. For example, the Pascal read, readln, write, and writeln operations can accept any number of parameters of any of the basic scalar types, and a special notation is available to specify the format of numbers printed by write and writeln. These procedures absolutely cannot be defined using the standard Pascal language; they have to be specified in the language definition or they couldn't be there in their present form. In C and Ada, among other examples, there are no special forms for I/O commands. So I claim that these languages do not contain I/O. How then is it possible to use these languages to write useful programs? The answer is that there are standard libraries or packages that provide I/O operations. Furthermore, virtually every implementation of these languages includes the an implementation of the standard I/O packages. For C, this is customarily the standard set of I/O routines described in Kernighan & Ritchie. For Ada, DoD has decreed that all certified Ada implementations must provide certain standard I/O packages. So it seems to me there is no problem with the statement that C does not contain any I/O. The incorrect statement is the one that claims that any useful programming language must contain I/O--otherwise programs cannot communicate with the world. The correct version is that either the language must contain I/O statements OR ELSE a standard package of I/O routines must be available with all implementations of the language. This is one of the reasons that ALGOL 60 never caught on. ALGOL 60 contains no I/O. Nothing wrong with that--C has demonstrated that a language without I/O statements is perfectly usable. But the ALGOL 60 community never defined a single, universally available, set of I/O procedures, so there was no way to write a portable program that communicated with the outside world. (Actually, attempts were made to specify a standard ALGOL 60 I/O package, but these were never widely adopted. I suspect that it is at least as difficult to standardize the I/O package definitions as it is to standardize language definitions. In the case of C, the Unix environment has been so closely associated with the language that it became the I/O standard by default.) To close this excessively long note, it seems to me that languages should not contain I/O commands because this helps to keep the language definition short and comprehensable. But it is equally important to define a basic set of I/O operations that are universally available with every implementation. Defining a good basic set of I/O operations is a difficult design problem. Separating this problem from the basic language can only help; it simplifies the number of things that must be designed at the same time. Hal Perkins UUCP: {decvax|vax135|...}!cornell!hal Cornell Computer Science ARPA: hal@cornell BITNET: hal@crnlcs