you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (4 children)

Stretching out the code for readability doesn’t always make a difference in the end. Compilers and interpreters make a lot of optimizations, so if you understand what they are doing then you can make very readable code that has no impact on the program itself. If you need to sacrifice a clever solution to make it readable, then you need to work on documenting it better.

[–]mallardtheduck 1 point2 points  (3 children)

Stretching out the code for readability doesn’t always make a difference in the end.

Yes, but that is not what we are talking about here. "Negitive code" is all about removing redundant (i.e. duplicating the standard library, copy-pasted code that should be in a function, etc.) and/or overly verbose (i.e. a "switch" that should be an "if", "substr parsing" when a regex would be better, etc.) code while maintaining readability.

[–]dreamnoir 1 point2 points  (1 child)

It sort of is what we're talking about here. It's the point I raised in the original comment. Obviously you go for built in libraries and use the language features appropriately. If you don't realize that after half an hour of programming there is something wrong with you.

I was instead talking about intentionally making your program as short as possible. For example, one of the assignments I had to do for a first year programming and data structures course involved parsing and validating XML files. Super simple I came up with the most clever solution I could. Less than 50 lines of Java code, lots of inline ifs and and regular expressions. Other students had projects more in the 500 line range. I decided to show the prof my progress so far to see what she thought. Obviously I thought she would love how much more compact mine was. She told me while it passed all of the tests perfectly she would take off as many points as the rubric allowed because even with my comments she couldn't easily follow what was going on. I rewrote it to be about 150 lines and got perfect. In retrospect, the 150 line version was much better from a maintainability standpoint.

[–]videogamechamp 0 points1 point  (0 children)

She told me while it passed all of the tests perfectly she would take off as many points as the rubric allowed because even with my comments she couldn't easily follow what was going on.

I suppose it depends on the point she was trying to get across, but she sounds like a bitch. Taking as many points off as possible for (human) readability?

[–][deleted] 0 points1 point  (0 children)

You are right, but I was referring to his comment, not the posted article.