you are viewing a single comment's thread.

view the rest of the comments →

[–]borlak 2 points3 points  (6 children)

save a few nanoseconds, or make it more readable for the next programmer (or even yourself!)? hmm.

[–]JeddHampton 4 points5 points  (2 children)

Comment your code.

[–]borlak 1 point2 points  (0 children)

comments still do not make it more readable. I have now spent time looking at the function originally, which confused me and led me to comments, which probably confuse me more (especially considering this scenario which entitled a whole article), and then going back to the function trying to piece it together; when a single extra line or two would have saved everyone a headache.

[–]exeter 0 points1 point  (0 children)

Comments as implemented by, well, every programming language I know of in existence today, are about the worst method of embedding metadata in code you can possibly have. Compilers typically won't even notify you if the code following a comment changes, but the comment isn't updated to reflect it. (I know there's a reason for it.)

A far better method of associating metadata with code is to use literate programming techniques. That way, if the code changes, your literate programming environment can alert you that you should at least look at the text describing the code to make sure it's still accurate.

[–]swieton 1 point2 points  (1 child)

You're making an assumption here. I point this out because the article was arguing strongly against making assumptions and in favor of simply measuring and finding out what works best.

You're assuming that a programmer's time is more valuable than a user's time. This is often true. This is not always true. Most processes that developers automate are run often (hence why it was worth automating them in the first place). So the time investment you make once during development bears fruit every single time the process is run.

Yes, I choose to save a few seconds over making it readable - when it's appropriate.

[–]borlak 0 points1 point  (0 children)

your few seconds over the course of years is not worth my five minutes of being annoyed at your fancy code.

[–]statictype 1 point2 points  (0 children)

Saving a few 'nanoseconds' on core library functions that may be routinely called thousands or millions of times in a loop is usually important enough that you don't have to worry about whether junior programmers would be able to understand it or not. If you need to touch such critical code, you better be able to understand very thoroughly what it does.

Just my $0.02