3 ms·
This might be beautiful code but come on, not a single comment?
by billmcneale 16y ago
This might be beautiful code but come on, not a single comment?
- KirinDave 16y agoComments: the great deceivers. To paraphrase: Some people write tricky code and say, "Ah! I will use a comment to make this clear." Now they have two problems.
- Peaker 16y agoYou might be assuming a little much about the purpose and target audience of this code :-) I didn't write it, by the way.
- silentbicycle 16y agoSee those type declarations? Those are comments. Comments that are automatically checked.
- Zaak 16y agoOn the one hand, I agree. On the other hand, a type declaration cannot possibly tell you /why/ unless the type system encodes a significant portion of our physical world. This encoding is left as an exercise for the reader.
- silentbicycle 16y agoAgreed, generally. I'd say comments are to express things the code itself cannot. More expressive languages can get by with good naming, some declarations, and clear idioms in many cases. The most useful kind of comments are "why" comments, about why specific design trade-offs were chosen.
- billmcneale 16y ago<sigh> So you're one of these "Code properly written shouldn't need comments" people, uh? To understand code, you need to figure out "why" and "what". Code gives you one, comments give you the other.
- silentbicycle 16y agoI mainly agree with you, but for something like that, "it's an AVL tree, look it up" is all it should need. Names and type declarations handle the rest. If you want to dismiss me as "one of those" people that is anti-commenting, you're reading too much into what I said. You said, "it doesn't have comments!", I said "actually, it does, and they're even checked." The end. In a more complex program, I'd add comments. How many, and the nature of the comments, depends on whether I was writing in something relatively low-level (like C) or something high-level (like Haskell, Erlang, or K).