3 ms·
I find the "no/less comments" always seems to come from Java programmers. In Perl / Python you can easily do the equivalent of a screen full of Java code in a c
by collyw 12y ago
I find the "no/less comments" always seems to come from Java programmers. In Perl / Python you can easily do the equivalent of a screen full of Java code in a couple of lines. In these cases I think it is helpful to comment liberally and explain what a list comprehension, or map is doing.
Comments adding signal to noise? I agreed with him on that point, but thinking back, I find the most useful time to have comments is when looking at someone elses unspecced code for the first time.
# open file
file = open('filename' 'rw))
# seek to bit 8
file.seek(8)
This is pretty close to a real world example I had to fix.
Now The comments should have explained what we expect to see in the file. What happens at byte 8? I still have no clue, and fixing the bug in that code took me nearer to a week than the day it should have done.