Re:Why Not Comments
by seanmcdirmid on Tuesday September 10, 2024 @06:56PM
(#41506449)
We could have the best of both worlds if comments could be easily hidden, or better yet, just additional meta-data on rich text code. But nope, we can't get away from ascii.
[ Parent
| on HN ]
Re:Why Not Comments
by readthenotes1 on Tuesday September 10, 2024 @06:59PM
(#41506485)
Trouble with comments is that they drift from the code over time because most people do not update the comments - - based upon my surveying production code bases. If they are hidden, it will drift even quicker and become even more useless faster
Re:Why Not Comments
by shiroiushi on Tuesday September 10, 2024 @08:04PM
(#41506915)
This is caused by poor or nonexistent code review practices. Reviewers should be ensuring that related comments are updated if code functionality is changed.
Re:Why Not Comments
by seanmcdirmid on Tuesday September 10, 2024 @07:39PM
(#41506762)
...and the main reason people don't like comments is because they clutter up the code that gives them the truth of the matter. But yes, if they aren't in your face forcing you to look at them rather than the code, then they are slightly more likely to not be ignored when the code is changed.
It would be nice if they could be like footnotes, or boxed out-takes, that could be pushed to side notes. We have had the typography, even if it was just markdown with a rendered code reading mode.
Re:Why Not Comments
by convolvatron on Tuesday September 10, 2024 @07:38PM
(#41506756)
i think in sean's proposed world we'd have metadata about that too! the comment in the context it was written in would be available, as well as all of the surrounding changes that potentially invalidate it. as well as potentially a whole discussion thread about what they meant when they wrote it, and suggestions about how to change it.
I would urge developers to err on the side of too many comments over having too few comments, even if there's a risk of them going stale. I can deal with drifting comments, but I can't deal with missing comments.
I've found the opposite. Misleading comments can be far worse than no comments.
Date and sign comments. /* Helps determine staleness -- conrach 2024-09-12 */
You just need a "hide/show comments" extension for your IDE. (I would argue that such a feature should already be built in.)
You don't need to abandon plain text to hide comments. Comments are detectable with a regex; an extension to hide comments would be trivial to make in most editors. I think it's not a common feature because people generally just don't want it.
Rich text code would create so many problems, too. You get locked into a special editor. You need special version control. Grepping becomes difficult. Diffs become difficult. You'd need a whole separate ecosystem, and for what? We have treesitter; we can already treat code like data.