2 ms·
This does not acknowledge that code styles can be compared in objective ways. What is more readable? # Expression 1 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1
by 29athrowaway 6y ago
This does not acknowledge that code styles can be compared in objective ways.
What is more readable?
# Expression 1
1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1
# Expression 2
10
One requires to do 9 arithmetic operations in your head, perhaps more than once if you lost count, the other one doesn't.
You can compare code in terms of length, nesting, cyclomatic complexity, number of negations, number of inputs, etc. It's not just subjective bikeshedding.
- bluGill 6y ago1 is simpler in most cases because I trust the computer to get the answer, but I need to know all the explicit parts. 2 hides where it all came from for an answer which might be wrong.
- 29athrowaway 6y agoUsually you give each constant a name and then operate on them symbolically. If it's a simple enough operation you can skip that and just add a comment. In this example, there are 9 arithmetic operations and there are clearly more readable ways of doing this. This is the point I am trying to make. For the author of this article, using roman numerals and using arabic numerals are the same because they represent the same quantities. However, in practice, if you have 2 accountants and tell one of them to use roman numerals, the one using roman numerals will be less productive, make more mistakes and will likely be frustrated.
- luckylion 6y agoI agree very much. 60 * 60 * 24 * 3 vs 258200. Which one is the number of seconds in three days?
- goto11 6y agoWhat is the code intended to communicate? It we don't know the intention we cant say which example most clearly communicates this intention.