a companion discussion area for blog.codinghorror.com

Death to the Space Infidels!


#161

wow, only 3 eclipse references.
why is auto-formatting (a next-next-generation editor?) such a big deal for the unwashed jeffs and followers?


#162

I now know what Geisterfahrer means. :slight_smile:


#163

I can see a new set of adverts - maybe with Vin Diesel and Keifer Sutherland:

I’m a TAB
.
.
.
I’m a space


#164

captcha should probably change once or twice… it seems the Chinese spammers have discovered the secret power of orange…

But the best way to train them not to do it, is to ignore their bad behavior.


#165

I think Jeff ought to include more a second version of each post that has mostly pictures and very few words so some of the readers can keep up.


#166

I wonder if the spammers have figured out the secret of the capcha, of if they’ve just got some human typing it in each time.


#167

Those who say it doesn’t matter as long as it’s consistent are dead on. I have my opinions, of course, but the fact is that my eyes will adjust to whatever the coding standard ends up being. That said…

I’m really surprised by how many tab supporters there are here. I don’t think I’ve ever run across another programmer who prefers tabs over spaces. I guess I can sort of see the appeal, but there’s not a lot of consistency between editors on how tabs are implemented and I think you’re just asking for trouble. With spaces, you always know how things are going to turn out. A space is a space. A tab is…well, whatever your editor decides it is.

Plus, in my experience, even if tabs are mandated you’ll still end up with spaces in your files. Why? The tab key is configurable in most decent editors, but the space key never is because you wouldn’t want it to be. You can make the tab key give you spaces, but you can’t make the space bar give you tabs, so stray spaces will always find their way in. (Unless maybe there’s an option to convert x spaces to tabs? This feature probably exists in some editors.)


#168

Gah, just look at the amount of comments in this blog post… Color of the bikeshed?


#169

‘What is the reason for wanting to use spaces? Can anyone explain?’

  1. You can’t get by without spaces.
  2. a mixture of tabs and spaces will inevitably lead to misaligned, hard-to-read code.
  3. you can get by without tabs: in fact, everything they do is really much better done by other means.

If you want to configurably reformat code to your personal preferences, it is much easier to set up one configurable reformating tool than the dozen or so different tools that will end up displaying code at some point. And that tool will handle not just indent level, but bracket placement, line length, and so on.

Repository code should be space-only, simply because it can’t be tab-only.


#170

That said, only a moron would use tabs to format their code.

tut tut! :slight_smile:

I work as a sub contractor and thus with several different clients. Each client has there own way of formatting its code, you can imagine my problems…


#171

thanks for all the code!!!


#172
  1. a mixture of tabs and spaces will inevitably lead to misaligned, hard-to-read code.

If tabs are used for indentation and spaces for non-indent alignment, that isn’t true. But what you’re really saying is that using tabs isn’t viable just because it’s a style decision. In which case, choosing a certain number of spaces for indent carries the exact same caveat.

The people arguing for tabs make explicit the benefit of editor display configuration. Personally, I’ve seen no text editor that can handle syntax highlighting and not something as simple as tab widths or space substitutions.

The people arguing for spaces make implicit the obstacle of a lack of editor display configuration. They should stop arguing about the benefits of spaces, which are none on the terms they’re talking, and discuss what tools they’re actually using and why.

The only thing more tiring than people talking over each other wrt tabs v. spaces is dealing with space-indented code.


#173

The chinese spammer makes more sense than Atwood.


#174

The really frustrating thing is when the IDE starts reformatting your code. Especially when it gets it wrong. I don’t know how many times I have had an IDE try to find tabs and starts creating weird tabs at 3 and 5 spaces. And it’s actually creating spaces! Argh. Just put it under the block above! Can’t you see the code? Why is your smart tabbing so stupid! Stop trying to reformat my code!

I get frustrated just thinking about it.

Stupid smart formatting :wink:


#175

A small experiment to see which is better.

Spaces:
if (!Array.prototype.reduce) {
Array.prototype.reduce = function(func, initial) {
var current = initial;
for (var i = 0; i this.length; i++) {
current = func(current, this[i]);
}
return current;
};
}

Tabs:
if (!Array.prototype.reduce) {
Array.prototype.reduce = function(func, initial) {
var current = initial;
for (var i = 0; i this.length; i++) {
current = func(current, this[i]);
}
return current;
};
}


#176

It seems, that there is absolutely no difference :slight_smile:


#177

Hey AftWood Every rule of KR nazi code writing guideline is there to make You Keep It Simple stupid - Greatest Man In The World (me of course)


#178

I’ve been guilty in the past of ‘cleaning up’ other’s code, but mostly only so when I’m amending it/updating it I can actually tell what the hell is going on, our production programmers use vi in Linux to write code and whitespace use along with everything else is extremely inconsistent.


#179

@John W: Can I work for you?


#180

orange you glad I didn’t say banana?