Live data from Hacker News

Tabs or spaces – Parsing a 1B files among 14 programming languages

medium.com

31–40 of 124 posts

Re: Tabs or spaces – Parsing a 1B files among 14 programming languages

#31

I've never really understood why you would use several characters (=spaces) for something that is semantically one indent. Can someone enlighten me? What are the advantages of spaces over tabs?

With spaces you can position the cursor anywhere you want, with tabs you can not position the cursor in the middle of a tab.

Re: Tabs or spaces – Parsing a 1B files among 14 programming languages

#32
post #23

Now, can we look at the same repositories and look at the number of bugs and correlate it with the use of spaces? But in all seriousness, how often something is used isn't an indication of how good it is. Spaces are like cigarettes. Just don't start.

If spaces are cigarettes, then tabs are crack.

Re: Tabs or spaces – Parsing a 1B files among 14 programming languages

#35
I've always used spaces instead of tabs.

My rationale:

The number of readers of any document will normally be greater than the number of authors. We should give a slight preference for readability and ease of comprehension over writeability, and should certainly not require that our readers adjust their editor settings for each document that they peruse.

In addition, it is useful to use vertical alignment to group related content that spans multiple lines. Although this at least partly an aesthetic choice, and not without drawbacks, I believe that the benefits outweigh the costs.

I believe that it looks neater, improves readability and also makes some errors "pop" out in a way that they don't in unaligned content. I find the ability to visually group related terms and expressions particularly useful.

The downside is that you have to "tidy up" after using refactoring tools or after doing a search-and-replace operation.

However, I believe that this downside is mitigated due to the fact that the very tidying up that is required is a good way of eyeballing the changes and checking to make sure that they are OK.

http://williamtpayne.blogspot.co.uk/2012/04/spaces-over-tabs...

Re: Tabs or spaces – Parsing a 1B files among 14 programming languages

#36
post #19

Earlier quoted context omitted.

Most diff programs have an "ignore whitespace" option. "whitespace noise on diffs" is pretty much a solved problem. You can even add '?w=1' to a Github URL to turn on the feature.

1. That's a band-aid. The characters have still been changed - the diff still "exists". 2. Those options are not perfect, they don't always work as expected 3. Those options are not turned on by default (because that would be INSANE) 4. Git's not the only VCS, much as I wish it were 5. Github's not the only Git web UI; that option is not available everywhere. It's not a "solved problem". It's an artificial problem, t…

> It's an artificial problem, that gets solved when you start consistently stripping trailing whitespaces on save and not realigning everything all the time.

This is mostly solved via coding standards. If there are no coding standards people will "refactor" the coding style when they touch various pieces of code. If people were following a consistent style, then the alignment wouldn't be changing all of the time.

Although I strongly agree with the trailing whitespace sentiment. The most egregious offender that I've found is Eclipse putting trailing spaces on blank lines to bring them to the indent level of the non-blank lines. Ugh.

Re: Tabs or spaces – Parsing a 1B files among 14 programming languages

#37
post #8

I've never really understood why you would use several characters (=spaces) for something that is semantically one indent. Can someone enlighten me? What are the advantages of spaces over tabs?

def doSomething( parameter1 , parameter2 , parameter3 ): pass How would you make all the punctuation line up using tabs?

You don't, you use tabs for indentation and spaces for alignment.

Re: Tabs or spaces – Parsing a 1B files among 14 programming languages

#38

I've never really understood why you would use several characters (=spaces) for something that is semantically one indent. Can someone enlighten me? What are the advantages of spaces over tabs?

Things that are supposed to be lined up stay lined up even if they aren't at the start of a line - even if you:

* Use different tools - IDE, command line, version control tool, code review tool, e-mail client.

* Have code that follows with different conventions - because you participate in several projects, or because you've imported third party code that follows a different convention, or because the code is written in different languages.

* Have co-workers with different opinions about what tab width should be set to.

Personally I don't think there's that much value in vertically aligning things, except in lookup tables. Usually it's a sign you've adopted line-length rules that don't reflect modern monitor sizes, or that your methods have too many parameters. But some people seem to think it's valuable.

Post reply on HN