Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic

Spaces or Tabs?
Spaces  56%  [ 55 ]
Tabs  44%  [ 44 ]
Total votes : 99
Author Message
PostPosted: Sat Mar 24, 2007 1:38 am 
Offline
Linode Staff
User avatar

Joined: Tue Apr 15, 2003 6:24 pm
Posts: 3090
Website: http://www.linode.com/
Location: Galloway, NJ
For those coders/developers out there: spaces or tabs?

-Chris


Top
   
 Post subject:
PostPosted: Sat Mar 24, 2007 9:08 am 
Offline
Junior Member

Joined: Tue Aug 30, 2005 9:42 am
Posts: 29
Website: http://www.indiegigs.co.uk
Definitely spaces. It gives you more flexibility to line your code up, without having to mix tabs and spaces.


Top
   
 Post subject:
PostPosted: Sat Mar 24, 2007 11:06 am 
Offline
Senior Member

Joined: Thu Sep 23, 2004 8:35 pm
Posts: 73
Location: The Hague, Netherlands
I was a 4-space softtab (my ~/.vimrc had sts=4) until I read the coding style guidelines from some guy named Linus Torvalds:

Quote:
Chapter 1: Indentation

Tabs are 8 characters, and thus indentations are also 8 characters. There are heretic movements that try to make indentations 4 (or even 2!) characters deep, and that is akin to trying to define the value of PI to be 3.

Rationale: The whole idea behind indentation is to clearly define where a block of control starts and ends. Especially when you've been looking at your screen for 20 straight hours, you'll find it a lot easier to see how the indentation works if you have large indentations.

Now, some people will claim that having 8-character indentations makes the code move too far to the right, and makes it hard to read on a 80-character terminal screen. The answer to that is that if you need more than 3 levels of indentation, you're screwed anyway, and should fix your program.

In short, 8-char indents make things easier to read, and have the added benefit of warning you when you're nesting your functions too deep. Heed that warning.

...


Read the rest of the very short document at http://pantransit.reptiles.org/prog/CodingStyle.html

Cliff


Top
   
 Post subject:
PostPosted: Sat Mar 24, 2007 4:55 pm 
Offline
Newbie

Joined: Fri Mar 16, 2007 12:40 pm
Posts: 3
Location: Montreal, Canada
Same here, I use vim with the space option, more flexible and from what I know, using tabs may be a problem in some languages.

c1i77 wrote:
I was a 4-space softtab (my ~/.vimrc had sts=4) until I read the coding style guidelines from some guy named Linus Torvalds:

Quote:
Chapter 1: Indentation

Tabs are 8 characters, and thus indentations are also 8 characters. There are heretic movements that try to make indentations 4 (or even 2!) characters deep, and that is akin to trying to define the value of PI to be 3.

Rationale: The whole idea behind indentation is to clearly define where a block of control starts and ends. Especially when you've been looking at your screen for 20 straight hours, you'll find it a lot easier to see how the indentation works if you have large indentations.

Now, some people will claim that having 8-character indentations makes the code move too far to the right, and makes it hard to read on a 80-character terminal screen. The answer to that is that if you need more than 3 levels of indentation, you're screwed anyway, and should fix your program.

In short, 8-char indents make things easier to read, and have the added benefit of warning you when you're nesting your functions too deep. Heed that warning.

...


Read the rest of the very short document at http://pantransit.reptiles.org/prog/CodingStyle.html

Cliff


Top
   
 Post subject: Spaces!
PostPosted: Sat Mar 24, 2007 6:20 pm 
Offline
Senior Member
User avatar

Joined: Sat Mar 24, 2007 6:09 pm
Posts: 59
Location: South Africa
Definitely spaces. Makes the code look the same in every editor you edit with and you don't have to mess with setting tab stops first.

I have much respect for Linus Torvalds, but his guidelines are for use in the Linux kernel, and using C as the language.

Also, the editors I use all have indentation highlighting (dotted lines, or whatever) to enable very quick and easy distinction of code segments.

--deckert


Top
   
 Post subject:
PostPosted: Tue Mar 27, 2007 3:03 am 
Offline
Senior Member
User avatar

Joined: Wed Jan 24, 2007 12:04 am
Posts: 90
Website: http://www.smiffysplace.com
Location: Rural South Australia
Until recently, I have used tabs, but am beginning to move to spaces a) because other people are now looking at/using my code b) it is specified for Drupal module contributions and c) when I have about 10 levels of indent, it's nice not to have to everything wrapping to the next line.

And I use vim, BTW.


Top
   
 Post subject:
PostPosted: Tue Mar 27, 2007 9:27 am 
Offline
Senior Member
User avatar

Joined: Tue Apr 13, 2004 6:54 pm
Posts: 833
Spaces, because TABs may not cut'n'paste properly so code can end up as a mixture of both.

(Yes, this can cause problems with sendmail and syslog which use TAB as the seperator....)

_________________
Rgds
Stephen
(Linux user since kernel version 0.11)


Top
   
 Post subject:
PostPosted: Tue Mar 27, 2007 4:39 pm 
Offline
Senior Member
User avatar

Joined: Wed Mar 17, 2004 12:35 am
Posts: 118
Website: http://www.necrobones.com/
Location: Sterling, VA
Tabs all the way, because I add code more than anything else, and it's simply faster and easier. On the occasion that I need to cut and paste (not often since I usually yank and paste in vi), I just use a regex to re-tab the lines.

I agree with Mr. Torvalds on this one, and I don't have the 80-column problem since I use a minimum of 120 columns in my terminals, often more. :)

_________________
----
Ed/Bones.


Top
   
 Post subject: spaces it is
PostPosted: Wed Mar 28, 2007 3:45 pm 
Offline
Senior Newbie

Joined: Wed Dec 07, 2005 10:57 pm
Posts: 17
Location: Philadelphia, PA
I do most of my coding in python, where the mixing of tabs and spaces causes havoc, and the majority opinion points toward spaces.


Top
   
 Post subject:
PostPosted: Sun Apr 08, 2007 6:04 am 
Offline
Senior Member

Joined: Sat Jun 05, 2004 12:49 am
Posts: 333
Tabs only.

Nothing is more aggravating then having to delete individual spaces to make things readable when a single stroke to remove that tab would be quicker.

That and tab is one keystroke :)

And no I'm not using those spawns of Satan called vi or emacs or any of their bastard children like vim


Top
   
 Post subject:
PostPosted: Thu Jan 24, 2008 3:03 pm 
Offline
Senior Newbie

Joined: Sat Jan 19, 2008 8:37 pm
Posts: 19
I use tabs exclusively at the beginning of each line and spaces to align code at any point after the first non-tab character. The advantages of tabs at the beginning of a line are being overlooked in this thread, i think. The size of a tab can be redefined so when you are reading code that is indented umpteem times, you can set it to 2 or 3, and when reading code that doesn't use many blank lines, you can increase it to 8 or so to speed up visual scans of code. As long as you use the spaces to format tables or arrays or etc. then you won't get the wierd unaligned column problems that often accompany resizing tabs.


Top
   
 Post subject:
PostPosted: Thu Jan 24, 2008 3:41 pm 
Offline
Junior Member

Joined: Tue May 25, 2004 2:21 pm
Posts: 20
Location: Newnan, Georgia
I've been programming mostly in straight C for 28 years and the answer is spaces, spaces, spaces...

EXCEPT you sure better be careful on those hand full of ascii configuration files (makefile is probably the best example) that require tabs only for white spaces. I shutter to think how many total man hours have been lost through the years due to this one issue.

Hal Williams


Top
   
 Post subject:
PostPosted: Thu Feb 21, 2008 11:47 pm 
Offline
Senior Newbie
User avatar

Joined: Thu Feb 21, 2008 11:40 pm
Posts: 7
AOL: matt@lonelyvegan.com
I prefer tabs, but I can deal either way. In Python I used to use spaces more, but now it's mostly tabs.

I hate it when they get mixed. Ewwww...


Top
   
 Post subject:
PostPosted: Fri Oct 03, 2008 8:28 am 
Offline
Senior Member

Joined: Thu Oct 02, 2008 8:56 am
Posts: 99
Spaces.

I use two spaces for most things.
I use four for php - but I usually write php in a nice gui editor (bluefish) - in vi in a 80 character wide xterm, 2 spaces is plenty.


Top
   
 Post subject:
PostPosted: Fri Oct 03, 2008 9:06 am 
Offline

Joined: Tue Jul 15, 2008 9:32 pm
Posts: 1
Location: Manchester, UK
spaces, definitely spaces.

my ${HOME}/.vimrc uses a 4 spaces soft tab stob. which in my opinion works a lot better than a tab :)


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group