Live data from Hacker News

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

medium.com

71–80 of 124 posts

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

#71

I couldn't care less about this, and I generally feel out of place when other programmers ask me about my preferences on this topic. I have written code in different programming languages, and just naming Go and PHP where Tabs and Spaces are the standard respectively — PHP mostly because of PSR — I simply don't pay attention to the character(s) used for the indentation, the tooling already does that for me, being gof…

Completely unrelated. Noticed you use Vala. Just curious, how do you find it? Do you just use it for GNOME related things (GUI building) or for other cases as well?

Remember being interested in it a few years back. It seemed to be popular, but haven't followed it since.

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

#73

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?

Semantically, the TAB character means something like "insert a pseudo-random number of spaces here" with that number often defaulting to some ridiculous value like 8.

I keep my programs less than 80 character wide for accessibility purposes but if I use tabs then the width is unpredictable.

Also, spaces are universal and trivial whereas the TAB button in many editors has strange behavior.

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

#74
I've been learning Go in my spare time. One of the things that I've found really refreshing is how the enforced conventions largely eliminate contentious discussions like tabs vs spaces.

For those unfamiliar with Go, the gofmt tool[1] converts indentation to tabs, standardizes brace positioning, etc. Most editors have a plugin that will automatically run the tool on save. An option for programmers using other languages is EditorConfig[2].

[1] https://blog.golang.org/go-fmt-your-code

[2] http://editorconfig.org/

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

#75
post #12

After 20+ years of listening to the tabs-vs-spaces debate and considering all the legitimate points that both sides have, many have made the following observation and it's what resonates with me the most: In an ideal perfect world, _all_ of programmers and _all_ text editor tools would use tabs specifically for indentation and spaces specifically for alignment. But, we don't live in that perfectly coordinated world s…

I came to this conclusion too after at least 20 years of using tabs; but mostly it was because of moving to white-space significant languages like Haskell, F#, etc. It was just too painful getting everything lined up with tabs and I needed the fidelity of spaces.

Previous to that with C/C++/C# the alignment usually took care of itself through the closing brace and IDE auto-formatting. So tabs was the natural unit of currency there.

Horses for courses I guess.

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

#76

Earlier quoted context omitted.

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.

I don't think blindly following any convention is good. Sometimes it makes sense to group a few parameters, take this toy example for instance:

    void drawrect(
        Surface *surf,
        int x, int y,
        int width, int height,
        uint32_t color);
Grouping relevant arguments just makes it a bit more legible. It's even more useful when calling the said function (assuming function with a lot of parameters, say XCreateWindow).

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

#78

I would like to know If they are people who have 'switched'(coded with spaces and then use tabs or revers)?

I have, I mentioned it in my comment above [1]. It's not too long, so I'll paste it again:

"I came to this conclusion too after at least 20 years of using tabs; but mostly it was because of moving to white-space significant languages like Haskell, F#, etc. It was just too painful getting everything lined up with tabs and I needed the fidelity of spaces.

Previous to that with C/C++/C# the alignment usually took care of itself through the closing brace and IDE auto-formatting. So tabs was the natural unit of currency there."

https://news.ycombinator.com/item?id=12398432

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

#79
post #27
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.

Go's adoption rate would be quadrupled if they had chosen spaces instead of tabs. It's a fact.

Fact? My team is using Atom, VS code, IntelliJ and vim-go for Go. There has never been a problem with tabs vs spaces. On save gofmt converts all spaces to tabs and when I open Go files in vim-go it converts them to spaces according to my settings. Same for all other editors, whether you like tabs or 7-space indent.

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

#80

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 re…

Hey, a rationale, something I seldom see in those debates :) I think that if you do want to align, spaces are unavoidable. But I want to reiterate three points against alignment: - Alignment creates a maintenance burden. It has to be updated whenever you touch unrelated lines, which creates whitespace noise. - Some types of alignments (specifically, method parameter alignment) create extreme horizontal noise. See for…

> - Some types of alignments (specifically, method parameter alignment) create extreme horizontal noise. See for yourself: https://github.com/pennersr/django-allauth/blob/c9b31ddee81d....

The answer there would be to put the line break before the . and align the .dispatch under super.

Post reply on HN