Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Same - if my code is complex enough to not be easily written in a few lines I'll drop a comment about what it is doing and maybe even why. It takes a minimal amount of effort while I'm coding and saves a lot of time when I (or someone completely unfamiliar with the code) have to revisit it months/years later.

My guiding principle is that I don't want someone to read my code years later, exclaim "Who the hell is this alyandon guy?!?!" and be motivated enough to create a time machine so they can go back in time and smash my keyboard to bits before I wrote said code.



Likewise if I am using some advanced feature of the language / framework, I think it's worth a comment.


I'm arguing here all over the place for writing comments. But exactly this kind of comment mentioned here I think is the most useless sort of.

Someone working on the code should know the language. If they stumble over something they don't know they should read the documentation of the language. Explaining the programming language you use in code comments is a terrible idea, imho. It's like writing comments of the form "adding the numbers" and than adding some numbers. Just useless noise.

The more important question would be, as always, why you used this feature? What would be e.g. the alternatives?

Just stating that you do something, just to do it than with code makes no sense. Nobody needs that redundancy.


How can people ever learn new languages if they are expected to only work on languages that they know? There are loads of systems out there using multiple languages. I agree why is more important than what. But sometimes you run into some strange functional construct that is very clever, but not in the slightest bit intuitive to read.


If something is not intuitive to read this is bad code most likely.

If there are good reasons WHY this is still the best way to do things, this WHY should be explained.

But, of course, not the how. It's self evident that some "special" functionality was used.

If you read some scientific paper you would also not expect to find there basic explanations of the scientific topic. To read and understand a paper you need to know the subject.

The same goes for code: You need to know your tools. Otherwise you can't use them properly anyway.

Language documentation just does not belong in random code comments. The comments should be there to explain your special use case, not give some basic tutorial to people that don't know the tool used in the first place. That are completely different concerns, and should not be mixed therefore.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

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

Search: