Editing 1960: Code Golf
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 12: | Line 12: | ||
{{w|Code golf}} is the attempt to use as few characters as possible to write a computer program with a certain function, analogously to {{w|golf|regular golf's}} goal of getting the ball into the hole with as few strokes as possible. Reverse code golf would be to write a given program, probably to achieve a trivial outcome, using as many characters as possible. Randall's approach to this in the code example shown in the comic is to create overly long function names, using [https://en.wikisource.org/wiki/Moby-Dick_(1851)_US_edition/Chapter_1 the beginning lines] of {{w|Herman Melville}}'s notoriously long-winded whaling novel ''{{w|Moby-Dick}}''. Regular code golf also results in names of functions and variables that have nothing to do with their purpose in the program, but would minimise their length. | {{w|Code golf}} is the attempt to use as few characters as possible to write a computer program with a certain function, analogously to {{w|golf|regular golf's}} goal of getting the ball into the hole with as few strokes as possible. Reverse code golf would be to write a given program, probably to achieve a trivial outcome, using as many characters as possible. Randall's approach to this in the code example shown in the comic is to create overly long function names, using [https://en.wikisource.org/wiki/Moby-Dick_(1851)_US_edition/Chapter_1 the beginning lines] of {{w|Herman Melville}}'s notoriously long-winded whaling novel ''{{w|Moby-Dick}}''. Regular code golf also results in names of functions and variables that have nothing to do with their purpose in the program, but would minimise their length. | ||
− | Using "as many characters as possible" to produce code is | + | Using "as many characters as possible" to produce code is actually an impossible goal. It would be a trivial task to make any given program longer by inserting useless code or comments. Furthermore, some programming languages place no limit on function names, so these could simply be made longer. Even if the language Randall is using does limit function name length, he has not maximised the ones he has used, since the first two are 50 characters long, and the last much shorter. The code is written in a programming language that looks similar to {{w|Python (programming language)|Python}}, but with the keyword “define” instead of “def” to define functions. Python has no limit for function name length, and was previously featured in comic [[353: Python]]. |
The first two functions defined implement “zero” and “successor”, the two basic operations of {{w|Peano axioms|Peano arithmetic}}. Presumably, the programmer will next implement natural number addition, then integers, then whichever branches of mathematics the original problem needs, all from scratch. Generally, you would use built-in functions to perform mathematical operations, so it is redundant to implement them yourself from scratch. | The first two functions defined implement “zero” and “successor”, the two basic operations of {{w|Peano axioms|Peano arithmetic}}. Presumably, the programmer will next implement natural number addition, then integers, then whichever branches of mathematics the original problem needs, all from scratch. Generally, you would use built-in functions to perform mathematical operations, so it is redundant to implement them yourself from scratch. | ||
Line 46: | Line 46: | ||
**Finally in the very next comic he returned to his problems with [[Small Talk]] and social interactions in general in [[1961: Interaction]], something he last dealt with in three comics released for about two years ago, the last being [[1650: Baby]]. | **Finally in the very next comic he returned to his problems with [[Small Talk]] and social interactions in general in [[1961: Interaction]], something he last dealt with in three comics released for about two years ago, the last being [[1650: Baby]]. | ||
**This comic also refers to another recurring theme [[:Category:Programming|Programming]], but there has been no break from this as this was the third of those already in 2018. | **This comic also refers to another recurring theme [[:Category:Programming|Programming]], but there has been no break from this as this was the third of those already in 2018. | ||
− | |||
− | |||
− | |||
− | |||
{{comic discussion}} | {{comic discussion}} |