Difference between revisions of "1513: Code Quality"

Explain xkcd: It's 'cause you're dumb.
Jump to: navigation, search
(Explanation)
m (Explanation)
(39 intermediate revisions by 31 users not shown)
Line 8: Line 8:
  
 
==Explanation==
 
==Explanation==
[[Ponytail]] is about to look at some {{w|source code}} [[Cueball]] has written, and he is warning her that he is self-taught so his code probably won't be written the way she is used to. 
+
This comic is the first in the [[:Category:Code Quality|Code Quality]] series:
 +
* [[1513: Code Quality]]
 +
* [[1695: Code Quality 2]]
 +
* [[1833: Code Quality 3]]
 +
* [[1926: Bad Code]]
 +
* [[2138: Wanna See the Code?]]
  
In spite of Ponytail's initial (polite) optimism, she comments in three increasingly harsh similes. First, she suggests that reading his code is like being in a house built by a child, using a small axe to put together what he thought was a house based on a picture.  This relates to a technique especially common for new programmers.  They follow and adapt tutorials, and find examples of similar problems being solved, copy the solution ("cutting" it out as with an axe), {{w|Jury_rig|jury-rig}} it together, and tinker with it until it seems to work.  This can lead to code that is hard to follow or otherwise "messy" and inconsistent. Once a piece of code is working, inexperienced or deadline-driven coders are reluctant to go back and rewrite it to be cleaner or clearer, for fear of breaking something that has been working.  More experienced coders will go back after the first time the code worked and try to improve the code if they think it is possible. This improvement practice is known as {{w|refactoring}} and code projects that incorporate cycles of refactoring tend to be easier to read and maintain than those that don't.  Including good test cases reduces the risks.
+
It is about the apprehension of asking for help from an expert who is a friend. Often we fear that we will be judged and they will think less of us, which is what occurs in this comic.
  
Second, she suggests that it looks like a salad recipe, written by a corporate lawyer on a phone with autocorrect that only corrected things to formulas from Microsoft Excel.  This presumably relates to the way many programmers use {{w|integrated development environment}}s (IDEs).  They serve as syntax-checkers and often also help correct other programming errors, but their corrections and advice can be unnatural and difficult to understand (like corporate lawyers producing Excel formulas).  The result of just fixing what the IDE complains about often results in less-than-elegant code.
+
[[Ponytail]] is about to look at some {{w|source code}} [[Cueball]] has written, and he is warning her that he is self-taught so his code probably won't be written the way she is used to. In spite of Ponytail's initial (polite) optimism, she comments in three increasingly harsh similes (and a fourth in the title text).
  
Third, she describes it as a transcript of the dialog of couple arguing at {{w|IKEA}}, which was then randomly edited until the computer compiled it with no errors.  IKEA is an international chain of furniture stores which feature large, maze-like showrooms as well as a large warehouse area where you can pick up the furniture you want to buy in flat, some-assembly-required packaging.  Especially on weekends when many people crowd in to a store, they can be stress-inducing places. So coming across arguing couples in IKEA is to be expected.  Compiling refers to taking human readable source code and translating it into machine executable code; this is done by software that expects the input (the human readable part) to be in a certain format -- if the input is somehow not quite correctly formatted, the program will fail to compile the code, and will indicate that the input could not be compiled. Often, this is some simple little failure, like you forgot to put a semicolon at the end of a line of otherwise perfectly correct code. Putting in the semicolon in the correct place will allow the code to compile. Sometimes, it is not immediately clear what little violation of the language's syntax has been violated, and you will try two or three things, hoping to get the code to compile: maybe I need to capitalize this function name, and maybe I need to put this part in parenthesis, and maybe I need a semicolon at the end of this line. You do those things, and suddenly the code compiles, but you don't know exactly why. This reinforces behavior where you tend to just randomly edit your code until it compiles. An extreme of this would be to randomly edit some random starting input that isn't even really code, and just add and subtract stuff until by pure chance it happens to fulfill all the requirement of syntax that will allow it to compile. (This is very similar to an infinite amount of monkeys bashing away on typewriters for an infinite amount of time eventually producing the complete works of Shakespeare.)
+
First, she suggests that reading his code is like being in a house built by a child, using a hatchet (a small ax) to put together what he thought was a house based on a picture. She is saying that the code shows a lack of command of the language being programmed. This is like the common expression "If all you have is a hammer, everything looks like a nail."  New programmers make use of the same techniques repeatedly, using them for situations that they are not intended for.
  
Finally, Cueball makes the rather weak assurance that he will read “a style guide”.
+
Second, she suggests that it looks like a salad recipe, written by a corporate lawyer on a phone with auto-correct that only corrected things to formulas from Microsoft Excel. She is saying that the code is verbose and the corrections that were done are illogical. This presumably relates to the developer not being an expert in their craft, and fixing the problems as they come up instead of reexamining the problem and solving it in a better way.
Although few programming languages require a perfectly rigid style, so long as the code is syntactically accurate, most programmers follow some sort of {{w|Programming_style|style}} to make the code easier to read. This includes indenting lines to show levels and using descriptive variable identifiers with special capitalization, (e.g., {{w|CamelCase|CamelCase}} (aka camelCase, capitalizing each word except for the first in a sentence)), {{w|Snake case|snake_case}} (separating lowercase words with underscores).
 
  
It seems clear from Ponytail's commentary that his {{w|Software quality|code quality}} would benefit from far more training in computer programming.
+
Third, she describes it as a transcript of a couple arguing at a branch of the Swedish retail chain {{w|IKEA}}, which was then randomly edited until the computer compiled it with no errors. She is saying that the intent of the code is unclear due to the seemingly random use of the language. This is very similar to an infinite amount of monkeys bashing away on typewriters for an infinite amount of time eventually producing the complete works of Shakespeare. (A couple's argument may be even less coherent at IKEA than at the average store, since IKEA products always have idiosyncratic names and many of them are difficult to pronounce or transcribe for anyone who doesn't speak Swedish.) This might happen if the code was written so bad that it does not compile, and people edited the code until it compiles so they can see what the code accomplishes. That Cueball's code is in this bad a shape indicates he really hasn't learned the programming language; he just happens to have a program that works in some shape or fashion.  
  
The title text refers to {{w|emoji}}, originally called "{{w|Smiley|smiley faces}}". Ponytail's comment implies that some of Cueball's variables contained emoji, perhaps in an effort to capture the emotional content of the arguments which show through the requirements document. Many crying-face emoji are possible if variables can include full Unicode (e.g., 😢,😭,😂,😪,😥,😰,😿,😹). In some programming languages it would be impossible to use them in variable names, as the symbols would break the language's syntax rules. Exceptions to this include {{w|Go (programming language)|Go}}, {{w|Swift (programming language)|Swift}}, {{w|Java (programming language)|Java}} ([http://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html#jls-3.8], [http://docs.oracle.com/javase/7/docs/api/java/lang/Character.html#isUnicodeIdentifierPart%28int%29]), but most languages with compilers that support Unicode characters can include this kind of emoji, even for languages that predate Unicode like {{w|C++}} and {{w|Lisp_(programming_language)|Lisp}}.
+
Finally, Cueball makes the rather weak assurance that he will read "a style guide", which articulates the intended use of the language. It seems clear from Ponytail's commentary that his {{w|Software quality|code quality}} would benefit from far more training in computer programming.
 +
 
 +
The title text refers to {{w|emoji}}. Ponytail's comment implies that some of Cueball's variables contained emoji, perhaps in an effort to capture the emotional content of the arguments which show through the requirements document. Emoji has become a [[:Category:Emoji|recurrent theme]] on xkcd, but this may have been the first comic to use them for a pun.
 +
 
 +
===Emoji===
 +
Many crying-face emoji are possible if variables can include full Unicode (e.g., 😢,😭,😂,😿,😹), as well as faces with sweat drops that are often mistaken for tears (😪,😥,😰). In some programming languages it would be impossible to use them in variable names, as the symbols would break the language's syntax rules. Exceptions to this include {{w|Swift (programming language)|Swift}} and {{w|Perl|Perl}} ([http://perldoc.perl.org/5.24.0/perlunicode.html]), but most languages with compilers that support Unicode characters can include this kind of emoji, even for languages that predate Unicode like {{w|C++}} and {{w|Lisp_(programming_language)|Lisp}}.
 +
 
 +
In any event, Cueball's code may best be represented by a bunch of people crying, as that is the only proper response to it.
 +
 
 +
===Programming Style===
 +
Although few programming languages require a perfectly rigid style, so long as the code is syntactically accurate, most programmers follow some sort of {{w|Programming style|style}} to make the code easier to read. This includes indenting lines to show levels and using descriptive variable identifiers with special capitalization, (e.g., {{w|camelCase}}, capitalizing each word except for the first in a sentence, or {{w|snake_case}}, separating lowercase words with underscores).
  
 
==Transcript==
 
==Transcript==
Line 39: Line 53:
  
 
==Trivia==
 
==Trivia==
*Emoji can be simulated using {{w|ASCII}} characters, and have roots in ASCII {{w|emoticon}}s. Most languages will allow variable names to include underscores, so some sad face ASCII emoticon will be legal variable names, such as <code>T_T</code>, <code>p_q</code>, <code>ioi</code> etc., but such things rarely show up in software variables. Many more can be made possible using [http://hexascii.com/sad-emoticons/ UTF-8 characters].
+
*Emoji can be simulated using {{w|ASCII}} characters, but their roots are mostly separate from ASCII {{w|emoticon}}s. Most languages will allow variable names to include underscores, so some sad face ASCII emoticon will be legal variable names, such as <code>T_T</code>, <code>p_q</code>, <code>ioi</code> etc., but such things rarely show up in software variables. Many more can be made possible using [http://hexascii.com/sad-emoticons/ UTF-8 characters].
  
 
{{comic discussion}}
 
{{comic discussion}}
<!-- Include any categories below this line. -->
 
  
 +
[[Category:Code Quality]]
 +
[[Category:Comics sharing name|Code Quality 01]]
 
[[Category:Comics featuring Cueball]]
 
[[Category:Comics featuring Cueball]]
 
[[Category:Comics featuring Ponytail]]
 
[[Category:Comics featuring Ponytail]]
 
[[Category:Programming]]
 
[[Category:Programming]]
 +
[[Category:Computers]]
 +
[[Category:Language]]
 +
[[Category:Emoji]]
 +
[[Category:Cueball Computer Problems]]

Revision as of 03:30, 31 August 2019

Code Quality
I honestly didn't think you could even USE emoji in variable names. Or that there were so many different crying ones.
Title text: I honestly didn't think you could even USE emoji in variable names. Or that there were so many different crying ones.

Explanation

This comic is the first in the Code Quality series:

It is about the apprehension of asking for help from an expert who is a friend. Often we fear that we will be judged and they will think less of us, which is what occurs in this comic.

Ponytail is about to look at some source code Cueball has written, and he is warning her that he is self-taught so his code probably won't be written the way she is used to. In spite of Ponytail's initial (polite) optimism, she comments in three increasingly harsh similes (and a fourth in the title text).

First, she suggests that reading his code is like being in a house built by a child, using a hatchet (a small ax) to put together what he thought was a house based on a picture. She is saying that the code shows a lack of command of the language being programmed. This is like the common expression "If all you have is a hammer, everything looks like a nail." New programmers make use of the same techniques repeatedly, using them for situations that they are not intended for.

Second, she suggests that it looks like a salad recipe, written by a corporate lawyer on a phone with auto-correct that only corrected things to formulas from Microsoft Excel. She is saying that the code is verbose and the corrections that were done are illogical. This presumably relates to the developer not being an expert in their craft, and fixing the problems as they come up instead of reexamining the problem and solving it in a better way.

Third, she describes it as a transcript of a couple arguing at a branch of the Swedish retail chain IKEA, which was then randomly edited until the computer compiled it with no errors. She is saying that the intent of the code is unclear due to the seemingly random use of the language. This is very similar to an infinite amount of monkeys bashing away on typewriters for an infinite amount of time eventually producing the complete works of Shakespeare. (A couple's argument may be even less coherent at IKEA than at the average store, since IKEA products always have idiosyncratic names and many of them are difficult to pronounce or transcribe for anyone who doesn't speak Swedish.) This might happen if the code was written so bad that it does not compile, and people edited the code until it compiles so they can see what the code accomplishes. That Cueball's code is in this bad a shape indicates he really hasn't learned the programming language; he just happens to have a program that works in some shape or fashion.

Finally, Cueball makes the rather weak assurance that he will read "a style guide", which articulates the intended use of the language. It seems clear from Ponytail's commentary that his code quality would benefit from far more training in computer programming.

The title text refers to emoji. Ponytail's comment implies that some of Cueball's variables contained emoji, perhaps in an effort to capture the emotional content of the arguments which show through the requirements document. Emoji has become a recurrent theme on xkcd, but this may have been the first comic to use them for a pun.

Emoji

Many crying-face emoji are possible if variables can include full Unicode (e.g., 😢,😭,😂,😿,😹), as well as faces with sweat drops that are often mistaken for tears (😪,😥,😰). In some programming languages it would be impossible to use them in variable names, as the symbols would break the language's syntax rules. Exceptions to this include Swift and Perl ([1]), but most languages with compilers that support Unicode characters can include this kind of emoji, even for languages that predate Unicode like C++ and Lisp.

In any event, Cueball's code may best be represented by a bunch of people crying, as that is the only proper response to it.

Programming Style

Although few programming languages require a perfectly rigid style, so long as the code is syntactically accurate, most programmers follow some sort of style to make the code easier to read. This includes indenting lines to show levels and using descriptive variable identifiers with special capitalization, (e.g., camelCase, capitalizing each word except for the first in a sentence, or snake_case, separating lowercase words with underscores).

Transcript

[Cueball showing Ponytail his laptop.]
Cueball: Keep in mind that I'm self-taught, so my code may be a little messy.
Ponytail: Lemme see - I'm sure it's fine.
[Ponytail sits at desk, Cueball stand behind her.]
Ponytail: ...Wow. This is like being in a house built by a child using nothing but a hatchet and a picture of a house.
[Ponytail sits at desk, Cueball stand behind her.]
Ponytail: It's like a salad recipe written by a corporate lawyer using a phone autocorrect that only knew Excel formulas.
[Ponytail sits at desk, Cueball stand behind her.]
Ponytail: It's like someone took a transcript of a couple arguing at IKEA and made random edits until it compiled without errors.
Cueball: Okay, I'll read a style guide.

Trivia

  • Emoji can be simulated using ASCII characters, but their roots are mostly separate from ASCII emoticons. Most languages will allow variable names to include underscores, so some sad face ASCII emoticon will be legal variable names, such as T_T, p_q, ioi etc., but such things rarely show up in software variables. Many more can be made possible using UTF-8 characters.


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

Discussion

On the bright side, I now have a new array of phrases to keep me sane while doing code reviews... 108.162.249.162 05:47, 17 April 2015 (UTC)

I think the emojis were referring to swift where you can use emojis as variables. 108.162.250.168 (talk) 05:53, 17 April 2015‎ (please sign your comments with ~~~~)

Could we get a link for the Apple language? 108.162.249.162 06:09, 17 April 2015 (UTC)

This is going on our OneNote at work. It totally made my day Jdluk (talk) 08:06, 17 April 2015 (UTC)

Yet another reason I'm glad I'm not a coder anymore (went back to hardware design . . . with NO style guidelines ;^) 173.245.56.182 (talk) (please sign your comments with ~~~~)

The description reads as if camelCase is part of every style. There are styles containing camelCase, but not all of them do. Also, different styles contain different rules, so following one specific style guide will be in conflict with others, therefore it's not necessary good idea: unless you program in team which agreed upon which style to use, it may be better if you don't worry to much to follow style exactly. On the other hand, if Ponytail's similes are accurate, Cueball is likely to discover lot of basic rules which will make the program easier to read even for him.

For example, there are lot of styles for Indenting alone, but most readability comes from the basic idea to indent code according to block it belongs to. -- Hkmaly (talk) 12:02, 17 April 2015 (UTC)

Out of curiosity I tried using 😭 as a variable name in Common Lisp. It works in SBCL, but fails in CLISP. 108.162.221.112 12:19, 17 April 2015 (UTC)

I really wish I knew anything about coding so I could contribute, but my 8th grade HTML class didn't help me that much. The Goyim speaks (talk) 12:50, 17 April 2015 (UTC)

The cruel person might point out that HTML isn't even 'coding'. (It's markup, for the most part, unless you're dabbling in DHTML or some of the latest bastardisations that have crept into HTML5.) But you will of course know the bit where you get "Hang on, why is that table element on the wrong line/off the end of the line/short of the end/outside the table, even?" and how it makes it easier to use a new-line and indentation scheme at appropriate places (and a logical policy of which lines not to split) so that errors like unaccounted-for COLSPANs and bad tag-pairing can be tracked down easily.
So it is with code. Liken it to obfuscation of HTML formatting (including using non-sensical, albeit consistent in themselves, id and name tags for the CSS to hang off of) can be employed deliberately (to prevent easy human readability/backformation) or incidentally (because it's created by a server-side/CMS generating script that hasn't been told to try to add useful whitespace). Moreso when it comes to <script> insertions (often deliberately obfuscated to single-letter variables, minimal whitespace and no line-feeds, perhaps in an misplaced attempt to enact 'security through obscurity', but of course that then is code. Arguably.
One of the aims could be to reduce the size of the 'code' (even when that's Markup), which is laudible given how much over-padded stuff you can get (I don't know if Microsoft Word's "Save as HTML"/whatever is currently as bad as it was in the early days, but even a web-page with just "Hello World" was chockablock full of formatting information that it never even bothered to ask if were necessary), but unless you absolutely do not need (or do not want!) people to read the code, both people and auto-generation scripts should attempt to impart visual elegance. IMO! 141.101.98.192 16:52, 17 April 2015 (UTC)

Does the second paragraph of the explanation, beginning "A common technique," add anything to explain the comic? I don't see it, but then I am from the era of COBOL. Miamiclay (talk) 19:54, 18 April 2015 (UTC)

I would propose a rewrite to something along the lines of "A common pattern in self-taught programmers...". As for the need of the paragraph, I feel it helps to explain where some programmers with bad (or a total lack of) employed standards come from. It's the kind of programmers that are used to copy and paste code examples and edit them until it does what they want, unknowingly introducing a horrible level of disparity to the code as well as disregarding any sensible coding standards and design patterns. I can speak from experience that such behavior exists, but that most such people either drop programming quickly or learn to adapt proper standards over time. I'm glad to say I'm in the latter group. — Erim Secla 141.101.79.67 08:02, 19 April 2015 (UTC)

How do we know that Agile and SaaS are relevant to this? 173.245.50.84 17:38, 19 April 2015 (UTC)

It has no relation, and futhermore whoever added software-as-a-service probably think it means something else than what it does Spongebog (talk) 19:30, 19 April 2015 (UTC)
It may even have been spam or a self promotion link. Spongebog (talk) 19:32, 19 April 2015 (UTC)
Emoji

IMHO the discussion on emoji is a bit off. Emoji are specifically the graphical representations (😢), not text-based smileys (T_T). And the sentences about language support use double negatives which is very confusing, and should probably mention that Javascript doesn't appear to allow it. (In my testing anyway.) Stevage (talk) 14:17, 20 April 2015 (UTC)

I agree. Emoticons and Emoji are two different things.--17jiangz1 (talk) 14:56, 20 April 2015 (UTC)
Can we distinguish between graphical emoji and character-based unicode emoji? The difference being that one is swapped in to normal text via some form of markup code (client-side or server-side, either when it thinks it has an explicit emoticon/etc string like ":)" or encounters a coded statement like ":lol:") while the other one is there already with no extra image bytes necessary. Except for perhaps font-file downloading, of course.
I assume the above (😢) is the latter, although that's an unrenderable character for me, as with most examples given on this page, and I assume I need some fancy new font installed to see it on any of the browsers I've tried it with. However, I do have ☺ and ☻ available to me. So I can at least emote in the manner of Dwarf Fortress (which, ironically, uses images of the original characters). 141.101.99.69 17:51, 21 April 2015 (UTC)

Ew non-Emoji code. This is the 21st century, get updated: https://github.com/emj-lang Natural languages ftw! No more this_is_a_variable_that_contains_the_number_of_xkcds_ever_posted! 108.162.210.246 21:18, 5 June 2015 (UTC)

On a tangential note, I once tried to install a decompiler into IntelliJ by copying and pasting a folder (not realizing it was the same decompiler IntelliJ already shipped with) and run it on Minecraft. It named all the variables and functions ☃. Promethean (talk) 22:28, 17 June 2015 (UTC)

Added info on code quality 3 141.101.104.215 03:43, 7 May 2017 (UTC)

I think that this series has to do with 1790: Sad. 108.162.221.70 (talk) (please sign your comments with ~~~~)

hexascii.com is dead ( maybe from plagiarism complain by Get Kaomoji https://getkaomoji.com/best-of-japanese-emoticons/ ) 162.158.179.40 (talk) (please sign your comments with ~~~~)

seems a bit like chatgpt sometimes 172.70.162.171