Editing 1306: Sigil Cycle

Jump to: navigation, search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 8: Line 8:
  
 
==Explanation==
 
==Explanation==
In {{w|computer programming}}, a variable is a way of storing information temporarily, for use later in the program. There are different types of variables, called {{w|Data type|data types}}, such as integers, strings, characters, and booleans, all of them holding different types of information. Integers hold whole numbers, strings hold text, and so on. Variables traditionally have names that identify their purpose, and a programmer should usually be able to infer from this variable name what type of variable it is. For example, if you want to store the name of the customer in a catalogue service, you might store the text in a string variable called "NameOfCustomer". Because it is fairly clear that names are made up of text, it is logical that this variable would be a string variable - if you didn't have any other information about it.
+
 
 +
In {{w|computer programming}}, a variable is a way of storing information temporarily, for use later in the program. There are different types of variables, called {{w|Data type|data types}}, such as integers, strings, characters, and booleans, all of them holding different types of information. Integers hold whole numbers, strings hold text, and so on. Variables traditionally have names that identify their purpose, and a programmer should usually be able to infer from this variable name what type of variable it is. For example, if you want to store the name of the customer in a catalogue service, you might store the text in a string variable called "NameOfCustomer". Because it is fairly clear that names are made up of text, it is logical that this variable would be a string variable - if you didn't have any other information about it.  
  
 
A {{w|Sigil (computer programming)|sigil}} in computer programming is a symbol that appears before the variable name. It is an alternative method of telling someone who is reading the program code what data type the variable is. Rather than relying on logic, then, to know that NameOfCustomer is a string, you might use a sigil "$" before the variable name, as in $NameOfCustomer, which would specify that the variable can hold text. Sigils can also specify the {{w|Scope (computer science)|scope}} of a variable, which refers to where the variable can be used in a program, and which parts of the program can access that variable. Sigils are useful in some ways because you don't have to refer to previous program code or find where the variable is declared (created) to know what data type it is. They also provide some level typing in languages that do not explicitly declare the type of the variable.
 
A {{w|Sigil (computer programming)|sigil}} in computer programming is a symbol that appears before the variable name. It is an alternative method of telling someone who is reading the program code what data type the variable is. Rather than relying on logic, then, to know that NameOfCustomer is a string, you might use a sigil "$" before the variable name, as in $NameOfCustomer, which would specify that the variable can hold text. Sigils can also specify the {{w|Scope (computer science)|scope}} of a variable, which refers to where the variable can be used in a program, and which parts of the program can access that variable. Sigils are useful in some ways because you don't have to refer to previous program code or find where the variable is declared (created) to know what data type it is. They also provide some level typing in languages that do not explicitly declare the type of the variable.
Line 15: Line 16:
  
 
;{{w|QBASIC}}
 
;{{w|QBASIC}}
:Variables of type string end with the $ symbol. Other symbols are used (% for integers, ! for single-precision, # for double-precision and, in some versions of BASIC, & for long integers), however the usual QBASIC program will use only the $ symbol and not any of the others, as the default type if no symbol is used is single-precision and that's OK for most numeric uses.
+
:Variables of type string end with the $ symbol. Other symbols are used (% for integers, ! for single-precision, # for double-precision and, in some versions of BASIC, & for long integers), however the usual QBASIC program will use only the $ symbol and not any of the others, as the default type if no symbol is used is double-precision and that's OK for most numeric uses.
  
 
;{{w|C++}}
 
;{{w|C++}}
Line 24: Line 25:
  
 
;{{w|Perl}}
 
;{{w|Perl}}
:In Perl, the initial character provides the context of the variable. Scalars (text, numeric and also to references to data) start with the $ character. An @ is for an array. With %, it is a hash (a loose non-sequential array, or 'dictionary' lookup). Functions ''can'' be given a preceding &, but rarely need this in straightforward use. You can use the variables $temp, @temp, %temp and &temp simultaneously and independently. There is also the * (not in a mathematical sense) which identifies a 'glob', a way to fuse or use all those types (and more!) in 'interesting' ways if you have a yen to.
+
:In Perl, variables of simple types, and references to items in arrays and hashes, start with $. Arrays start with @. Hashes start with %.
:A block, with {} surrounding some other suitable statement(s), can potentially be typed to (re)interpret the context within. If you have a $reference which currently points to an @array, @{$reference} will let you use it as a direct array. But in simple cases, like that, this can often be shortened to @$reference, as alluded to by the "@$PERL" of the comic. (Just as $$reference would be a valid way to dereference the $reference when it points to $scalar... or even to $anotherReference that itself points to a %hash, in which case you could even use %$$reference for 'direct' access to that. Perl can be complicated, if you let it!)
 
  
 
;{{w|Python (programming language)|Python}}
 
;{{w|Python (programming language)|Python}}
Line 31: Line 31:
  
 
;{{w|Google}}
 
;{{w|Google}}
:Once upon a time, Google added a social network called "[[918|Google+]]" (pronounced "Google plus") to its many offerings. On this network, accounts were identified and "mentioned" (linked in a message, and sent a notification) with a + prefix. For example, [[Randall]] was "+Randall Munroe". Google+ has been defunct since 2019, but it was active and growing in 2013 when this comic was posted.
+
:In the beginning, Google was only a search engine. However, it now includes many things, in particular a social network called Google+ (pronounced "google plus"). Google+ accounts are referenced with a + prefix.
  
 
;{{w|Twitter}}
 
;{{w|Twitter}}
Line 37: Line 37:
  
 
;{{w|Hashtag}}s
 
;{{w|Hashtag}}s
:In 2007 Twitter users began a convention that a # sign (whose {{w|Number sign|many names}} include the "hash") can be prepended to words to mark them as keywords. Twitter could then be searched for those words. In 2009 Twitter recognized the existence of hashtags and began hyperlinking them. Some other microblogging services followed suit.  Google+ eventually added hashtag support as did Facebook.
+
:In 2007 Twitter users began a convention that a # sign (whose {{w|Number sign|many names}} include the "hash") can be prepended to words to mark them as keywords. Twitter could then be searched for those words. In 2009 Twitter recognized the existence of hashtags and began hyperlinking them. Some other microblogging services followed suit.  Google+ eventually added hashtag support as did Facebook.
  
As is noted by the comic, the use of sigils to indicate types of variables varies between programming languages, from strict enforcement in languages like Perl, to their complete absence in languages like C++ (but see {{w|Hungarian Notation}}). The comic notes that the use of sigils seems to be cyclic, especially if you count things like hashtags as extensions of the pattern.
+
As is noted by the comic, the use of sigils to indicate types of variables varies between programming languages, from strict enforcement in languages like Perl, to their complete absence in languages like C++ (but see {{w|Hungarian Notation}}). The comic notes that the use of sigils seems to be cyclic, especially if you count things like hashtags as extensions of the pattern.
  
The title text describes the two competing influences responsible for the cycle: The first impulse finds sigils useful to elucidate the type of the variable, especially when variable names are not very descriptive, while the latter impulse notes that descriptive variable names are much more useful for that purpose, especially in extensible languages where the built-in types form only a small part of the type system.
+
The title text describes the two competing influences responsible for the cycle: The first impulse finds sigils useful to elucidate the type of the variable, especially when variable names are not very descriptive, while the latter impulse notes that descriptive variable names are much more useful for that purpose, especially in extensible languages where the built-in types form only a small part of the type system.
  
 
==Transcript==
 
==Transcript==
Line 50: Line 50:
  
 
{{comic discussion}}
 
{{comic discussion}}
 
+
[[Category:Charts]]
[[Category:Line graphs]]
 
 
[[Category:Computers]]
 
[[Category:Computers]]
 +
[[Category:Compromise]]
 
[[Category:Internet]]
 
[[Category:Internet]]
 
[[Category:Programming]]
 
[[Category:Programming]]
 
[[Category:Social networking]]
 
[[Category:Social networking]]
[[Category:Google Plus]]
 

Please note that all contributions to explain xkcd may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see explain xkcd:Copyrights for details). Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following CAPTCHA:

Cancel | Editing help (opens in new window)