The real thing to blame here is the fact that version control systems are still in the 80’s and match source code as if it were simple text. If Version control systems were not language agnostic, they would never flag trailing whitespaces as diferences, neither putting “{” on the same line vs next line, etc.
One could checkout code and see and edit it with his/her preferences and upon commit it would be converted to an internal representation that abstracted all those differences that did not affect program semantics.
Even if you commit code with lots of spaces in the end (for some weird reason), if those spaces did not affect the program, they would be deleted.
As much as I agree, (if I saw that whitespace, I would almost certainly delete it, even if it was just some irrelevant sample code I was looking at) a commit where the only thing changed was a bunch of whitespace taken out is one of the most ridiculous things ever.
Love it. I recently forced all the programmers on my team to make sure their VS options had tabs NOT SPACES due to the repeated “conflicts” when updating source control. What? the whole file is in conflict?! WTF!?
I’ve learned over the years to to ignore whitespace, and most other formatting issues foudn in OPC. I’m going to apply that same discipline to ignoring all the incorrect arguments attempting to justify it. Also surprisingly difficult to do.
The real problem here is the use of space characters and not proper tabs. Have you ever gazed upon the horror of source code maintained by two people that both use soft tabs, but have them configured for different widths? Hard tabs, people. Separate the data from the presentation.
Yes you are once we spent hours after site was suddenly crashed just to find out that we had mistakenly put 2 white spaces after PHP closing tag…
But after all we all love web designing and will go on coding…
John. Judging by your quadruple posting above, I’d say that trailing white space is the least of your problems. For most people (but evidently and surprisingly not everyone) they are a trivial irrelevance that is easily dealt with - if they are even noticed.
Solution: auto-convert the code to a very strict canonical format before commit. There should be one and only one way to represent the same functional code structure.
IN this post I compare Web coding to a Robin Williams routine on golf. Fixing a mistake in some minor part of code is like trying to hit a tiny ball 350 yards into a small hole.
In our java builds, we have checkstyle (a style checker, duh) built into our build process to enforce our style standard, and it has rules to check for trailing whitespace. If you don’t fix before checking in… BOOM broken build