USE TABS FOR INDENTION!
Why? Jeff likes indention of 2 spaces, I personally prefer 4, some prefer 8. Indention is a matter of personal taste. Why would you force your personal taste upon other programmers? That is moronic. Especially in a wold of open source projects with hundreds of programmers, why would a couple of people decide upon a style and force it upon so many other coders, no matter how much this style will hurt their eyes?
When using tabs, every not completely useless code editor allows you to configure how large tabs are on screen. You can make it everything from 1 to 16 spaces, whatever you like. The same piece of code, indented with tabs, can make a 2, 4 and 8 space indention fan happy, since it will have exactly that many indention within his/her favorite editor.
Also a space is just a space. When programming, you never know what meaning a space has in this file. A tab, when exclusively used for indention, has a meaning though. It means indent once and two tabs mean indent twice and so on.
I agree with Aram, though. If you must format (layout) something, use spaces. Why? Because you must not rely upon the fact that a tab is equally width for everyone in the world as it is for you. And an alignment that works nicely when tabs are 4 spaces breaks terribly when they are 2 or 8 spaces!
I always and exclusively code according to Cyrus’s 3rd option. I indent with tabs, that way everyone reading my code can have indention as big or small as pleases his/her eye. Nobody needs to like my style, change the config of your editor and have my code be presented in you favorite style. However, when I must align something, I cannot use tabs, so I use spaces. If you look at the Cyrus code sample in the post above… copy this to a file (and make tabs real tabs). Now change indention to 2 spaces, change it to 4, change it to 8. Indention changes each time, but the string is always nicely aligned below the int, isn’t it? If you make this example all spaces, you cannot change indention (you must read it, no matter how bad it looks to you). If you make it all tabs, changing indention width breaks the alignment and string won’t be aligned with int any longer. Using both does not give you the problems of both worlds as Jeff wrote, it gives you the BENEFITS of both worlds:
-
Have indention your way, whatever pleases your eyes
-
Have aligned text aligned, no matter how indention width changes.