Spaces or Tabs?
(public topic in Programming)
Started by
Avatar
2 years ago
5 Comments
Jamsterson mentioned the ongoing argument of tabs vs spaces in the grupthink blog ( http://blog.grupthink.com/?p=32 ). Do you like to use tabs or spaces to indent your code?
Tags: programming, tabs vs spaces
1. |
|||
2. |
|||
3. |
Page 1 of 1
Topic Details
This topic was started by Avatar
on August 13th, 2006. 22 grupies have voted on one or more of the 3 answers.
Tags: programming, tabs vs spaces


Comments
For me, it entirely depends on the language whether I use spaces or tabs. For example: I usually use tabs for C/C++ and Java, but I usually use spaces for Lisp and Prolog.
This comment is primarily relevant for Java. For some reason, Sun standardized on 8 spaces per tab, but most IDE's come up with 4 spaces per tab by default, and since the indentation base is 4 spaces, that makes more sense for Java. This mishmash means that if you're debugging and you need to look at some Sun Java code, and you're settings are at 4 spaces per tab, everything goes nasty.
It's easier to avoid this entirely just by leaving the settings at 8 spaces per tab, and getting everyone in the team to use spaces to avoid this issue.
PEAR for PHP also insists on Spaces and not tabs:
From their Manual:
"Using spaces and avoiding tabs is the only way to ensure that a piece of code is rendered consistently in all editors and viewers. Many editors render tabs as 4 spaces, and a lot of editors, terminal programs and utilities render tabs as 8 spaces."
" In a community like PEAR where people use lots of different systems and editors, using tabs simply doesn't work. People will end up doing whitespace commits fixing rendering in their editor, while breaking it for others. With only spaces it will look the same to everyone."
Oops forgot the link:
http://pear.php.net/...vs-spaces.php
Tabs are the only way to go for any C/Java-style language. It isn't the distance that's important, it's the RELATIVE distance. And trying to copy/cut+paste code is a frigging pain in the butt with spaces... And if you end up having to enclose something inside another control structure, or take it out of one... ugh... just ugly.
Since they're neater, functionally superior, and quicker, tabs are definitely the way to go. :)