tabs versus spaces

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
koen.h
Forum Contributor
Posts: 268
Joined: Sat May 03, 2008 8:43 am

tabs versus spaces

Post by koen.h »

Is there a reason why you use one and wouldn't like the other?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: tabs versus spaces

Post by RobertGonzalez »

Are you trying to start another T vs S flamewar? :roll:

This is one of those "vi" vs "emacs" discussions. Search around. I think we have talked about this before around here.
koen.h
Forum Contributor
Posts: 268
Joined: Sat May 03, 2008 8:43 am

Re: tabs versus spaces

Post by koen.h »

I am not starting another war. I just happened to read that tabs in some programs give problems. I was looking for other problems or aruments for/against. I'm not aware this discussion causes flamewars but I'm aware answers like yours don't encourage polite responses.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: tabs versus spaces

Post by RobertGonzalez »

I apologize if my answer did not come across politely. I have seen enough "OOP" vs "procedural", "vi" vs "emacs" and "tabs" vs "spaces" fights break out around here that I attempt to prevent them at the first sight of one.

My response was not an attempt at being mean, rude or confrontational. To the contrary, I am trying to prevent those types of responses from even being posted.

As to the core of your question, what have you heard? I have not heard of spaces causing problems before, except in the case of version control systems that show edits made when tabs are converted to spaces and vice versa.
koen.h
Forum Contributor
Posts: 268
Joined: Sat May 03, 2008 8:43 am

Re: tabs versus spaces

Post by koen.h »

Ok, I just don't like being called a troll when I have no intention to.

The problem was that some program messed up tabs. I can't remember what exactly it was but it may have to with layout. I consider switching to spaces for another reason too, being it seems easier to align things like long arrays or method chains. A disadvantage could be that it increases file size (maybe not much but everything counts).
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: tabs versus spaces

Post by RobertGonzalez »

koen.h wrote:Ok, I just don't like being called a troll when I have no intention to.
Fair enough.
koen.h wrote:The problem was that some program messed up tabs. I can't remember what exactly it was but it may have to with layout. I consider switching to spaces for another reason too, being it seems easier to align things like long arrays or method chains. A disadvantage could be that it increases file size (maybe not much but everything counts).
Many programs can be configured to handle tabs as spaces and vice versa. There are some folks that love an 8 space equivalent tab, others, like me, prefer a tab that is equal to 4 spaces. Others that I know use a 3 space tab.

I know there was a huge discussion about this topic about a year ago. The discussion was remarkably amicable and both sides of the argument for/against provided some very good reasons why you should/shouldn't use tabs/spaces.

I have never heard of a tab character screwing anything up. At least not in PHP, HTML, CSS, etc. I know there are some pretty strictly typed languages where white space has meaning. I am sure in a language like that a tab could knacker some stuff up pretty good.
Post Reply