3
\$\begingroup\$

From the Help Center:

Do I want the code to be good code? (i.e. not code-golfing, obfuscation, or similar)

To me, this part of the check list reads as "Do I want the code to be good code (as opposed to do I want the code to be well-golfed or well-obfuscated)?" I interpret this part of the checklist as a question about what kind of answers the asker intends to get out of the question.

If my interpretation is correct, then presumably, a question with code-golfed or obfuscated code as the to-be-reviewed code could be on topic as long as the asker's intent is to turn it into something significantly more readable (we regularly get well-on-topic questions about improving readability).

Would a question in the form of "Help me un-golf this golfed code." be on-topic for Code Review?

\$\endgroup\$
  • \$\begingroup\$ So, the OP golfed his/her own code, then wants help un-golfing it? \$\endgroup\$ – 200_success Mar 25 '15 at 21:25
  • \$\begingroup\$ 1) Write pseudo-code for some particular something. 2) Because you're doing it for a code-golf contest, your original implementation is code-golf. 3) Later, you decide that this particular something that your golfed code does would actually be useful in your other very real project, but you don't want to commit code-golf to that project... so you come to CR to ask for help turning your original golfed implementation into actual commit-able code. \$\endgroup\$ – nhgrif Mar 25 '15 at 23:34
8
\$\begingroup\$

No, I do not believe this would be a valid question for Code Review. Properly golfed code is nearly impossible for anyone but the golfer to understand what the code does, and from my attempts to ungolf some of my own golfs later, it is honestly easier to just write a new version. I believe golfed code is so different from good code (especially code golfed good) that asking for an ungolfed version is the same as asking for us to write code for them, whether they understand what is happening or not.

\$\endgroup\$
  • \$\begingroup\$ I've seen ungolfed code which is almost impossible to decipher, yet wouldn't be off-topic for CR if it were accompanied by a plain-English description of the code. \$\endgroup\$ – nhgrif Mar 25 '15 at 22:11
  • \$\begingroup\$ Me too, but the intent wasn't to golf/obfuscate it. \$\endgroup\$ – Hosch250 Mar 25 '15 at 23:15
  • \$\begingroup\$ Why does the original intent of the code matter? \$\endgroup\$ – nhgrif Mar 25 '15 at 23:26
  • \$\begingroup\$ Moreover, your answer presumes that reviewers wouldn't be able to determine what the code was doing. If the reviewers cannot determine what the code is doing, then, just like any question that didn't involve code-golfing or obfuscating, the question could be closed as unclear what you're asking. We can't argue that these types of questions are automatically off-topic based on the assumption that they'd violate something else which would make them on-topic. Assuming everything else about the question is on-topic, are code-golfed questions automatically off-topic? \$\endgroup\$ – nhgrif Mar 25 '15 at 23:40
  • \$\begingroup\$ No it doesn't. All I said was that it is easier to write a new program than to ungolf a program. Whether you understand what the program does or not doesn't matter - it is easier to write a new version just the same. \$\endgroup\$ – Hosch250 Mar 25 '15 at 23:50
  • \$\begingroup\$ But that doesn't apply strictly to code golfed code. Answers which completely rewrite the original code are posted with some regularity. \$\endgroup\$ – nhgrif Mar 25 '15 at 23:53
  • \$\begingroup\$ They aren't asking for it. When you ungolf code without changing things, it is full of atrocities and hacks to remove a byte, and it needs to be ungolfed to be usable. \$\endgroup\$ – Hosch250 Mar 26 '15 at 0:09
8
\$\begingroup\$

A question asking to turd-polish deliberately golfed or obfuscated code would violate the intent of the Good-Code Rule, and, by my interpretation, it would violate the letter of the rule as well.

If the code that is posted for review is deliberately obfuscated, then it was not written with the intention of being "good" code. The standard I would use is, the posted code should be as good as the author write, to the best of his/her ability. At that point, it is reasonable to ask others for help to improve it.

Posting code that is deliberately bad to begin with would make a mockery of the code review process, even if your intention is to make it good. Such a question would be closer in spirit to Code Understanding or Reverse Engineering (and I'm not vouching that it would be welcome on those sites either).

\$\endgroup\$
  • \$\begingroup\$ Would code with compiler warnings be automatically off-topic then? \$\endgroup\$ – nhgrif Mar 26 '15 at 0:06
  • 1
    \$\begingroup\$ Automatically off-topic? Highly unlikely. It would have to be pretty egregious — for example, "Please disregard the warnings on line n: I am deliberately not initializing variable x before use because it turns out not to make a difference, and I'm treating an int as a pointer without an explicit cast because it makes my source code more compact." Otherwise, I would give the author the benefit of the doubt. \$\endgroup\$ – 200_success Mar 26 '15 at 0:14
3
\$\begingroup\$

Well, what about ?

I wanted to chip in after chatting with nhgrif. Consider (BF for short). Examples from Wikipedia.

So, BF is purposefully designed as obfuscating. But it can be made sense of using comments and such, and BF has been on-topic assuming other question guidelines are met. We've even had some popular BF questions, like this one or that one.

That being said, BF could very well fall in the "code golfing" category due to its nature. For instance, a question like this would extremely likely be closed as off-topic:


Print "Hello World!" in BF

This code prints "Hello World!" to console. How can I make it better?

++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.

As opposed to a question that could very well be on-topic, such as:


Print "Hello World!" in BF

This code prints "Hello World!" to console. How can I make it better?

+++++ +++               Set Cell #0 to 8
[
    >++++               Add 4 to Cell #1; this will always set Cell #1 to 4
    [                   as the cell will be cleared by the loop
        >++             Add 2 to Cell #2
        >+++            Add 3 to Cell #3
        >+++            Add 3 to Cell #4
        >+              Add 1 to Cell #5
        <<<<-           Decrement the loop counter in Cell #1
    ]                   Loop till Cell #1 is zero; number of iterations is 4
    >+                  Add 1 to Cell #2
    >+                  Add 1 to Cell #3
    >-                  Subtract 1 from Cell #4
    >>+                 Add 1 to Cell #6
    [<]                 Move back to the first zero cell you find; this will
                        be Cell #1 which was cleared by the previous loop
    <-                  Decrement the loop Counter in Cell #0
]                       Loop till Cell #0 is zero; number of iterations is 8

The result of this is:
Cell No :   0   1   2   3   4   5   6
Contents:   0   0  72 104  88  32   8
Pointer :   ^

>>.                     Cell #2 has value 72 which is 'H'
>---.                   Subtract 3 from Cell #3 to get 101 which is 'e'
+++++++..+++.           Likewise for 'llo' from Cell #3
>>.                     Cell #5 is 32 for the space
<-.                     Subtract 1 from Cell #4 for 87 to give a 'W'
<.                      Cell #3 was set to 'o' from the end of 'Hello'
+++.------.--------.    Cell #3 for 'rl' and 'd'
>>+.                    Add 1 to Cell #5 gives us an exclamation point
>++.                    And finally a newline from Cell #6

In this regards, I think questions that are specifically golfing (i.e., obfuscating) should be off-topic for Code Review.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .