Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is there an escape sequence for VERTICAL TAB?

Another question, What is a vertical tab?, describes what the vertical tab character was originally used for.

But why was U+000B VERTICAL TAB considered important enough to be allocated an escape sequence ('\v') in the first place, in C and many other programming languages?

See also: some guy complaining about this.

like image 631
Mechanical snail Avatar asked Sep 09 '11 21:09

Mechanical snail


People also ask

What is the escape sequence for the horizontal tab?

This is the escape sequence for the horizontal tab. Words that come after ‘ ’ will be pushed in the same line leaving some spaces. Its ASCII value is 009. This is the escape sequence for backspace.

How is the character ‘T’ interpreted as an escape sequence?

The compiler will interpret the character ‘t’ as an escape sequence because the character ‘t’ is preceded by a backslash (‘\’). Let’s take an example to understand the significance of the escape sequence in C.

What is an escape sequence in writing?

As the name denotes, the escape sequence denotes the scenario in which a character undergoes a change from its normal form and denotes something that is different than its usual meaning. Generally, an escape sequence begins with a backslash ‘’ followed by a character or characters.

What is the vertical tab (VT)?

The Vertical Tab (VT) is a control code, a command for printers. Many programming languages have an escape sequence to easily encode it within a string, just like they have escape sequences for characters such as Tab and Carriage Return. However, nowadays, even programmers often have no idea what a Vertical Tab is or why it is in there.


1 Answers

Correct Answer: TELETYPE

It has nada to do with delimiters. My parents worked with big data and a lot of broadcasters and Fortune 500s were still using punch cards up to the 80's. Remember that most languages were originally designed to be entered and used on a teletype machine, not a screen. The printer was not just for printing documents like it is today. There was no monitor at all. The print-out was the display.

With that in mind, vertical tabs were pretty useful. Even post-teletype my parents used them render forms faster by overwriting just the parts that changed. Because back then even text-only display was too slow!

Fun video: https://www.youtube.com/watch?v=qv5b1Xowxdk

But more to the point: Many, many, many things in modern operating systems are relics of the teletype machine... not just vertical tab. We're just so used to them that people don't even think about them anymore, but they're no less weird. I sure many don't realize where these conventions come from unless they've been coding since the 70's.

  • Do you text-wrap your code or e-mail at 80 columns?
    Because IBM punch cards were 80 characters wide.

  • Do you use graphics that support bottom up encoding, such as Windows bitmaps, or any graphics libraries with the origin in the lower corner?
    Because teletype machines scrolled from the bottom up.

  • Do you use \n to indicate a new line of text?
    Because \n stands for line feed, which comes from manual typewriters before it was used in teletypes.

  • Have you ever sent a message to a friend by writing to /dev/tty under Linux?
    Because TTY is short for teletype.

  • Have you ever told someone to use an existing library instead of reinventing the wheel? Have you ever used a library or framework yourself?
    Because that's how old code hangs around. Certainly, the benefits outweigh the harm, but libraries built on top of libraries built on top of libraries leads to this creeping dependency such that even when the original library is long since gone, everything that was ever compatible with it causes its conventions to live on... and on... and on...

These teletype conventions are so firmly entrenched into the operating system itself I fully expect this will always remain until someone writes an operating system from scratch, and even then I'm not so sure. There's no question why the C language picked them up. Remember, C came long after LISP, Forth, COBOL, FORTRAN, Pascal and even BASIC.

P.S. Using the bell character as a delimiter would have been an insane thing to do. Grind grind grind BEEP grind grind BEEEEEEP grind chuka chuka BEEP grind chuka grind grind BEEEP. Whizzzz clunk. Grind grind BEEP...

like image 62
lisa Avatar answered Oct 11 '22 23:10

lisa