Difference between revisions of "234: Escape Artist"

Explain xkcd: It's 'cause you're dumb.
Jump to: navigation, search
(Created page with "{{comic | number = 234 | date = March 12, 2007 | title = Escape Artist | image = escape_artist.png | titletext = Easier to escape: n-layered nested quotes or a...")
 
(Added link to related comic)
(13 intermediate revisions by 8 users not shown)
Line 8: Line 8:
  
 
==Explanation==
 
==Explanation==
{{w|Harry Houdini}} was a famous escape artist, whose more famous routines included escaping straitjackets and switching places with an assistant while locked inside a box.
+
{{w|Harry Houdini}} (born Erik Weisz/Ehrich Weiss) was a famous escape artist, whose more famous routines included escaping straitjackets and switching places with an assistant while locked inside a box.
  
The word "escape" also has a meaning {{w|Escape character|in computer science}}. To "escape" something in programming means to input some "escape character" to force to the computer to use a different interpretation of the following character (i.e. letter, number, or symbol). The escape character in most interpreters or languages is the backslash (\), and it's usually used to suppress the special meaning of the following symbol. For example, in most programming languages, strings are specified in quotation marks (e.g. "this is a string"). In this case, if the programmer tried to put a quotation mark inside the string, the compiler would interpret it as the end of the string, and probably end up having an error when it sees the rest of the string. Because of this, most languages also specify that \" can be used to literally just be a quotation mark, which allows programmers to put actual quotation mark characters into strings.
+
The word "escape" also has a meaning {{w|Escape character|in computer science}}. To "escape" something in programming means to replace a character or character sequence which would usually have a special meaning with another character sequence that doesn't have this special meaning. One common way of escaping is to have a special escape character which removes the special meaning from whatever character follows it. For instance, many programming languages enclose text strings in quotation marks (e.g. "this is a string"). If you tried to directly put a quotation mark inside the string, the compiler would interpret it as the end of the string. To avoid this, the quotation mark is ''escaped'' with a backslash: "He said, \"Goodbye!\", and went away."
  
 
The problem [[Cueball]] is having is related to the fact that {{w|Bash (Unix shell)|the Bash shell}} interprets spaces as a special syntactic marker, when he actually just wants the spaces to be literal space characters. In this case, escaping the spaces with \ would force Bash to interpret his script in this way.
 
The problem [[Cueball]] is having is related to the fact that {{w|Bash (Unix shell)|the Bash shell}} interprets spaces as a special syntactic marker, when he actually just wants the spaces to be literal space characters. In this case, escaping the spaces with \ would force Bash to interpret his script in this way.
Line 18: Line 18:
 
The person talking to Cueball is having a separate conversation about Houdini as Cueball thinks aloud about his script issue, which results in diverging conversations. This eventually leads Cueball to suggest that Houdini might have "escaped" (freed himself from) handcuffs by "escaping" (removing the special meaning from) them with backslashes.
 
The person talking to Cueball is having a separate conversation about Houdini as Cueball thinks aloud about his script issue, which results in diverging conversations. This eventually leads Cueball to suggest that Houdini might have "escaped" (freed himself from) handcuffs by "escaping" (removing the special meaning from) them with backslashes.
  
Sometimes, escape characters need to be "nested" - the backslash character itself can be escaped as \\ to produce a literal backslash, so if, for example, one needs to produce a literal quotation mark to output to a script file, and that script file ''also'' needs to have the quotation mark escaped, one would need to type it out as \\\", which would be output as \". If I needed to actually output that \\\", one would need to type it as \\\\\\\". The number of backslashes needed grows exponentially, and can be very hard to keep track of. This behavior is a type of n-level nested quotation mentioned in the title text.
+
Sometimes, escape characters need to be "nested" - the backslash character itself can be escaped as \\ to produce a literal backslash, so if, for example, one needs to produce a literal quotation mark to output to a script file, and that script file ''also'' needs to have the quotation mark escaped, one would need to type it out as \\\", which would be output as \". If I needed to actually output that \\\", one would need to type it as \\\\\\\". The number of backslashes needed grows, and can be very hard to keep track of (see [[1638: Backslashes]]). This behavior is a type of n-level nested quotation mentioned in the title text.
  
An {{w|iron maiden (torture device)|iron maiden}} is supposedly a medieval torture device, currently believed to have been invented for tourism purposes much later than the time period when it was in use.
+
An {{w|iron maiden (torture device)|iron maiden}} is supposedly a medieval torture device, currently believed to have been invented for tourism purposes much later than the time period when it was said to have been used.
 +
Harry Houdini's escapes include an escape from a purported "iron maiden," although it only vaguely resembles the "medieval" torture device.
  
 
==Transcript==
 
==Transcript==
Line 27: Line 28:
 
:Cueball: Why does my script keep dying?
 
:Cueball: Why does my script keep dying?
  
:[Closeup on Cueball sitting at the computer]
+
:[Closeup on Cueball sitting at the computer.]
 
:Man: And a lock invites you to try and open it. It's the hacker instinct. Only your ignorance stands in the way.
 
:Man: And a lock invites you to try and open it. It's the hacker instinct. Only your ignorance stands in the way.
 
:Cueball: Wait it's passing bad strings.
 
:Cueball: Wait it's passing bad strings.
  
:[Returns to the two shot of both men]
+
:[Returns to the two shot of both men.]
:Man: I admired Harry Houdini, how he could open any lock and free himself from any restraint.  
+
:Man: I admired Harry Houdini, how he could open any lock and free himself from any restraint.
 
:Cueball: Ah - Bash is parsing the spaces.
 
:Cueball: Ah - Bash is parsing the spaces.
  
Line 38: Line 39:
 
:Cueball: Backslashes?
 
:Cueball: Backslashes?
 
:Man: Huh?
 
:Man: Huh?
:Cueball: Never mind.  
+
:Cueball: Never mind.
  
 
{{comic discussion}}
 
{{comic discussion}}
 
[[Category:Comics featuring Cueball]]
 
[[Category:Comics featuring Cueball]]
 
[[Category:Programming]]
 
[[Category:Programming]]
 +
[[Category:Computers]]
 +
[[Category:Multiple Cueballs]]
 +
[[Category:Puns]]

Revision as of 14:34, 3 February 2016

Escape Artist
Easier to escape: n-layered nested quotes or an iron maiden?
Title text: Easier to escape: n-layered nested quotes or an iron maiden?

Explanation

Harry Houdini (born Erik Weisz/Ehrich Weiss) was a famous escape artist, whose more famous routines included escaping straitjackets and switching places with an assistant while locked inside a box.

The word "escape" also has a meaning in computer science. To "escape" something in programming means to replace a character or character sequence which would usually have a special meaning with another character sequence that doesn't have this special meaning. One common way of escaping is to have a special escape character which removes the special meaning from whatever character follows it. For instance, many programming languages enclose text strings in quotation marks (e.g. "this is a string"). If you tried to directly put a quotation mark inside the string, the compiler would interpret it as the end of the string. To avoid this, the quotation mark is escaped with a backslash: "He said, \"Goodbye!\", and went away."

The problem Cueball is having is related to the fact that the Bash shell interprets spaces as a special syntactic marker, when he actually just wants the spaces to be literal space characters. In this case, escaping the spaces with \ would force Bash to interpret his script in this way.

(There is one other way the escape character is sometimes used, but we'll ignore it for the sake of explaining the comic.)

The person talking to Cueball is having a separate conversation about Houdini as Cueball thinks aloud about his script issue, which results in diverging conversations. This eventually leads Cueball to suggest that Houdini might have "escaped" (freed himself from) handcuffs by "escaping" (removing the special meaning from) them with backslashes.

Sometimes, escape characters need to be "nested" - the backslash character itself can be escaped as \\ to produce a literal backslash, so if, for example, one needs to produce a literal quotation mark to output to a script file, and that script file also needs to have the quotation mark escaped, one would need to type it out as \\\", which would be output as \". If I needed to actually output that \\\", one would need to type it as \\\\\\\". The number of backslashes needed grows, and can be very hard to keep track of (see 1638: Backslashes). This behavior is a type of n-level nested quotation mentioned in the title text.

An iron maiden is supposedly a medieval torture device, currently believed to have been invented for tourism purposes much later than the time period when it was said to have been used. Harry Houdini's escapes include an escape from a purported "iron maiden," although it only vaguely resembles the "medieval" torture device.

Transcript

[Cueball sits before a computer on a desk while another man stands behind him.]
Man: I was fascinated by locks as a kid. I loved how they turned information and patterns into physical strength.
Cueball: Why does my script keep dying?
[Closeup on Cueball sitting at the computer.]
Man: And a lock invites you to try and open it. It's the hacker instinct. Only your ignorance stands in the way.
Cueball: Wait it's passing bad strings.
[Returns to the two shot of both men.]
Man: I admired Harry Houdini, how he could open any lock and free himself from any restraint.
Cueball: Ah - Bash is parsing the spaces.
Man: Sure some of it was fakery and showmanship. But I still wonder how he so consistently escaped handcuffs.
Cueball: Backslashes?
Man: Huh?
Cueball: Never mind.


comment.png add a comment! ⋅ comment.png add a topic (use sparingly)! ⋅ Icons-mini-action refresh blue.gif refresh comments!

Discussion

So, I'm curious, what is the escape character's other use that wasn't discussed in the comic? Monolith (talk) 06:51, 22 September 2015 (UTC)

They are also used to add special characters or certain instructions. For example, in LaTeX (a document typesetting system) I could type "\Omega" and in the final document the Greek letter omega will be in its place. I could also type "\newline" and the final document will have a line break at that point. In either case the backslash lets the compiler know that what follows is not to be treated as ordinary text. 108.162.250.180 08:02, 22 September 2015 (UTC)

The word "backslash" can also be meaningful in real-life escapes (assuming the escapist has a knife). Mountain Hikes (talk) 02:25, 25 September 2015 (UTC)