8 ms·
Taken literally just CR seems very odd. You probably know this, but LF is "line feed" which advances the feed. CR is "carriage return" which puts the carridge
by eterm 9y ago
Taken literally just CR seems very odd.
You probably know this, but LF is "line feed" which advances the feed.
CR is "carriage return" which puts the carridge to the start of the line.
The combination makes sense because it does both, it returns the carriage and advances the line.
Just LF kind of makes sense because when you advance the line you can think of the line being empty.
But conceptually just CR suggests returning the carriage but that doesn't imply the newline.
Of course the terminology is originally from type-writers so it doesn't have to make sense, but it does seem odd that some systems chose just CR.
- chc 9y agoOn a typewriter from around the time of the first Macs, the return key normally moves back to the beginning and moves down a line, so that's probably why they picked it. They also called the key "return" rather than "enter."
- craftyguy 9y agoStrange that 'return' takes you to a new line, rather than returning you to the previous line. English!
- doughj3 9y ago(Nevermind)
- boomlinde 9y agoIt's a simple mechanical artefact. Carriage return moves the paper carriage all the way to the right (returning it to its initial position), while line feed will advance the paper vertically (feeding a line through the carriage). With that in mind, line feed and carriage return on their own make about as little sense. On later type writers both the line feed and carriage return were integrated into a single key or lever, which was just called carriage return or return. From this perspective, an encoding using a lone CR for newlines might make more sense than one using a lone LF. But neither combination really makes intuitive sense in buffered, electronic systems. It's just how it is.
- phkahler 9y agoOn a classic non-electric typewriter the carriage was returned by pushing a lever on the right side of the carriage. The lever could be pressed to the left relative to the carriage which would move the paper up. At the end of travel relative to the carriage if you kept pushing it would move the carriage back to the left. Hence CR and LF could be accomplished in one motion. If you wanted to advance the paper many lines, you'd push the lever multiple times - probably with the carriage all the way to the left the whole time. On another note, I find it incredibly weird describing an "everyday" item like a typewriter because many people on HN may have never used one!
- yread 9y agoBrings back memories of staring at a keyboard unsuccessfully looking for a "return" key to satisfy "Press return to continue..."
- k__ 9y agoSomehow the friends who told me how to use a PC always used "Return" instead of "Enter", but this was in Germany where we didn't have any text on this key, just a big arrow pointing down and left.
- pvg 9y agoIt's no more odd than just 'LF'. At the end of the day, something has to represent 'end of line'. The outlier here is really MS DOS, wasting a perfectly good byte on pretend-lineprinter codes.
- kevin_thibedeau 9y agoExcept that LF was also designated as NL before Apple came onto the scene. They were deliberately incompatible.
- pvg 9y agoIt was? By whom? What were they 'deliberately incompatible' with?
- mappu 9y agoUNIX, for one.
- tom_ 9y agoI wonder if this would have been a big concern for home computer vendors at the time. How many of them would have used Unix? Even if they had, would Unix even have been popular enough to really matter?
- pvg 9y agoNo.
- Lionsion 9y agoAt that time Apple chose CR, UNIX was just one of a multitude of minicomputer operating systems. Compatibility with it would have been only important in hindsight.
- carussell 9y agoYou're pulling things out of your ass. I'm interested in comments like yours. At some point between reading the previous comment and responding to it, you must have had some thought that goes, roughly, "Hey, I'm just going to make some shit up now and post it." Right? How else does it happen? Apple's is not the only ecosystem that settled on carriage return. Who do you think was around for them to deliberately break compatibility with in 1977? Kildall?
- jschwartzi 9y agoCR is a common line ending for RS-232 devices. I've got 3 or 4 in a cabinet for my current job which are "line-based" and which use CR as the line-ending. To issue a command to one of these devices, you terminate the command with CR and then the device processes it. These same devices will also send response data with CR line endings. This is partly why stty and termios have options for CRLF translation on terminals. I'm sure there's some historical reason for that.
- rusk 9y agoI thought it was to do with the fact that you might want to use them separately sometimes? For instance you might want to repeat a line without a newline for a "bold" effect, or with underscores for underlining.