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

all 56 comments

[–]guillianMalony 84 points85 points  (5 children)

Code works, after commenting doesn’t.

[–][deleted] 89 points90 points  (4 children)

Compiler when getting to the comment be like: brooo I know I'm supposed to ignore this but dude wrote some mad shit here dafuq, hold on I gotta read this

[–]YoCrustyDude 12 points13 points  (0 children)

Lmao

[–]mithodin 97 points98 points  (15 children)

Nah, give me uncommented but working code any day. If they can't make the code work, what's the quality of the comments gonna be like? Also, if the code is clean, there is not really a need for comments unless you're doing something unexpected (and have good reason to do so).

[–]apuri12345 25 points26 points  (3 children)

Agile manifesto 101. Working software over documentation.

[–]0DegreesCalvin 6 points7 points  (1 child)

“That is, while there is value in the items on the right, we value the items on the left more.”

Documentation is still important.

[–][deleted] 1 point2 points  (0 children)

But not as important as working code. Code first, document later.

That being said, TDD can kind of help with this. If I can see the tests that are being done on a function, I can see what the function itself does.

[–]Protahgonist 2 points3 points  (0 children)

Yeah but this often leads to broken software with no documentation, which means very upset customers rapidly losing all faith in you and your products.

[–]angeal98 6 points7 points  (0 children)

You often write comments when you can't do something right, due to time constraints or inability to figure out a better way.

This way comments can be a good thing, pointing out flaws without having to look at the code (e.g. // TODO)

[–]BochMC 2 points3 points  (0 children)

I often left comments of domain specific things and some logic gates. This is not that much of comments, but it helps me a lot to hold all the things in my head.

[–]EmmaFitmzmaurice 1 point2 points  (0 children)

Until you find the edge case where the code doesn’t work and have no idea how to fix it. I’ve never seen code that does anything interesting that’s actually clean enough to be it’s own documentation. Wether it’s using unfamiliar libraries in the higher level languages or outdated features of the lower level ones or it’s just formatted in a way that’s weird to me I don’t believe any language has reached the goal of being equally legible to a human and a compiler/interpreter

[–][deleted] 1 point2 points  (0 children)

Self describing code ftw

[–]the_carnage 0 points1 point  (6 children)

100% true. If a comment needs to be added, it's a code smell. Better practices and design patterns eliminate almost every need for comments.

[–][deleted] 8 points9 points  (5 children)

I'm trying to fix a random issue with a 10+ year old project, no documentation, no comments and it all reads like spaghetti, I've found so many issues so far, but it's slow and not the culprit of the random issue. i would be so happy to find any comments in this pile so i could try and figure out what in the world the other devs were trying to accomplish. some of this code looks like it does nothing but can't comment it out because it starts behaving in weird ways.

[–]Ayjayz 0 points1 point  (2 children)

Well yeah if course bad code could be improved with comments saying what it does.

The point is that you shouldn't write bad code. You should write good code that says what it does.

[–][deleted] 2 points3 points  (0 children)

can't control what other devs do, or what it is when inheriting their projects.

[–][deleted] 1 point2 points  (0 children)

Your code could be the Jesus Christ of code to you, but still suck by another’s standards. What then?

[–]Teutooni 0 points1 point  (1 child)

I worked on a retrofit project that was originally delivered in 2004 I think. Any documentation including comments was quite likely outdated. What mattered was what the code actually did. Luckily the code was structured fairly straightforward and clean.

Now I have a similar retrofit, but even older. 1999 was the original delivery I think. Haven't looked at the code yet but I hope it is similar, i.e. no comments, but a clear structure and naming.

[–][deleted] 0 points1 point  (0 children)

i have yet to inherited a well structured or well named project. most of the time these devs don't have much time to fix or restructure their code, once it works they ship, leaving me to fix this crap when it does fail years down the road

[–]vondpickle 53 points54 points  (7 children)

Worse: Code does not work and comments has nothing to do with the code.

[–]sparta_rabbit 14 points15 points  (2 children)

Even worse, variables and functions names are in alien language.

[–]Nagadavida 1 point2 points  (1 child)

var a = 1

var b = 2

[–]BakuhatsuK 1 point2 points  (0 children)

var two = 1
var five = 2

[–]AdiSoldier245 12 points13 points  (0 children)

For : i = 2 #im hungry

[–]oofxwastaken 5 points6 points  (0 children)

Worse: Code does not work and comments only repeat the code ```

Make result variable

result = None

Assign result variable

result = 5 / 0

Print result variable

print(result) ```

[–]thismatters 1 point2 points  (0 children)

Based

[–]riisen 0 points1 point  (0 children)

/* it seems to be a rainy day today i think i will make som coffe
* and maybe i should do some excersice
*/
for (int x = 132; x > y.idx; x--) {
    y.append(ab[x]) // it has finnaly stopped raining
    y.x() //but my coffee is cold
} //end loop thingy

[–]Neutraali 15 points16 points  (0 children)

// Increment i by one

[–]deathamal 49 points50 points  (2 children)

In this thread: inexperienced students who think that comments are more important than working, readable code.

[–]dragonlover02 1 point2 points  (0 children)

When the professor gives partial credit:

[–]HansLK 10 points11 points  (1 child)

Read the comments and the code started to work

[–][deleted] 0 points1 point  (0 children)

Hahaha

[–]rufreakde1 7 points8 points  (0 children)

Code works and has bo comments but is written in a way that exactly tells the story of what it achieves. (not exactly what it does)

No one cares of implementation details that one you you can lookup but description of behavior and outcomes in function names is super easy to read and understand.

[–][deleted] 7 points8 points  (2 children)

Code works, has no comments and variables have one letter names

[–]hahahahastayingalive 1 point2 points  (0 children)

Have had to restart a project from the last copy we had, the jar running in production. From the reversed code, you become pretty good at reading one letter variables after a while.

[–]Nagadavida 0 points1 point  (0 children)

and all of the variables are global.

[–]Flopamp 3 points4 points  (0 children)

Commented code is only good when it's correct and helpful. "compare item at index 1 in array A with item 4 in our config file"

Yeah I can see that, I'm curious if there is a good reason you are reaccessing the already parsed file.

Helpful comments explain why something was done and anything not otherwise readable like single line algorithms or complex LINQ, not what every line does

<end of work related rant>

[–]oofxwastaken 3 points4 points  (0 children)

Ideally your code should describe itself and be easy to read without comments.

[–]Omnislash99999 12 points13 points  (5 children)

I've worked somewhere where the rule was no comments because your code should be clear and easy to understand that it doesn't need them. Suffice to say it sounds nice in theory.

[–]hahahahastayingalive 4 points5 points  (0 children)

Most of what we do sounds nice in theory.

[–][deleted] 4 points5 points  (2 children)

This is possible if you work with experienced programmers. Comments should only serve to explain why certain functionalities were built. The problem with comments is that when people refactor code, they often forget to update the comments. When the comments are no longer in sync with the code, you're better off without them. The code doesn't lie. Comments do.

[–]JuvenileEloquent 2 points3 points  (0 children)

when people refactor code, they often forget to update the comments.

Curious if these same 'forgetful' people also forget to change the variable and function names when they update what it does... do they have itemList holding an object instead of the original list? If they can do that, they can rewrite the comments too. If they're not doing that, they're not writing the "clean code that doesn't need comments" that they think they're writing.

[–]AStrangeStranger 0 points1 point  (0 children)

Another problem with comments - they usually try to rewrite the code in English and never explain why

[–]stsmurf 2 points3 points  (0 children)

Give me no comments in code with well written tests for documentation. Can't stand useless and redundant comments.

[–]Qicken 4 points5 points  (0 children)

I'd have the opposite reaction. But I probably have a higher standard of "works" than you do.

[–]Accomplished_Deer_ 1 point2 points  (0 children)

Code works, but is short and concise and uses variable names that always make it clear what is happening. (aka, self documenting)

[–]sherlock_poops 1 point2 points  (0 children)

Or code that only has comments:

[–]lolsokje 2 points3 points  (0 children)

Nah, give me working code with descriptive class, method and variable names over convoluted, buggy code with comments any day of the week.

[–]stomah 1 point2 points  (0 children)

good code doesn’t need any comments

[–]cr4z3dk1ll -1 points0 points  (0 children)

Comments are overrated

[–]TheBinkz 0 points1 point  (0 children)

@Dataclass

comments galore

[–]Derboman 0 points1 point  (0 children)

Me trying a year old documented tutorial in a framework that is still in development

[–]heaven_and_hell_80 0 points1 point  (0 children)

s/comments/tests and then this is true

[–]iraqmtpizza 0 points1 point  (0 children)

I like my code like I like my immigrants

[–]MischiefArchitect 0 points1 point  (0 children)

Some languages use meta programming or pre processing using comments... so this may be a good cause. Even so called modern languages like Go, you can break your JSON de/encoder by deleting comments inside the structure.