Live data from Hacker News

Swift Style Guide by GitHub

github.com

21–30 of 52 posts

Re: Swift Style Guide by GitHub

#21

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 :)

I prefer tabs BUT ... don't you have to throw out any line-length requirements if you use them?

Nah just hard wrap at the line length.

Imagine everyone setting their preferred tab width and hard wrapping.

That'll be fun for looking at VCS diffs...

Re: Swift Style Guide by GitHub

#22
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 :)

Tabs beat spaces in every single way;

Spaces look the same in whatever application you might be using to view a source file, be it any number of random command line tools, or fully fledged IDEs.

Re: Swift Style Guide by GitHub

#23
post #15
post #9

Earlier 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.

Yup. Amazing in Go. At first I was all (Python-esque) spaces, not tabs! Not only have I come over to the tabs side, but...

IT NO LONGER MATERS!

`gofmt`being run on save changes the game, and ensures consistency without beating people about the head with it. I wish more language had this feature.

Re: Swift Style Guide by GitHub

#24
post #18
post #17

> 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.

If your editor doesn't do smart tabbing, I'm sorry for you. Not to mention that random trailing whitespace is just annoying.

Part of the problem is that Xcode (you know, the editor pretty much everybody will be using to write Swift) leaves blank lines indented. So to leave a blank line that doesn't have indentation, you press Return, and you get an indented blank line; you then need to press Backspace some appropriate number of times to get the cursor back to column 0; then you press Return.

(In Xcode's defence, the cursor is, then, at least indented.)

If you don't use Xcode, you might not realise how crap Xcode is.

Re: Swift Style Guide by GitHub

#27
post #24
post #18

Earlier quoted context omitted.

If your editor doesn't do smart tabbing, I'm sorry for you. Not to mention that random trailing whitespace is just annoying.

Part of the problem is that Xcode (you know, the editor pretty much everybody will be using to write Swift) leaves blank lines indented. So to leave a blank line that doesn't have indentation, you press Return, and you get an indented blank line; you then need to press Backspace some appropriate number of times to get the cursor back to column 0; then you press Return. (In Xcode's defence, the cursor is, then, at lea…

While this is the default behavior, you can, at least in Xcode 7.2, check "Automatically trim trailing whitespace" and "Including whitespace-only lines" under "Text Editing" in Xcode's preferences.

Re: Swift Style Guide by GitHub

#28

What does Github write that uses Swift? I thought they didn't have an iOS app and I figured their desktop app was some node-webkit or electron based thing based on it being 27mb download.

This actually left me more curious than any of the rules in the style guide.

Re: Swift Style Guide by GitHub

#29
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 :)

So setup your tab to insert four spaces, like every editor on the planet.

Re: Swift Style Guide by GitHub

#30
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 :)

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

Consider changing your editor.

Post reply on HN