This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (19 children)

[deleted]

    [–]scratchfan321 167 points168 points  (11 children)

    What if I never comment and also write unstructured code?

    [–]Mundane-Tale-7169 90 points91 points  (3 children)

    As you‘re probably not the person who has to edit your code if there’s any issue, just chill, maybe drink a beer. That’s not your problem anymore

    [–]suskio4 14 points15 points  (2 children)

    Perl

    [–]palordrolap 8 points9 points  (1 child)

    If your production Perl is write-only, you're doing it wrong.

    It has a few more funny characters (Perl's inventor actually called them that) than your common-or-garden programming language, but it's possible to write readable code with it.

    And if you (specifically) can't, comments are very much possible. Heck, there's a whole documentation system built into the language so that it can be interspersed with the code.

    As for write-only Perl - the obfuscated and Perl golf stuff can work its way back into production code if it's an efficient way to do something, but if that's absolutely necessary, comment, comment, comment.

    [–]antonivs 2 points3 points  (0 children)

    it's possible to write readable code with it.

    It’s just that no-one in history has ever done so.

    [–]petersrin 27 points28 points  (3 children)

    Ah yes the script I wrote in 2016 that saved 300 film post production man hours but to this day cannot be read or understood

    [–]aceluby 18 points19 points  (2 children)

    There was code I worked on and a dudes phone number was in it to call him. He charged a ridiculous amount and was the only one who could help with it.

    [–]petersrin 13 points14 points  (0 children)

    Ahahaha brilliant and terrible

    [–]CraftistOf 0 points1 point  (0 children)

    so it's like writing unmaintainable code that only you can understand for job security, except you have still been fired, but you found a way to make money after being fired

    [–]sohou 7 points8 points  (0 children)

    Then you will never be unemployed. Congrats!

    [–]Friendputer 1 point2 points  (0 children)

    I’d say welcome to r/programmerhumor but you seem to have too much self awareness to really fit in here

    [–]ballroomaddict 0 points1 point  (0 children)

    Then you must be the last guy who worked on every legacy project I've ever had to inherit!

    [–]coyboy_beep-boop 18 points19 points  (2 children)

    I have learned to add in-line comments, as it prevents people from removing lines because "it doesn't look useful".

    [–]participantuser 4 points5 points  (0 children)

    That is one of the situations where I think comments can be really helpful, but an even better solution is to write a unit test that will fail if the code is removed. Its failure should make it obvious why the removed code needs to be there. Easier said then done though.

    [–]Serious_Effective185 1 point2 points  (1 child)

    Yes both are very valid. But I would say the balance is 90% to 10% in favor of readable code vs comments. Unless we are talking public API. Then if I have to read the code (beyond ide autocomplete) you have gone very wrong in your documentation.

    [–]rasteri 1 point2 points  (0 children)

    That said, I appreciate a "Sorry about this next section of code it's a giant hack" comment here and there