73

In the operating system (DOS) of IBM PCs, newlines were represented by a carriage return (CR) character, followed by a line feed (LF) character. The motion of a printer or teletype receiving such a combination would be first to move to the left, then down, and can be drawn this way:

---
|
v

or (if your browser font supports this)

However, the keyboards of those same IBM PCs used a different symbol on the return key: an arrow first drawn down, and then to the left.

   |
<---

or

Why didn't the return key symbol match the motion of a CR-LF?

(If the intent was to have a symbol for just the CR, |<--- () would have been better.)

14
  • 66
    God bless stack exchange for its curious and absurd questions, and equally curious and absurd answers. I have used cr/lf all my life, and never once had to think about it being backwards until today! Now, I will be incapable of not thinking about it every time I press "enter"... like now!
    – Cort Ammon
    Commented Mar 19, 2020 at 19:39
  • 6
    I'm surprised, given the Retrocomputing readership, that no-one pulled you up on your pressing Enter rather than pressing Return. (-:
    – JdeBP
    Commented Mar 20, 2020 at 21:57
  • 6
    |<-- is a backwards tab Commented Mar 21, 2020 at 12:12
  • 15
    There used to be this thing known as a "typewriter". The carriage return lever on it would first scroll up the paper, then slide the carriage to the right, so that the left side of the paper was ready to receive more printing.
    – Hot Licks
    Commented Mar 21, 2020 at 22:59
  • 5
    While I can't tell you the history of why the decision was made, regardless of what order the CR and LF are sent or physically carried out I have always thought that the visual metaphor makes sense the way it is: enter/execute the command (downward flowchart direction) and then go back to the beginning of the line to wait for a new command. If the arrow went back to the beginning of the line before going down, then every time I press it some part of my subconscious would think that I'm deleting the command I just typed.
    – jez
    Commented Mar 22, 2020 at 0:33

3 Answers 3

42

Chromatix' answer already perfectly nails the technical background. Especially the reference to classic typewriter mechanics, predating any TTY or terminal, where the symbol used quite closely follows the hand movement when issuing a new line.

Historically it may be interesting to look at the development. The combined function as a single key was only introduced with electric typewriters - like the Friden Flexowriter with 'CAR RET'. Even as late as 1961, when the new IBM Selectric was introduced, keyboards didn't feature the symbol but had 'Return' written in text. The same was true for IBM's first dedicated terminal system, the 1050 (and that was the basis for the /360 console).

It wasn't until the 2741 in 1965 that the symbol found its way onto the key cap - and stayed there until today.

Noteworthy here is maybe that neither CR nor LF was used in its mainframe environment, but NEL - Next Line - which in turn wasn't considered part of an input line but part of the protocol.

While using CR/NL instead of NL/CR may support a speed-up due to the way that TTY/typewriter mechanics operate (*1), this sequence also adds freedom in further transmission optimisation. Many TTYs had the ability to combine CR and LF into a single function (often switchable), to reduce the number of characters to be transmitted/stored (*2). Doing so makes more sense on LF than on CR, as CR alone does have a useful application for overwriting a line - like adding an underline or some other overstrike, while LF always advanced to the next line, which doesn't make much sense without repositioning the carriage as well.

As a result, TTYs configured for automatic CR on LF would act the same, no matter whether only a LF or CR/LF was sent, being agnostic to either variant, but would still allow overwrite with CR alone.

This is the reason why UNIX and other TTY-based systems of that time use LF to mark a line end. They expect TTYs (as well as glass TTY) to be set to include an implied CR when LF was received. Here it was less of a speed concern, but simplification of text handling as now (like with NEL) a single character symbolized line end, while still keeping compatibility with (TTY) output equipment, e.g. when dumping a file.


Side note about symbol usage: During the 1930s European TTY manufacturers replaced country specific labels, like German WR/ZL for CR/LF, with symbols. Using < for CR and (Triple Bar) for LF.


*1 - Being processed by independent hardware, thus able to act in parallel.

*2 - Depending on the device at the cost of inserting additional space.

18
  • 1
    Re, "simplyfication of text handling" The point wasn't just to make it simpler. The point was, to decouple the encoding of text in a file or, the text stream output by a program, from the requirements of any particular output device. Also note: It could be that the output device itself was configured to correctly interpret the LF character, or (more often than not, is my guess) the line discipline (a.k.a., "line driver") would convert the NL to an appropriate sequence of control characters and/or time delays. Commented Mar 19, 2020 at 11:42
  • 5
    @Raffzahn, Yes The problem (application programs needed to be aware of control codes and timing requirements for a specific teleprinter) existed before the solution (UNIX translates \n into whatever sequence of CR and LF and NULs will make the teleprinter happy) was invented. I personally remember writing application code for some non-UNIX minicomputer (or maybe a micro, not sure), and having to find out the right number of NUL characters to send to prevent the first character of the next line from being struck while the print head still was in-flight back to the home position. Commented Mar 19, 2020 at 13:47
  • 3
    @CaptainMan LOL. No, but that's a cool way for a fake explanation. Caret is Latin and means 'he/she is missing (something)' (third person singular of careo). When editing/correcting a text (back before computers) an upward chevron was used (below the line) to mark where something had to be inserted - which is why a text cursor nowadays is called a caret, as it's were text gets inserted (when typing). In French it also has the meaning of turtle. < for CR is simply a symbol showing that the carriage will be moved to the left. Symbols save the effort to make country specific keycaps.
    – Raffzahn
    Commented Mar 19, 2020 at 14:55
  • 2
    @Raffzahn Just for the sake of completion, the turtle sense of French caret is unrelated to the Latin verb – it’s a borrowing from Spanish carey, which in itself is a Taíno word (from the Caribbean). The final t in caret is purely orthographic; they could just as well have spelt it caré or carai(e) instead. Commented Mar 19, 2020 at 23:31
  • 2
    @JanusBahsJacquet Sure, I'm aware of that, still looking at the symbol, it seams related, a small turtle crawling along below a text line ... don't you think so? Not, when I comes to French spelling (English as well) , I do firmly belive it's a topic to be spared until human kind has reached lasting world peace and mastered FTL travel.
    – Raffzahn
    Commented Mar 19, 2020 at 23:39
61

Even though the CR usually goes before the LF in ASCII text, most printer mechanisms actually perform the LF before, or during, the CR. So the shape of the arrow is actually accurate.

This is even true of mechanical typewriters, in which the carriage is returned through a physical lever which, before enough force is transmitted through it to move the carriage, moves sufficiently to advance the page by one line. CR is sent first because it generally takes longer to perform the carriage movement than the line feed.

20
  • 23
    @CaptainMan Because the carriage return action usually takes takes longer than the line feed action, so you want it to start first even it's only by the fraction of a second it takes to transmit one character.
    – user722
    Commented Mar 19, 2020 at 14:32
  • 4
    @supercat : Many TTYs implicitly LFed on an explicit CR (duplicating typewriter behaviour). On those models, CR and CRLF were already equivalent. Commented Mar 19, 2020 at 17:03
  • 7
    @supercat Bolding via typing a line, issuing CR without LF, then retyping the line was a common operation on ttys, and the vestiges of it still appear sometimes in Unixy systems. Commented Mar 19, 2020 at 20:18
  • 8
    @supercat Bolding by typing a line, throwing the carriage return lever, rolling the paper back a line, and retyping the line was also a common operation on typewriters. ;) Commented Mar 19, 2020 at 23:55
  • 16
    @supercat Mechanical tolerances, while quite good, were just sloppy enough that the second pass would be shifted enough to give a really good bold -- much better than a harder physical strike. Check out uniqcode.com/typewriter Commented Mar 20, 2020 at 0:20
-3

Just a quick comment on UNIX and actual teletype printers like the Dec LA120. Whether or not the enter key sends CR or a CR/LF is completely dependent on what TERMCAP (Terminal Capabilities) profile you are using for the interface(tty). I have several files of ASCII art which were explicitly designed to be printed on 120 column form-feed paper where inline CR's were not followed by LF's so that the printer could over-type to make darker text in the resultant print.

The platen is not able to move the impact area up the sheet it just prints the line and (other than a full CR) to the left via VT character codes which is what an LA120 uses. When you were using an LA120 as your terminal interface pressing backspace actually printed a ^H and then the new character. It would not move the print head one space back because you wouldn't be able to clearly read the over-struck character.

These ASCII Art files were designed to be large images, multiple sheets wide in many cases. The largest complete one I have is a lunar scene which was made to be 5 sheets (around 5 feet) wide though most are only 2 wide.

Any place you see VTxxx or LAxxx in a terminal file, those terminals were all defined by DEC (Digital Equipment Corporation) including the color capable terminals.

3
  • 2
    I don't see how this addresses the question that was asked. You appear to be "begging the question" - if you want to answer a different question, the best way to do that is to ask the different question yourself. You obviously have useful information to impart, but doing so as an answer to a question asking something different isn't the right way to go about it. Commented Apr 20, 2022 at 19:51
  • 1
    Yeah the hazards of answering too late at night. I've decided to ask my own question about these files and will strip this down to something that will fit in a comment which is why I originally did the answer Commented Apr 21, 2022 at 0:17
  • Please add a link in a comment here when you do - I'm looking forward to that Q&A. Thanks! Commented Apr 21, 2022 at 6:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .