Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

tabs vs spaces

 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
lowercase baba
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not saying I do this.
 
Sheriff
Posts: 3064
12
Mac IntelliJ IDE Python VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Source code steganography. That's evil.
 
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Saloon Keeper
Posts: 28064
198
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Greenhorn
Posts: 2
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 3064
12
Mac IntelliJ IDE Python VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I use Comic Sans. It's way better than Dingbats.
 
Bartender
Posts: 2407
36
Scala Python Oracle Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic