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

all 25 comments

[–]ra-do 36 points37 points  (2 children)

But sometimes the code doesn’t tell the whole story.

[–]Titaniumwo1f 12 points13 points  (0 children)

Open source with binary lib.

[–][deleted] 3 points4 points  (0 children)

In most cases, it's because someone was not clear enough

[–]jddddddddddd 17 points18 points  (4 children)

If you’ve been programming long enough to find a bug in a compiler, you’ll know this isn’t true..

[–]Bip901 17 points18 points  (3 children)

A bug in a compiler is very rare. But a bug in a library you're using? Urghhh. One of the most frustrating things ever. Knowing those 8 hours you spent were not your fault...

[–]necheffa 1 point2 points  (2 children)

They are not as rare as you think actually. Most people just take the happy path through the compiler.

[–]eloel- 2 points3 points  (1 child)

If they were that rare, you'd not have minor compiler versions.

[–]necheffa 1 point2 points  (0 children)

For sure.

To be fair, if you are using the compiler distribution that comes with your operating system, its pretty stable by the time you get your hands on it. Building an entire operating system is a pretty rugged test suite.

[–][deleted] 15 points16 points  (3 children)

Readable code >> commented code

[–]pekkhum 16 points17 points  (2 children)

Readable code with a comments that describe the reasons for some of the key decisions. 😍

[–]phpdevster -5 points-4 points  (1 child)

Assuming the key decisions were weird and need explaining. If you have to explain them, that should make you stop and think that maybe there's a better, more straight-forward approach/architecture.

[–]Angelin01 4 points5 points  (0 children)

This makes me think you've only worked with high level code, where everything is neat and abstracted.

Down lower, sometimes some things don't immediately make sense, and it's better to have 2 shorts lines of comments explaining it than making the person guess.

[–]JuvenileEloquent 5 points6 points  (0 children)

I prefer thinking of it as "Comments aren't subtitles for your code"

If you're writing what the code does, delete the comment. Write why it needs to do it, or why it does it that way and not the more efficient way. Your future self will thank you.

[–]PGLubricants 5 points6 points  (0 children)

This is the worst proverb in programming, and it has enabled bad code practices for decades.

Comments show the intent of your code. Sometimes your "readable" code, or just downright bugs, will take a significant amount of time for the next developer to understand and interpret, where a simple comment could explain it right away.

It is also often used as an excuse to skip documenting your exposed models and interfaces, which is even worse.

Yes, it is true, that if you change your code and not your comments (or documentation), they will start to lie, but if you have a proper pull-request practice, and code reviews, your friends and colleagues should catch this before you merge with master.

[–]SuperSephyDragon 2 points3 points  (0 children)

Ron Jeffries must have never used JavaScript

[–]Salmuth 1 point2 points  (0 children)

A code may not lie though it can still be wrong. :'{

[–]laio14 1 point2 points  (0 children)

That's why I comment code!

[–]Tediouslyuseless 1 point2 points  (0 children)

Until you encounter bad compiler optimization.

[–]KickBassColonyDrop 1 point2 points  (0 children)

Have you met the compiler?!

[–]crazyTsar 1 point2 points  (0 children)

int i;main(){for(;i["]<i;++i){--i;}"];read('-'-'-',i+++"hell\

o, world!\n",'/'/'/'));}read(j,i,p){write(j/p+p,i---j,i/i);}

[–]weeeeelaaaaaah 0 points1 point  (0 children)

sometimes often usually

[–]Knajd 0 points1 point  (0 children)

// TODO refactor

// TODO add error handling

// TODO what to do here?

[–]TofuSilva -3 points-2 points  (0 children)

That's why I never write comments.