|
|
|
|
|
by kennywinker
5185 days ago
|
|
I always think of using semicolons like using parentheses when doing math in code. It makes the order of operations explicit rather than implied. For example, 1 + 2 * 3
Solves to 7, obviously. But I'll write it in code like this: 1 + (2 * 3)
Just to make it clear that I know what I mean, and I mean do the operations in _this_ order.Similarly, using semicolons to end lines means I am saying loud and clear... this line of code ends HERE. Obviousness is a good thing, no? |
|
So I actually think that 1 + 2 * 3 is better than 1 + (2 * 3). I usually find reading a line with less stuff easier, so I prefer the shorter between two equivalent expression.
Besides, adding a semi-colon is more like surrounding the whole expression with parentheses rather than just grouping. And you would never write (1 + (2 * 3)). And yet that also says, loud and clear, the same thing!
I've used some languages with optional semi-colons--Python and Haskell, for example. I've never thought that missing them made the code less readable--it's always been the opposite. Going back to Java and having to use semi-colons everywhere becomes increasing annoying as I grow more acclimated to languages without.
In short, I see where you're coming from but don't really agree.