Hacker News new | past | comments | ask | show | jobs | submit login

Comments should be about why a piece of code does what it does not about what (should be clear from the function/method name) or how (should be clear from the code itself). As long as the comment just explains why it should be as long and detailed as necessary.



That is so wrong.

Mathematical thesis are using a syntax arguably much much more powerful than programming languages and yet they're still using lots and lots of english to describe what the formulas are doing and why they're (supposedly) correct in doing so.

I very much prefer to have 1000 lines of some Lisp dialect with lots of comments about what the code does than 10 000 lines of "self-explaining" Java/C# code.

Code can contain bugs. Comments cannot.


>Comments cannot.

I disagree. While the comments won't break your code, they can certainly ease the introduction of bugs, and cause cognitive delays when they're wrong or out of date.

Comments need as much care as the code itself, with the DRY principle guiding when they need to be pruned.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: