tabs vs spaces

Geek

When indenting source-code:

Tabs-only suck because it is usually not possible to align adjacent lines correctly. For example:

foo = bar(baz,
          quux);

Combining tabs with some number of trailing spaces (the Emacs default, IIRC) fixes the problem with tabs-only, but breaks again if someone uses a tab-width different than yours (an often-quoted feature of tab indenting). When this happens, source code looks very badly b0rked

So. There can be only spaces.

Here endeth the sermon.

Posted Tuesday, June 22, 2004 at 22:50.

TrackBacks

TrackBack URL for this post: http://volition.vee.net/mt/mt-idle-trackback.cgi/290

Comments

Praise be.

Posted by: Tim Riley on June 23, 2004 01:10 AM

Word.

I can't believe there are professional programmers who still don't grasp this.

Then, there's a lot of shit I can't believe there are professional programmers who still don't grasp*, and the list grows in ever-novel ways.

(* how's that for a fucked-up sentence? I need coffee.)

Posted by: Joel on June 23, 2004 09:31 AM

yuh.

those 'professional programmers' would be saying right now:

"grasp this".

Posted by: on June 23, 2004 07:07 PM

You are WRONG, you damn troll! :-)

You can mix spaces and tabs just fine, Mike.

You can use tabs to indent to the appropriate level of nesting, which allows flexibility to whoever reads the code in that they can adjust the tab size. After using tabs to indent to the correct level, you can then use spaces to line up with surrounding lines.

I don't understand what breaks when you do this?
It's only going to break if you want to line things up from different levels of blocks/nesting,

Do you do that?

Posted by: Dave Hill on June 23, 2004 07:54 PM

Yo Dave!

Do any tools actually support that style of indenting? Is it really worth the effort? Why not just use all spaces?

Anyway, even if you do go to *all* that effort, you still run into display inconsistencies as the display tab width differs from that which the original author used. Given there's there's no way to ensure the same width is used everywhere, it is best that the author be explicit about it in the first place.

Flame on! >:)

Posted by: Mike on June 23, 2004 09:33 PM

I don't know if you need any special tool. I use the tab key for tabs, and the space key for spaces. Simple!

I guess I can live with whatever as long as people don't use two-space indents, and are at least consistent! (ARRGH!)

As always, 'indent' is your friend when the formatting isn't to your liking.

Posted by: David Hill on June 23, 2004 09:57 PM

Why would anyone use an editor other than emacs, in a mode other than the one intended for the language, with an indent different to the default for that mode? I don't see the problem.

Posted by: Paul Hoadley on June 23, 2004 10:22 PM

> As always, 'indent' is your friend when the formatting isn't to your liking.

Amen, brother. Another guy and I nearly came to blows a few years ago... then we had a conversation/negotiation that consisted entirely of gradually-converging command-line arguments to 'indent'.

Posted by: Joel on June 24, 2004 10:10 AM

Actually, the hell with my conciliatory tone. I'm obviously some sort of pinko. Let's take it outside and settle it like civilised people - with Big Sticks.

Posted by: Joel on July 1, 2004 03:12 PM

My page mentions _all_ of the issues: http://farfetched.blogspot.com/2004/10/spaces-vs-tabs.html

Posted by: josh on January 6, 2005 09:57 AM

Add a Comment



(Optional)


(Optional)


Preview your comment before submitting.