Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

tabs vs spaces

 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that could work well as long as you never had to think about what you were doing. In other words, if your editor understood the code and the scheme and sorted it all out for you regardless of whether you actually typed tabs or spaces. Otherwise you're almost certain to be inconsistent, and it's baseball time.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12196
35
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not saying I do this.
 
Greg Charles
Sheriff
Posts: 2993
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that's what I meant, but I also don't think it would work in real life. People wouldn't stay consistent with where they put tabs and spaces and so you'd end up with something that looked fine in one editor and terrible in another. In other words, the "both" situation for which someone would justifiably be beaten with fists, bats, or 2x4s, according to availability.

I like the idea Whitespace. Has anybody written code that does one thing when compiled with Java, and something else when compiled with Whitespace? Two interwoven programs in one file. It'd be like a Bach toccata!

 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Source code steganography. That's evil.
 
Jayesh A Lalwani
Rancher
Posts: 2756
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greg Charles wrote:

I like the idea Whitespace. Has anybody written code that does one thing when compiled with Java, and something else when compiled with Whitespace? Two interwoven programs in one file. It'd be like a Bach toccata!



If you look at this wiki page it contains links to example programs that are valid in multiple languages and produce the same output in all the languages. Some of the examples use Whitespace.
 
Tim Holloway
Saloon Keeper
Posts: 18303
56
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When my primary data storage facility was floppy disks holding maybe 88KB or so, I was a big believer in tabs. I use a LOT of whitespace in my code (steganograph THAT, sucker!).

However, these days, using tabs merely as a primitive form of compression is pointless. We have disk drives approaching the multi-terabyte range on ordinary home computers.

More seriously, God intended tabs to be located at stop points 8 characters apart. A decently-indented listing or XML file in most languages needs to be printed on half-meter wide paper to avoid ugly wrapping of text if your tabs are that wide. I prefer my indents more on the order of 3-4 characters width.

Then there's the whole Python thing...
 
Mark Ross
Greenhorn
Posts: 2
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I read through the whole discussion before weighing in. I use spaces exclusively and I set every editor I use to insert spaces for tabs. But, wait, there's more!

None of this will do my code one damned bit of good if I don't use a fixed width font for my code. Now, I'm sure this is all pretty basic to most of you, but I've run into programmers using proportional fonts in their editors and the only way they could get decent alignment was by exclusively using (ugh) tabs. I'm an old man and most of them were irritated when I explained their errors.

So, yes, use spaces AND fixed width fonts (yes, I know the font generally isn't stored with the code).
 
Greg Charles
Sheriff
Posts: 2993
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use Comic Sans. It's way better than Dingbats.
 
chris webster
Bartender
Posts: 2407
33
Linux Oracle Postgres Database Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Definitely spaces (with the IDE putting spaces in if I hit the tab key), for all the reasons already given, plus I'm learning Python, which also spares me all those arguments about curly braces on the same/next line after an if statement!

Anyway, tabs are a fossil relic of the days of typewriters, when it made no difference to your finished document how you got those spaces in there.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic