56

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, |<--- ( or ) would have been better.)

  • 52
    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 Mar 19 at 19:39
  • 4
    I'm surprised, given the Retrocomputing readership, that no-one pulled you up on your pressing Enter rather than pressing Return. (-: – JdeBP Mar 20 at 21:57
  • 3
    |<-- is a backwards tab – Thomas Weller Mar 21 at 12:12
  • 7
    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 Mar 21 at 22:59
  • 2
    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 Mar 22 at 0:33
38

Chromatix answer already perfectly nails the technical background. Especially the reference to classic typewriter mechanics, predating any TTY or terminal, were the symbol used quite closely follows the hand movement when isueing 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 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 CR, as CR alone does have a useful application for overwriting a line - like adding underline or 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 if only a LF or CR/LF was sent, being agnostic to either variant, but 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 did symbolize line end, while still keeping compatibility with (TTY) output equipment, e.g. when dumping a file.


Side note about symbol usage: Already during the 1930s European TTY manufacturers replaced country specific label, like German WR/ZL for CR/LF, with symbols. Using < for CR and (Tripple 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.

| improve this answer | |
  • 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. – Solomon Slow Mar 19 at 11:42
  • 4
    @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. – Solomon Slow Mar 19 at 13:47
  • 2
    @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 Mar 19 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. – Janus Bahs Jacquet Mar 19 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 Mar 19 at 23:39
51

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.

| improve this answer | |
  • 21
    @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. – Ross Ridge Mar 19 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. – Eric Towers Mar 19 at 17:03
  • 6
    @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. – Russell Borogove Mar 19 at 20:18
  • 7
    @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. ;) – Russell Borogove Mar 19 at 23:55
  • 14
    @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 – Russell Borogove Mar 20 at 0:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.