Live data from Hacker News

Google Coder Analyzes a Billion Files to Find a Winner in Tabs vs. Spaces Debate

gizmodo.com

1–10 of 22 posts

Re: Google Coder Analyzes a Billion Files to Find a Winner in Tabs vs. Spaces Debate

#2
C++ Developer - must admit I used to use spaces, then switched to tabs.

This was for several reasons - firstly - makefiles will not be parsed correctly if you start using spaces rather than tabs, so it's a good habit to get into to use them elsewhere to save headaches. Secondly, almost every developer I've met will want to use a different amount of spaces for indentation. When using tabs they can set whatever they want using the text editor or IDE of their choice.

This is my line of thinking anyway.

Re: Google Coder Analyzes a Billion Files to Find a Winner in Tabs vs. Spaces Debate

#3

C++ Developer - must admit I used to use spaces, then switched to tabs. This was for several reasons - firstly - makefiles will not be parsed correctly if you start using spaces rather than tabs, so it's a good habit to get into to use them elsewhere to save headaches. Secondly, almost every developer I've met will want to use a different amount of spaces for indentation. When using tabs they can set whatever they wa…

js developer will tell you otherwise: "tabs will break npm"

the whole debate is futile. but as least you're on the right side :) go tabs!

Re: Google Coder Analyzes a Billion Files to Find a Winner in Tabs vs. Spaces Debate

#4
>> Should you use the tab button or five spaces when you're indenting source code?

Five? What sort of freak uses five?

And you should use the tab button, with your editor set up to insert four spaces instead of tab characters. This way display is consistent across editors, platforms etc etc

I must say I'm surprised at the result for 'C' on there, as I've never worked with a C programmer that used tabs.

Re: Google Coder Analyzes a Billion Files to Find a Winner in Tabs vs. Spaces Debate

#5
post #4

>> Should you use the tab button or five spaces when you're indenting source code? Five? What sort of freak uses five? And you should use the tab button, with your editor set up to insert four spaces instead of tab characters. This way display is consistent across editors, platforms etc etc I must say I'm surprised at the result for 'C' on there, as I've never worked with a C programmer that used tabs.

Agreed, except s/four/two/ :)

And except for those few language where strangely tabs are required, like makefiles :(

Re: Google Coder Analyzes a Billion Files to Find a Winner in Tabs vs. Spaces Debate

#6
post #5
post #4

>> Should you use the tab button or five spaces when you're indenting source code? Five? What sort of freak uses five? And you should use the tab button, with your editor set up to insert four spaces instead of tab characters. This way display is consistent across editors, platforms etc etc I must say I'm surprised at the result for 'C' on there, as I've never worked with a C programmer that used tabs.

Agreed, except s/four/two/ :) And except for those few language where strangely tabs are required, like makefiles :(

LOL. Always found two a little too dense personally.

And yeah, meaningful tab characters in Makefiles are a real sod...

Re: Google Coder Analyzes a Billion Files to Find a Winner in Tabs vs. Spaces Debate

#8
post #6
post #5

Earlier quoted context omitted.

Agreed, except s/four/two/ :) And except for those few language where strangely tabs are required, like makefiles :(

LOL. Always found two a little too dense personally. And yeah, meaningful tab characters in Makefiles are a real sod...

I guess that would depend on the density of the language - I prefer 2 for clojure / common lisp and 4 for C and python.

At the end, we're trying to optimize for readability, and the horizontal indentation needs to be more or less in harmony with how tight the code is vertically... for example, see this completely random and subjective selection from two of my projects:

    void consumeInput(gap * sudoku, inputQueue * q){
        unsigned short int x, y, i, data;
        input * ptr = q->head;
        q->head = ptr->next;
        x = ptr->x;
        y = ptr->y;
        data = ptr->data;
        free(ptr);
        if(!q->head)
            q->tail=NULL;

        if(DEBUG)
            fprintf(stdout, "%d %d %d:\n", x, y, data);
        x--;y--;



    (defn username-from-req [ring-request]
      (when-let [identity (:cemerick.friend/identity (:session ring-request))]
        (let [[[:authentications auths]
               [:current curr]] (vec identity)]
          (when (and auths curr)
            (str (:identity (auths curr)))))))

(My) C functions tend to be longer but with shorter lines, whereas with clojure, I end up writing denser functions with fewer lines with more meat, both in term of characters and semantics. Thus (again, for me), clojure looks better if lines are more "tight", and C needs more breathing space.

Re: Google Coder Analyzes a Billion Files to Find a Winner in Tabs vs. Spaces Debate

#9
post #6
post #5

Earlier quoted context omitted.

Agreed, except s/four/two/ :) And except for those few language where strangely tabs are required, like makefiles :(

LOL. Always found two a little too dense personally. And yeah, meaningful tab characters in Makefiles are a real sod...

We had people in the same team with the same differing opinions 15 years - we compromised on a coding standard of 3 spaces, and anything else looks wrong to me now.
Post reply on HN