Hacker News new | past | comments | ask | show | jobs | submit login

Not just terminals: most printers until the mid-80's or so also cared about the distinction for the same reason. They started adding DIP switches allowing you change the default behavior and by the end of the 80's the need for CR+LF was pretty much a thing of the past.

While the original reason for this distinction probably did date back to teletypes, some practical use cases evolved out of the capability. IIRC, some word processors used the ability to provide an overstrike mode before bold was a thing most printers could do. ASCII art photos were also a thing both for printers that didn't support a graphics mode as well as providing a way of printing a larger 'image' on the paper faster while also using less (ribbon) ink.




The distinction goes back to typewriters.

The author mentions that the typewriters had a return lever that could also do a line feed.

What they missed is that:

* You could still freely move the carriage without advancing the paper if you wanted: there was a carriage release button;

* You could also advance paper manually at any time, while keeping the carriage at its current position;

* You could often adjust line spacing, including setting it to 0, which means that the big lever would only return the carriage, but not advance the paper.

In short, CR and LF were separate useful functions on a typewriter.

The backspace key was useful for the same reason; obviously, it wouldn't erase text - it would move the carriage just like the space bar would, but in opposite direction.

These were necessary for:

* Underlining text (by overtyping the underscore character over lines of text);

* Adding accents, or crossing zeros with overtyping;

* Bold text by retyping the same line;

Etc.

Tab stops in your favorite document editor come from the same era: the "Tab" key would release the carriage, and the spring would pull it forward until the next physical stop (whose positions you would manually set). The feature was made to make typing tabular data easier, hence the name.

That said, the author has a solid point about why we have CR and LF in that order.

To wit, on typewriters, the LF+CR lever would advance the paper first, because it made sense both mechanically and from the UX perspective (you would nudge it to advance paper by whatever line spacing you set, as opposed to manual advance which could be a fraction of that).

Returning the carriage, and then advancing paper indeed makes more sense on the terminal, where all operations but CR take a fixed amount of time.

That was the value of the article, really : to give motivation for CR+LF rather than LF+CR for line ending.

The former works well with the terminals, the latter - with typewriters.

Computers therefore use CR+LF.




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: