[net.unix-wizards] NL vs CR-LF

dmr (09/08/82)

I'm not positive I saw the original question, and probably haven't seen
all the replies.  But here are some thoughts.

Early Teletype machines (like the model 14 and 28, and later the 35 and 33)
used separate CR and LF codes, which has always seemed silly, especially
given the limited code space of Baudot, which the first 2 used.
Other relatively old terminals, such as the IBM 1050 and 2741, used
a single character for the new-line function.  (Some of the IBM terminals
had a separate "index" character that performed the LF function).

It was quite early in the career of ASCII, not just in the last 5-10 years,
that the NL was accepted as an alternate interpretation of the LF code.
It is a much more sensible choice, since the combined function of "new line"
is much more common than either CR or LF separately.  The Teletype model 37
terminal optionally interpreted NL characters (to enable the option one
installed a small spring.)

CTSS, Multics, and finally Unix adopted the convention of a single NL
character for the following reasons.

1)  Given that one is interpreting character streams (not records)
it is much better to use a single character than a pair of characters
to mark the end of a line.  For example, it is annoying for every program
to have to invent an interpretation for one of the characters
alone or the two in the wrong order.

2)  Given that a single character is to be used, it is better to use one
that conforms to the standard.

I have always been curious why terminal manufacturers have never adopted
NL, at least as an option.  A lot of terminals can send out CR-LF when
you push the return key, but this is useless.

I think the original question was: why not use \r (CR) instead of \n (NL)
to demarcate lines?  The answer is:

1) It isn't as "standard" ASCII
2) It would be a pain to change
3) It would not make life any easier anyway, since instead of having to
translate \n -> CR LF, the system would now have to translate
\r -> CR LF.
			Dennis Ritchie

ARPAVAX:mo (09/09/82)

I am glad to see Dennis respond to that, but I can't help but wonder
if one of the motivations was the Teletype 37, with a nice, big,
oversize newline key and a small, out of the way return key. Could
it be that Teletype was pushing for the future??  Maybe so...
(This is predicated on the impression that the 37 must have been a popular
terminal around Research at one point, otherwise, why in the world would
NROFF default to that type.)
	-Mike