Live data from Hacker News

Swift Style Guide by GitHub

github.com

1–10 of 52 posts

Re: Swift Style Guide by GitHub

#3
post #2

Lost me at "Tabs, not spaces." :p

Tabs beat spaces in every single way;

- only press a single key instead of tapping 2 or 4 times.

- alter their width within your IDE to suit your preferences.

- they are "designed" to intent a piece of text with unlike spaces which are "designed" to break words.

But use whatever you like as long as it's consistent :)

Re: Swift Style Guide by GitHub

#4
post #2

Lost me at "Tabs, not spaces." :p

Tabs beat spaces in every single way; - only press a single key instead of tapping 2 or 4 times. - alter their width within your IDE to suit your preferences. - they are "designed" to intent a piece of text with unlike spaces which are "designed" to break words. But use whatever you like as long as it's consistent :)

Yeah, consistency trumps preference.

Re: Swift Style Guide by GitHub

#6
post #2

Lost me at "Tabs, not spaces." :p

Tabs beat spaces in every single way; - only press a single key instead of tapping 2 or 4 times. - alter their width within your IDE to suit your preferences. - they are "designed" to intent a piece of text with unlike spaces which are "designed" to break words. But use whatever you like as long as it's consistent :)

> But use whatever you like as long as it's consistent

I would add "as long it's consistent with the codebase and the practices of the project"

Mixing tabs and spaces in a project is very unpleasant and changing one for the other wreaks havoc in the blame functionality

Re: Swift Style Guide by GitHub

#7
post #2

Lost me at "Tabs, not spaces." :p

Tabs beat spaces in every single way; - only press a single key instead of tapping 2 or 4 times. - alter their width within your IDE to suit your preferences. - they are "designed" to intent a piece of text with unlike spaces which are "designed" to break words. But use whatever you like as long as it's consistent :)

Spaces are more consistent than tabs. https://www.jwz.org/doc/tabs-vs-spaces.html

Re: Swift Style Guide by GitHub

#8
post #2

Lost me at "Tabs, not spaces." :p

Tabs beat spaces in every single way; - only press a single key instead of tapping 2 or 4 times. - alter their width within your IDE to suit your preferences. - they are "designed" to intent a piece of text with unlike spaces which are "designed" to break words. But use whatever you like as long as it's consistent :)

We really shouldn't get into this, but I can't help myself.

- Every single text editor that's come after notepad.exe has had automatic tab/space conversion. Pressing tab inserts N spaces, pressing backspace un-indents N spaces, etc.

- In some languages, this is not a feature. 2-character tabs, using two tabs to indent for alignment:

    var myVar = 1,
        otherVar = 2,
        anotherVar = 3;
Opened later in an editor using 4-character tabs:

    var myVar = 1;
            otherVar = 2,
            anotherVar = 3;
- {}[] and more aren't used for anything close to their original literary intent.

Re: Swift Style Guide by GitHub

#9
post #5

> Fewer debates about aesthetics Are you kidding? You just added one. De gustibus non est disputandum.

Dictatorial decree is a valid solution to some debates, especially the neverending ones. I actually think it's one of Golang's best features, having a built-in "go fmt" tool that automatically applies an opinionated style guide, which makes it so every single Go repo I find in the wild has code that's formatted in the manner to which I'm most accustomed.

Re: Swift Style Guide by GitHub

#10
post #8

Earlier quoted context omitted.

Tabs beat spaces in every single way; - only press a single key instead of tapping 2 or 4 times. - alter their width within your IDE to suit your preferences. - they are "designed" to intent a piece of text with unlike spaces which are "designed" to break words. But use whatever you like as long as it's consistent :)

We really shouldn't get into this, but I can't help myself. - Every single text editor that's come after notepad.exe has had automatic tab/space conversion. Pressing tab inserts N spaces, pressing backspace un-indents N spaces, etc. - In some languages, this is not a feature. 2-character tabs, using two tabs to indent for alignment: var myVar = 1, otherVar = 2, anotherVar = 3; Opened later in an editor using 4-charac…

Tabs should never be used for lining things up, for that very reason. In your example, you've stopped 'indenting' and started 'aligning'. And it's only 'working' because "var " % 2 == 0; other language keywords will screw that up.
Post reply on HN