wood burning stoves 2.0*
The moose likes Meaningless Drivel and the fly likes tabs vs spaces Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Other » Meaningless Drivel
Bookmark "tabs vs spaces" Watch "tabs vs spaces" New topic
Author

tabs vs spaces

Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4338
    
    7

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

Joined: Oct 02, 2003
Posts: 11150
    
  16

I'm not saying I do this.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2833
    
  11

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

Joined: Apr 06, 2010
Posts: 4338
    
    7

Source code steganography. That's evil.
Jayesh A Lalwani
Bartender

Joined: Jan 17, 2008
Posts: 2271
    
  28

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

Joined: Jun 25, 2001
Posts: 15950
    
  19

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...


Customer surveys are for companies who didn't pay proper attention to begin with.
Mark Ross
Greenhorn

Joined: Jul 02, 2012
Posts: 2
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

Joined: Oct 01, 2001
Posts: 2833
    
  11

I use Comic Sans. It's way better than Dingbats.
chris webster
Bartender

Joined: Mar 01, 2009
Posts: 1607
    
  13

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.


No more Blub for me, thank you, Vicar.
 
wood burning stoves
 
subject: tabs vs spaces
 
Similar Threads
XPATH vs tree parsing
Coding standards
tab vs. excape sequence "\t" in String interal
package vs inheritance
Formatting Java Code