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 :)
Swift Style Guide by GitHub
11–20 of 52 posts
Re: Swift Style Guide by GitHub
#12Lost 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 like you said, consistency matters a lot more.
Re: Swift Style Guide by GitHub
#13Earlier quoted context omitted.
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.
Re: Swift Style Guide by GitHub
#14Earlier quoted context omitted.
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.
Sounds to me like you're saying there's no objectively correct answer that works for all languages and situations, which I agree with.
In general, you should avoid aligning unless the readability gains are significant. Aligning things means that you end up re-aligning when you add or remove longer items. This increases maintenance and pollutes diffs (which also means code reviews and git logs).
Re: Swift Style Guide by GitHub
#15> 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
#16Earlier 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 :)
Spaces are more consistent than tabs. https://www.jwz.org/doc/tabs-vs-spaces.html
Re: Swift Style Guide by GitHub
#17Ugh. I wonder how is this a real issue?
Non-indented blank lines ARE an issue though - they make code editing more cumbersome, requiring pressing the tab key far more often.
Also, tabs are for bros.
Re: Swift Style Guide by GitHub
#18> Not even leading indentation on blank lines. Ugh. I wonder how is this a real issue? Non-indented blank lines ARE an issue though - they make code editing more cumbersome, requiring pressing the tab key far more often. Also, tabs are for bros.
Re: Swift Style Guide by GitHub
#19Earlier quoted context omitted.
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.
Yes, Swift should do the same thing. Format on save. So much time is wasted on style guides.
Re: Swift Style Guide by GitHub
#20Lost 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 :)
I use spaces and I still only hit a single key.