Hisham is a user on mastodon.social. You can follow them or interact with them if you have an account anywhere in the fediverse. If you don't, you can sign up here.
Hisham @hisham_hm

I hate the paranoia around trimming trailing whitespace.

I remember a time when people weren't pedantic about it.

It started with Linux kernel devs because of their patches-over-email development method (email lost whitespace)

Then Linus coded that pedantism into Git.

And it spread like wildfire: editors started painting trailing whitespace RED.

Now everyone HATES trailing whitespace and when I ask them why they go blank for a second, then "...because Git and $EDITOR complain about it"

· Web · 6 · 8

@hisham_hm Actually because it can be the source of line changes that are unimportant. Adding or removing whitespace is irrelevant but will show up as a changed line in git. Therefore, removing whitespace early and sticking to keeping it removed keeps linechanges clean too.

@Gargron Whitespace-only diffs are a different/larger issue from trailing-whitespace.

I don't trim trailing whitespace and I still pay attention to avoid unimportant whitespace-only diffs.

Whitespace diffs can happen whether you trim trailing blanks or not (e.g. when people "align" C-style variable declarations then have to change/add one of them).

@hisham_hm I don't like trailing whitespace because it's completely invisible cruft. Sure, it harms nobody, but it's there, and because it's not surrounded on either side, there is no way to tell without selecting it. I have held an exception for indented blank lines, but that's changing because of the editors.

@impiaaa I love using indented blank lines, it's my #1 use-case for trailing whitespace (their presence has even been occasionally useful to me when scripting some edits over codebases).

Indeed, editors are getting more and more opinionated, clearly changing people's code writing habits. I'm not sure if that's always a good thing.

@impiaaa But then again, I'm opinionated and wrote my own editor in which my opinions are encoded, so... ¯\_(ツ)_/¯

@hisham_hm One reason I actually like Eclipse is that is has a huge number of options for code formatting, whereas other IDEs I've used are more limited.
On the other hand, I don't have any strong preferences about code style, so I'm happy to stick with anything as long as it's consistent (which a code formatter will be).

eh, to be fair i started being irritated by trailing whitespace back in my pre-programming writing-stuff-in-MS-Word days, and chose making-trailing-whitespace-visible for myself.

i realize i'm probably not representative in this, though.....

@hisham_hm

@hisham_hm I think it's ok because it emphasizes that every byte of your patch should be as you mindfully selected it to be, which is true.

@hisham_hm when i was very young, before git hit the scene, trailing whitespace already made me irrationally nervous for reasons unknown. I developed a habit of randomly highlighting text near the line ends just to check for it, and I'd always go through sample code by hand to remove it all before using it. having tooling that takes care of the problem for me and encourages others to remove it from the code they publish has been very welcome in my life~

@lifning something tells me Linus shares your condition ;)

@hisham_hm it messes up editor commands that operate on the end the line and you don't know it's there until the cursor goes to the wrong place, and once it's there it can't be removed without cluttering up the log

your history seems off too, for starters whitespace isn't lost when emailing diffs, and other projects disallowed trailing whitespace long before git happened, eg. freebsd added it to their style(9) in 1997 and it would have been an informal guideline long before it got added

@vi on diffs via email: not in attachments, but inline they do, don't they?

@hisham_hm no? at least mutt, mail(1) and mcom don't

@vi IIRC this was an issue not with MUAs but with MTAs. A mention I could find was here but I didn't search too hard: www.w3.org/Protocols/rfc1341/5_Content-Transfer-Encoding.html

@hisham_hm sending inline patches as quoted-printable has always been discouraged or completely disallowed by pretty much every project that uses inline patches

@daniel_bohrer no, that's a first! I'm not very knowledgeable on the ins and outs of email headers

@hisham_hm me neither, I just came around it a while ago, and had to think about this because you mentioned whitespace at the end of a line :)

@hisham_hm also, since I often check patch files into Git, I have learned to ignore Git's nitpickery about mixing tabs and spaces and whitespace at the end of a line etc.