Live data from Hacker News

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

medium.com

61–70 of 124 posts

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

#61

Earlier quoted context omitted.

My other personal feeling is that it's easy to auto-check we aren't using tabs (just search for tabs, and reject if any are found). Depending on how you choose to format, it can be arbitrarily hard to check tabs are being used correctly. For example, many people want to do some space indenting, such as: void my_function(int arg1, int arg2, int arg3) { It's (I believe) impossible for a language-agnostic tool to know t…

Don't align. void my_function( int arg1, int arg2, int arg3, ... ) {

While I quite like that style, now you have to convince people to never align, before you can convince them to use tabs.

I've not seen any large public code-bases uses this style, so it's hard to know how well it works in practice. Do you know of any major projects with a 'no alignment' requirement?

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

#62

Earlier quoted context omitted.

My other personal feeling is that it's easy to auto-check we aren't using tabs (just search for tabs, and reject if any are found). Depending on how you choose to format, it can be arbitrarily hard to check tabs are being used correctly. For example, many people want to do some space indenting, such as: void my_function(int arg1, int arg2, int arg3) { It's (I believe) impossible for a language-agnostic tool to know t…

Don't align. void my_function( int arg1, int arg2, int arg3, ... ) {

I also like a rule that states that you either put all the parameters on one line, or each one on its own separate line, but never something in between.

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

#63
post #48
post #28

Earlier quoted context omitted.

or python, or rust.

Python doesn't care either way as long as indentation is consistent (though there's a common misunderstanding that Python cares). However PEP-8 specifies that code should be indented using 4 spaces and editors should be configured to render tabs as 8 spaces (likely to make mixed tabs & spaces really obvious). But PEP-8 also specifies that code should follow whatever is the coding standard in a given project. IOW, Pyt…

Well, python most certainly do care in the case when tabs and spaces are used inconsistently. In python2 you could even redefine tab width inline like https://gist.github.com/yxhuvud/2006599 .

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

#64
The biggest problem with the spaces vs tabs debate is that editor presentation is still tightly coupled to file persistence. Imagine an abstraction layer created so that developers might choose to see what they wished, yet have files saved in a standard format it might negate some of the issues people have.

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

#65
post #28
post #18

Earlier quoted context omitted.

Unless you're using golang,in which case gofmt will correct you. Hence the overwhelming consensus of the go row for tabs.

or python, or rust.

Using Python for 10+ years, never used tabs.

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

#67
post #64

The biggest problem with the spaces vs tabs debate is that editor presentation is still tightly coupled to file persistence. Imagine an abstraction layer created so that developers might choose to see what they wished, yet have files saved in a standard format it might negate some of the issues people have.

That sounds like a really complex solution to a kind of non-problem.

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

#68

Obligatory clip from Silicon Valley (Season 3): Tabs vs Spaces (Some potential storyline spoilers if you haven't seen Silicon Valley) https://youtu.be/SsoOG6ZeyUI

A vim user who prefers spaces to tabs but doesn't know about 'set expandtab'?

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

#69

Some IDEs will convert tabs to spaces when saving and the other way around when editing, so, while your approach is interesting, not really a proof of a majority choice. Also my beef is specially with people who don't use tabs in files like fstab, like beasts.

For standard levels of indentation, I get that tabs may be useful, but in /etc/fstab, I absolutely hate them – how many do you put if the individual elements vary in size? Always just one, resulting in e.g.

    this_is_a_long_linedefaults…
    shortdefaults…
with the following elements not aligning? Or however many are necessary to get things to align, which sort of destroys the semantic meaning?

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

#70

I'm curious, what's going on with C? I was surprised to see it as the only language other than Go (where tabs are enforced by gofmt) to dissent from the spaces majority.

Probably related to Linux kernel coding convention: https://www.kernel.org/doc/Documentation/CodingStyle

Quoted: Tabs are 8 characters, and thus indentations are also 8 characters.

Post reply on HN