Whitespace: The Silent Killer

Uncredible, I have read the post about the bad codes of flickr, yahou., reddit etc. And now that one. You whould work for me :slight_smile:

Myabe its just the example you gave, but its no big deal really, get a life.

If it’s my file, I press Ctrl+K+D sometimes, and that usually gets rid of them + the other formatting annoyances. If I modify somebody other’s file, I can mess up the svn patch by doing that, so sometimes when I notice the whitespaces in the patch file, I go back to the file and delete them. Anyway it’s annoying.

At least in corporate “enterprise application” code,
the problem with trailing whitespace is that it often
indicates cruddy, cut-n-paste coding by cut-rate,
one-size-fits-all, lowest-bid consultants.

This whole discussion is ridiculous enough, when it’s a tool problem that can be solved with proper editors. But, then, blaming consultants? I know of many lamo-waiting-for-retirement-even-tho-they-are-only-in-their-30s-programmers that write the worst code on the planet.

Let’s be nice. Let’s get good tools.

My old programming teacher always wrote the most incomplete and syntax violating examples in class - his excuse? “I let the parser find my typing errors”

very good blog, I come here every day,thanks very much for post.

Seriously - 8000 comments and only one person mentioned that this was a) horrible markup and b)just plain old bad code. Never ever mix markup and c# code. That should be an asp repeater bound to a data source. Who cares about the whitespace…

Here’s how I keep my whitespace under control in emacs:

(setq-default indent-tabs-mode nil
require-final-newline t)
(setq whitespace-check-indent-whitespace nil)

(require 'whitespace)
(global-whitespace-mode t)
(add-hook 'before-save-hook
’whitespace-cleanup)

I m sure sure I use other editors for python, one showing me every tab, I tend to do the same for YAML files.

I use Visual Studio 2005 and every now and then I use this procedure to bulk-remove trailing white space from the code:

  • Press “CTRL + SHIFT + H” to open “Replace in Files” dialog
  • Find what = “:b+$” (colon, small b, plus, dollar)
  • Replace with = “” (empty string)
  • Use = “Regular expressions”
  • Look in = “”
  • Look at these file types = “.asp;.css;*.js”

Works nicely. But until you get used to this procedure, remember to backup your files.

Myabe its just the example you gave, but its no big deal really, get a life.
I agree

thanks admin
Are you really cool

Removing trailing whitespace on save is always a good thing. Even if there’s no functional difference, it’s nice to be able to compare versions in your SCM without having to worry about whitespace. Now, don’t even think about opening the “space vs. tab” can of worms!

CTRL+K, CTRL+D baby.

I tried Acme::Bleach once and it destroyed the code. Maybe it was because it was Perl 5.004 on HP-UX or something.

I also loved that the Delphi IDE automatically removed trailing whitespace.

I guess I must be more hardcore OCD than Jeff, because I often go through the code and check for trailing whitespace manually! Though I find it’s only a problem if I copy/paste.

Trailing whitespace is boring. Tabs vs spaces is the real horror!

@a_m0d:

In Python, EOL whitespace can be relevant!
if condition1 and .…
condition2
Python will complain about that trailing whitespace after the
line-continuation character!

That’s not Python specific, and has nothing to do with the Pythonesque kind of whitespace-significance (that is indeed beginning-of-line only). It’s just a consequence of the fact that, if you want to escape a character, you have to put that character immediately after the backslash. E.g. if you’re in a string and you want to insert a quote mark*, you might write "; [space]" wouldn’t work. So if you want to escape an end of line, of course you have to have the backslash write before the end of line; otherwise you’re just escaping a random space.

So that’s not really an instance of actual significant whitespace any more than the fact, if you have a variable “foo”, you can’t refer to it as “fo o”, means that that language has 'significant whitespace.

In 1924, George Mallory, when he was asked why he wanted to climb Mount Everest, said “Because it’s there.” I suppose most still did not understand why. Similarly, if you didn’t understand the pain of this article, you probably never will. :slight_smile:

Just be glad your boss doesn’t inist on using tabs instead of spaces! le sigh

On a side note, you’d think that being an OCD freak you’d have spotted the following:

“Also, how exactly is that day is different from any other? But seriously.”

is=any?

@misteraidan

“I recently forced all the programmers on my team to make sure their VS options had tabs NOT SPACES…”

This is evil. Could you say what team you run so I can avoid it.

I don’t see what all the fuss is about.