Richard Heathfield said:
KIRAN said:
Because there was a teletype device in the 1960s on which moving the
carriage (the thing that carried the print head) from the right edge of
the paper to the left edge took twice as long as it took for a character
to arrive over the wire. To avoid dropping characters during the return of
the carriage from right to left, the designers split the task into two -
returning the carriage to the left edge of the paper, and feeding the
paper up a line - so that it would require two input characters to do this
one task, and thus the carriage would have time to do its thing without
any characters being dropped. (Essentially, the linefeed started life as a
padding character.)
If you're talking about the ASR33, this I think /required/ the two
characters, CR to move the head to the left, and LF to advance a line. They
were two different operations.
For convenience, whenever the user pressed Return, it was echoed back as CR
LF.
CP/M uncritically adopted the CR/LF convention, wasting one byte per line
of text file. Recognising this, the Unix guys dropped the CR, whereas the
Mac folks dropped the LF. 86-DOS (QDOS) inherited the pair from CP/M, and
then was rebadged as MS-DOS, which was later rebadged as Windows. So even
in 2008, Windows users are stuck with this two-character newline encoding
several decades after the obsolescence of the hardware whose shortcomings
it was introduced to work around.
I think Windows itself didn't help by requiring both CR and LF to be present
when sending text to the console, just like the teletype, otherwise lines
would either overwrite themselves (LF missing), or newlines would start
halfway across the screen (CR missing). So it was advisable to keep the CRLF
ending in a text file.
In text mode these will result in CR CR LF or CR LF CR, even more waste. And
if sent to a file, a lot of confusion for programs that expect specific line
endings.