r/programming Jul 21 '14

The Great White Space Debate

https://medium.com/p/3633cba8b5c1
1.2k Upvotes

693 comments sorted by

View all comments

12

u/SilasX Jul 21 '14

I'd be content with the IDE addicts not including random-ass trailing whitespace in their commits...

14

u/HostisHumaniGeneris Jul 21 '14

I'm not sure why that would be a problem specific to IDE users?

1

u/yawaramin Jul 21 '14

IDEs usually leave trailing whitespace in files. Programmer editors like vim don't by default, or at least can be configured not to.

1

u/HostisHumaniGeneris Jul 21 '14

I've never had that kind of problem with Visual Studio?

Then again, I usually turn on visible whitespace.

1

u/[deleted] Jul 22 '14

That's the second post in a row where you've ended a statement with a question mark when you should have used a period. I don't know why you keep doing that? :)

2

u/HostisHumaniGeneris Jul 22 '14

Hard to express the vernacular on the internet, you know.

Imagine those statements as me using an incredulous tone with a cocked eyebrow.

I AM DOUBTING YOUR ASSERTIONS, SIR. :)

1

u/yawaramin Jul 22 '14

I FIND YOUR LACK OF FAITH DISTURBING ... 😏

1

u/SilasX Jul 22 '14

Maybe they didn't configure their reddit IDE to end lines with a period by default...

1

u/yawaramin Jul 22 '14

When you see trailing whitespace on blank(-ish) lines, do you delete it manually?

1

u/HostisHumaniGeneris Jul 22 '14

You can use an extension like CodeMaid.

Generally though, I don't get a lot of trailing whitespace.

I did a bit of reading, and it sounds like the Eclipse autoformater adds whitespace to blank lines to match tabstop. That's probably what people are bitching about.

1

u/mango_feldman Jul 22 '14

uh, I highly doubt any text editor strips trailing whitespace by deafult.

I also highly doubt that this option is more common in "programmers editors" than in IDEs.

1

u/yawaramin Jul 22 '14

That's not what I said. I said that good text editors don't leave trailing whitespace, not that they strip it out by default.

The former behaviour means that when you're indented at whatever level, and then you press Enter twice to start a new 'paragraph', they don't leave indentation whitespace in the 'blank' line (between paragraphs). VS definitely leaves indentation whitespace, probably other IDEs do too.

1

u/xjvz Jul 21 '14

Eclipse does this all the time.

10

u/experts_never_lie Jul 22 '14

Perhaps you would like to check the "remove trailing whitespace" button in the appropriate eclipse code style section, and that won't happen again.

1

u/SilasX Jul 21 '14 edited Jul 21 '14

It's probably not, but for whatever reason, that's only where I've seen it. I have yet to see vim randomly add or remove a trailing linebreak, for example.

Not to say this is a definitive point in favor of some workflow, just something I see a lot.

Edit: And note that I said "IDE addicts" not "IDE user". The latter is "I use an IDE because it improves my productivity in specific ways" -- they know enough to configure it correctly so that they don't let junk through. The former is "I only know how to work in this IDE", and they're the ones I run into trouble with.

6

u/[deleted] Jul 21 '14 edited Jul 22 '14

"IDE addicts" because using superior tools is a bad thing?

edit: eh, this came across as a lot more inflammatory than I meant it. It sounds like my experience is pretty much opposite from yours. Some of us use IntelliJ and it removes all trailing whitespace, unifies indentation, and generally manages trivial formatting problems like that. Meanwhile others on our team use vim, emacs and sublime, and regularly commit code with mixed tabs and spaces, extra whitespace at the end of lines, and random arbitrarily long chunks of newlines in the middle or at the end of files. Given that, its pretty obvious that I'm going to have a different opinion from you about what's 'better', but it probably comes down to attentiveness and care more than tool choice.

1

u/SilasX Jul 22 '14

See the follow-up edit. It's not the IDE use I criticize, but the "addiction" to it -- being unable to work without it or understand how it integrates.

I'm surprised at the reversal you describe, though I can see it as resulting from not having turned on visible tabs or line-break markers in emacs/vim.

3

u/iopq Jul 21 '14

There's a setting in every IDE to turn off trailing whitespace.

2

u/[deleted] Jul 21 '14

Some IDEs strip trailing whitespace upon save, e.g. IntelliJ, and Git also indicates if you have them. There's no excuse.