Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

So, word wrap? This is the same stupid argument that pro-spaces people make in the tabs-vs-spaces argument - that you have to use spaces (or hard line breaks) so that you can force your ideal indent size (or line length) on other people.

Just accept the other people have different preferences, and tabs and soft word-wrapping enables them to use their preference. If you don't then you're being selfish really.



You cannot align things on different lines with soft tabs. If you really need to change the indentation, you could always do it based on spaces (not that I have seen any editors capable of doing it) - again, you will mess up the alignment.

I completely agree with the soft wrapping of emails though.


That is correct, you can't align things on different lines with soft tabs. So don't do it! When using tabs, only use them for semantic indentation, not for alignment. In most cases, to align things: enter a newline character, tab-in the same number of tabs as the previous line, then add spaces to align. This is the one true correct way because it allows anybody to use any size tabs imaginable and still works without breaking alignment.

Unfortunately, the world is full of people who don't understand this, so when tabs are used, they are used incorrectly (for alignment). Therefore, the one truerest way is (unfortunately) spaces for both indentation and for alignment. I've come to accept this non-ideal solution as a consequence of the wonderful but imperfect nature of Humanity.


enter a newline character, tab-in the same number of tabs as the previous line, then add spaces to align.

That method is broken unless we also agree on a tab width, in which case we may as well use spaces anyway.


I suggest you try it. Here is an example file [1]. Try adjusting the tab size: you'll find the arguments are always aligned. I like to set vim's listchars with the UTF-8 light shade and medium shade blocks to make tabs visible. Here are screenshots with ts=4 [2] and with ts=16 [3].

[1] http://sprunge.us/AOGg

[2] http://i5.minus.com/iu14dVi9QRTri.png [3] http://i4.minus.com/itno9LlgJobQD.png


I see the confusion. For aligning function call arguments your strategy works fine. Here are a couple use cases that don't work out so well with tabs (taken from the Jalopy manual [0] to make finding examples easy):

function declaration (most people would accidentally use too many tabs here):

    public void severalParameters(String one, int two, String three,
                                  StringObject four, AnotherObject five) {
        ...
    }
assignments:

    String        text  = "text";
    int           a     = -1;
    History.Entry entry = new History.Entry(text);
Ultimately the problem with mixing spaces and tabs in one document is that programmers are human. Someone will inevitably make a change to the lines you've carefully indented and mess up the whitespace, and someone else will have to go back to fix it in a dummy commit. Having a simple rule that's easy to follow eliminates that source of wasted effort.

[0]: http://jalopy.sourceforge.net/existing/manual.html


The strategy works perfectly fine for those examples.

    	public void severalParameters(String one, int two, String three,
    	                              StringObject four, AnotherObject five) {
    		// No problems here. It's just like my example.
    		// We're two levels of indentation in for these comments.
    		// The argument list continuation was at 1-level indentation with spaces for alignment
    	}
For these assignments, anything to the left is a semantic indentation (tabs), the rest is all alignment (spaces).

    	String        text  = "text";
    	int           a     = -1;
    	History.Entry entry = new History.Entry(text);


Sure, you can make it work. By point is just that you're introducing a burden making people remember which whitespace to use in which context. At that point you're forcing your devs to show non-printable characters in their editor to get it right. You devs are now spending their time checking whitespace instead of writing code, which is lost productivity.

As with any coding standard, the point of the rule is to eliminate such sources of lost productivity.


What things are you aligning on different lines? Are you stuffing spaces between variables and assignment operators "a = 1"?

Don't do that. It looks ugly on my tab-indented, proportional font display.


Usually, it's argument lists that need aligning.

I personally hate aligned assignments. I find it very sloppy. But yes, that is what you would do if you so wanted aligned assignments.

Using only tabs, you cannot do aligned assignments unless you are able to set specific tab stops per line. If you disagree, I can provide an assignment example that breaks tabs. While per-line tab stops might be possible, the overhead of maintaining tab stops vs not using aligned assignments is not worth it.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: