Whitespace: The Silent Killer

#1

Ever have one of those days where everything you check into source control is wrong?


This is a companion discussion topic for the original blog entry at: http://www.codinghorror.com/blog/2009/11/whitespace-the-silent-killer.html
0 Likes

#2

Dude, Jeff, calm down… it’s just a bit of space.

0 Likes

#3

$foo =~ s/.*?\s+// if it bothers you that much.

I prefer languages where whitespace doesn’t matter to the compiler - C, Perl, Lisp…

0 Likes

#4

If the problem is the extra bytes sent over the network, perhaps the ASP template engine has an option to strip the whitespaces on the fly ? Another option is compressing the response, I don’t know how to do it in ASP but with servlets is easy to do, and the browser takes care of the unzipping automatically. This is convenient for very heavy pages of course. In any case, I prefer the readability provided by the extra spaces.

0 Likes

#5

Different material. I will try this. Thanks so much :slight_smile:

0 Likes

#6

If that code ends up getting downloaded, like with JavaScript, HTML, or CSS, the extra white space wastes download time, and costs money. I bet the world could save hundreds of dollars by taking out the trailing spaces.

0 Likes

#7

Imagine how it is for those of us who spend a lot of time in Python world, where the whitespace isn’t just an OCD obsession, but can actually modify the functionality of code!

0 Likes

#8

The Delphi IDE has a neat setting that automatically throws away trailing spaces.

0 Likes

#9

“Run your IDE in whitespace-always-visible mode, or toggle it frequently”

A friend of mine calls it “Pac-man mode”. All of a sudden you see all of these little dots that need to be gobbled up…

0 Likes

#10

Python world, where the whitespace isn’t just an OCD obsession, but can actually modify the functionality of code!

But isn’t EOL whitespace irrelevant to Python as well?

0 Likes

#11

@Rizwan : +1 ! We want code to be space sentitive!

Or at least a “Trim Trailing and save” option in Visual Studio as we have on Notepad++

0 Likes

#12

Actually, it should be a feature of the IDE. The solution is just a plugin away :slight_smile:

Just like in Vim : http://vim.wikia.com/wiki/Remove_unwanted_spaces (let the holy wars begin…)

0 Likes

#13

eclipse also has a “remove trailing whitespace” option.

0 Likes

#14

I know exactly what you mean. Carefully crafted source code, nicely tucked away in your repository, and then someone with TextMate comes along and automagically adds random whitespace all over the place. Byebye useful diffs!

0 Likes

#15

You seem like the perfect candidate to start using the Whitespace language.

http://compsoc.dur.ac.uk/whitespace/

0 Likes

#16

Eclipse can format your code and/or remove trailing whitespace on save. I think that’s the optimal solution.

0 Likes

#17

Whitespace.
You can’t see it,
it must not matter.
If it does,
Tool broken.

captcha: Danner peet

0 Likes

#18

OMG! Whitespace! Makefiles just popped in front of my eyes. Tabs and all that.

0 Likes

#19

People who don’t care about whitespace, don’t have to deal with merging code. I make sure everyone I work with has to fix their own whitespace merge conflicts. Sometimes they even learn to set their IDE up correctly.

The next question is; should we extend this to automated code formatting? Personally I am not willing to take that step yet, because I don’t like any automated code formatters, and more importantly all the code I write is formatted correctly. :slight_smile:

0 Likes

#20

Diffing for no reason is a mortal sin.

0 Likes