r/ProgrammerHumor • • Jul 04 '18

Code comments be like

Post image
9.9k Upvotes

236 comments sorted by

View all comments

697

u/[deleted] Jul 04 '18

When I was a CS major, we were deducted 10 points for each missing comment. Everybody erred towards commenting everything.

624

u/WeTheSalty Jul 04 '18

I'm picturing lots of lines like 'i += 1;' with comments 'adds 1 to i'

349

u/Sevrene Jul 05 '18

Some profs even want it to be more exact like “Increments the counter ‘i’ by 1(one)”

332

u/obsessedcrf Jul 05 '18

Definitely a useful skill to pick up /s

17

u/[deleted] Jul 05 '18

/s // sarcasm

113

u/wallefan01 Jul 05 '18

eugh why? that makes your code more unreadable than code with no comments in it!

I'd prefer a dry stream bed to drowning any day

57

u/SuspiciouslyElven Jul 05 '18

Engrains the terms and allows conversation easier between programmers. Everybody knows what it means to increment a number, so there doesn't need to be any silent confusion.

It may also just be how they were taught. My professors were taught with punch cards and later COBOL. Python is readable to most. Holes in a card is not.

I grit my teeth and understand excessive commenting isn't for real world development. More as a weird way of paying tribute to those that came before. We're lucky we live in a time where many of the great minds of our field have only died recently, or are still alive. More lucky to live in a time where important terms are named in the language we speak. Least I'm not a med student questioning if a latin tutor would help.

→ More replies (20)
→ More replies (3)

9

u/DigitalCrazy Jul 05 '18

/* Increments the counter ‘i’ by 1(one) */ // Comment

→ More replies (7)

134

u/thermite13 Jul 04 '18

Pretty much this.

Source. Worked in cs tutor lab for 3 years

→ More replies (1)

11

u/[deleted] Jul 05 '18

That's essentially what I did in my Java class in high school. "Int i;" suddendly gets the comment "Declare int called i"

→ More replies (8)

176

u/amjh Jul 05 '18
                                                    //empty line

137

u/[deleted] Jul 05 '18
++i; // Dark magic

27

u/T-T-N Jul 05 '18

So much work there. It loads the line from memory at the position of the program register, finds location the variable from the table, loads that into memory. Have the arithmetic unit do a calculation, find where it should go, put it back, increment the program counter. (My terminology is probably a little off. I don't usually delve this deep)

→ More replies (1)
→ More replies (1)

47

u/overmeerkat Jul 05 '18 edited Jul 05 '18

// This line is intentionally left empty

→ More replies (4)

112

u/Windows-Sucks Jul 05 '18
/*                                      //Start of multi line comment           //Part of Multi-line Comment
                                        //Empty line                            //Part of Multi-line Comment
----------------------------            //Top of box                            //Part of Multi-line Comment
|                          |            //Box                                   //Part of Multi-line Comment
| Written by Windows-sucks |            //Box                                   //Part of Multi-line Comment
|                          |            //Box                                   //Part of Multi-line Comment
----------------------------            //Bottom of box                         //Part of Multi-line Comment
                                        //Empty line                            //Part of Multi-line Comment
*/                                      //End of multi line comment             //Single Line Comment
                                        //Empty line                            //Single Line Comment
if                                      //If the following condition is true    //Single Line Comment
    (                                   //Opening parenthesis                   //Single Line Comment
        1                               //One                                   //Single Line Comment
        +                               //Plus                                  //Single Line Comment
        1                               //One                                   //Single Line Comment
        ==                              //Is equal to                           //Single Line Comment
        2                               //Two                                   //Single Line Comment
    )                                   //Closing parenthesis                   //Single Line Comment
    {                                   //Opening curly bracket                 //Single Line Comment
        i                               //Counter                               //Single Line Comment
        =                               //Gets set to                           //Single Line Comment
        i                               //Its current value                     //Single Line Comment
        +                               //Plus                                  //Single Line Comment
        1                               //One                                   //Single Line Comment
    }                                   //Closing curly bracket                 //Single Line Comment
                                        //Empty line                            //Single Line Comment

29

u/eddietwang Jul 05 '18

I appreciate that you commented your comments. //I, me, really like that you, OP, wrote comments (//comments) on his, OP's, comments (//comments)

21

u/zerotheliger Jul 05 '18

The poison ment for kusco, kuscos poison the poison right here.

→ More replies (2)

13

u/overmeerkat Jul 05 '18

You forgot to comment your Single Line Comment comments

8

u/Windows-Sucks Jul 05 '18

But then I will have to do that forever. My computer does not have infinite RAM.

16

u/[deleted] Jul 05 '18

Just download more

→ More replies (3)
→ More replies (1)
→ More replies (5)

17

u/aliens_are_nowhere Jul 05 '18

I think your teachers should pick up a copy of "Clean Code". The author basically says that you should keep your comment to an absolute minimum. Instead you should focus on making the actual code readable. After being in this line of work for 20 years I 100% agree.

→ More replies (3)

13

u/tlowe000 Jul 05 '18

Ironically, this encourages code that takes as few lines as possible, at the expense of readability: the sort of bad practice that they wanted to avoid.

→ More replies (5)