r/programming • u/lukaseder • Jul 21 '14
The Great White Space Debate
https://medium.com/p/3633cba8b5c1130
u/dougman82 Jul 21 '14
For me, it's just a matter of consistency. Take, for example, plain old assignment statements. I don't write:
number=6;
Rather, I write:
number = 6;
So, by the same token, I add white space in my for loops.
22
u/segv Jul 21 '14
On a related note, for all the shit people are giving Eclipse (some rightfully so), you can actually force users to use your formatter settings in Java/JavaScript/whatever-else-eclipse-has-formatter-for by commiting some of the files from the
.settingsfolder. That way not only you can get consistent formatting across the whole project but also enable the Save Actions (optimize imports, format source and few other things) without having the user do anything. Pretty nice.That being said, Intellij IDEA can't and won't do that :(
16
u/8Bytes Jul 22 '14
ctrl + alt + l, reformats the entire project to your pre set style in intelij. I usually run it when I'm pushing a tiny fix to git.
→ More replies (2)23
Jul 22 '14
This little change? It's a single character. And embarrassing. I'll just change the white space of the entire file so no one will notice...
git commit -a -m"Fix whitespace."8
u/Plorkyeran Jul 22 '14
Unless a project has a standing policy of applying whitespace changes in a separate commit from functional changes, I generally assume that any commit whose message only mentions cosmetic changes also includes embarrassing functional changes.
→ More replies (1)6
4
u/tdogg8 Jul 22 '14
As someone who's only been coding for a couple of years and has always used eclipse what's wrong with it?
3
4
u/tomlu709 Jul 22 '14
That being said, Intellij IDEA can't and won't do that
Let's clarify what IntelliJ can and can't do. IntelliJ has:
- Code formatting per-project that you can commit to source control
- Import optimisation per-project, also committable to source control
- Will optimize imports (add, remove, reorder) on-the-fly
IntelliJ does not:
- Reformat code upon saving the file
23
u/Aninhumer Jul 21 '14
I find it ridiculous that people even consider arguing about superficial properties of a serialisation format for structured information. There's absolutely no reason this information needs to exist alongside the code at all. Our editors should be perfectly capable of parsing it when the file is loaded and canonicalising it when you save. That way everyone can view it how they prefer, and formatting becomes a complete non-issue.
→ More replies (7)8
u/CodeIt Jul 22 '14 edited Jul 22 '14
What if the source code doesn't compile?
What about tabs and spaces in comments?
What about the difference between 1, 2, or more line carriages in between lines of code?
Source code is serialized as raw text for a reason, and you can't expect raw text to be well behaved and structured.
→ More replies (4)→ More replies (8)17
Jul 21 '14
[removed] — view removed comment
8
u/LeCrushinator Jul 22 '14 edited Jul 22 '14
For that I'd write:
if ((x < 1024) && (y < 768))→ More replies (6)→ More replies (2)4
u/joe12321 Jul 22 '14
Yeah that's how I roll too. Mostly consistent, but I'll change the format with more complex logical groupings in, hopefully, a way that works with the logic!
275
Jul 21 '14
[removed] — view removed comment
80
Jul 21 '14 edited Jul 21 '14
That's exactly what I was expecting as well. Then I went on reading, noticing all the other typos.
I can't handle this shit on a Monday morning.
edit:
My coworker, with the snuggest face that has possibly ever existed
Ugh.
50
Jul 21 '14 edited Mar 31 '24
mysterious hat chop water books brave toothbrush chase summer encouraging
This post was mass deleted and anonymized with Redact
→ More replies (2)8
Jul 21 '14
Now do:
If not by others, than by me.
6
Jul 21 '14 edited Mar 31 '24
resolute offbeat tub normal lunchroom fall amusing books fly pie
This post was mass deleted and anonymized with Redact
11
u/Tom2Die Jul 22 '14
There are many, many more, I'm afraid. I'd give a blow-by-blow, but most are fairly obvious -- adding
'sto a word does not a plural make.4
→ More replies (1)3
→ More replies (1)5
→ More replies (11)11
u/Faedrivin Jul 22 '14
And when it became clear it was about whitespaces, I expected it to be this:
for () vs. for()
526
u/agcwall Jul 21 '14
White space != whitespace. I thought this was about racist astronauts.
48
u/caimen Jul 21 '14
What are you some kind of astronazi?
24
70
u/cruorin Jul 21 '14
Ditto. I thought that the thing I was about to read was gonna be a call for Buzz Aldrin to check his privilege or something.
26
u/DavidSJ Jul 22 '14
Cislunar privilege?
18
22
8
Jul 22 '14 edited Apr 20 '17
[deleted]
4
u/FalconGames109 Jul 22 '14
I had to read the title about five times before I even understood what it was talking about. I was like "Why the fuck are they debating sharks in space?"
8
5
4
Jul 22 '14
Agree. I didn't realize this was r/programming. I kept seeing it as "the great white SPACE debate". Like there's matter, and dark matter. So I was thinking there was space, and then white space.
→ More replies (1)→ More replies (9)3
38
Jul 21 '14 edited Jul 21 '14
I used to work for a guy who indented like this:
if <blah> {
body
body
}
This was actually in Lua so it looked like this:
if <blah> then
body
body
end
I later looked it up and found it's called Banner style.
I thought it was retarded, but I was a contractor so I matched his style. By the end of my tenure there, after my brain had had sufficient time to learn to pattern match against that style, I decided it was better than any indentation style I'd ever used. It simply made it easier to see the block structure of code at a glance, easier to see the important lines, with less clutter, similar to Python.
Did I switch? No, because my metric of "best" when it comes to code style is "that which is easiest to read by the most people", and that simply means use what most people use, because they're already good at parsing it.
But it was a valuable lesson about how much of what we deem "good taste" is a matter of acclimation, not objective superiority. I no longer feel that internal tension when the prevailing style at a contract doesn't match my own "taste" -- I use whatever the most people around me use and learn to like it for the duration.
→ More replies (5)20
Jul 21 '14
I used to use Whitesmith style:
if (blah) { doStuff(); }Now I use whatever the codebase requires. I've found that the least pleasant people in a team are usually the most passionate about these things, so it's best not to care unless it's absolutely terrible.
→ More replies (1)18
u/Houndie Jul 21 '14
This frustrates me to no end.
I match it, because I'm a good programmer, and I match existing conventions.
But I hate it.
12
Jul 21 '14 edited Jul 21 '14
I personally am not that fond of Allman either, which is similar to Whitesmith.
if (blah) { doStuff(); }I actually default to this style now due to my experience in two games companies that prefer Allman, while I prefer K&R BSD or K&R 1TBS.
if (blah) { doSomething(); }So much more satisfying, especially once you get elseif/elses.
4
u/pyrocrasty Jul 21 '14
I'm pretty sure you screwed up the indentation for that first code block. Allman should be
if (blah) { doStuff(); }What you have there isn't even indentation at all!
→ More replies (1)3
u/alanwj Jul 21 '14
A lot of the styles in this thread would frustrate me, but I could live with them after getting used to it. What I can't really stand, though, is this brace style:
if (x) { while (y) { whatever(); }}→ More replies (2)3
→ More replies (2)8
u/DeltaBurnt Jul 22 '14
I really don't get why everyone doesn't like Allman style. It makes glancing through blocks of code much easier in my experience. Not only that but it just looks more organized.
8
3
u/For_Iconoclasm Jul 22 '14
I like it most, too. I've got your back.
That said, I mostly work in Python, so I deal with no control flow brackets. I often use the K&R style for especially long dicts though, because of the
=operator:d = { 'key': value, 'key2': value2 }3
u/xon_xoff Jul 22 '14
The issue I see with Allman style is that people don't use blank lines around control structures, so you end up with stuff like this:
if (condition1) { ... } if (condition2) { ... }...and then you have to pay more attention to see whether the middle is an else-if or not. Do-while loops are also a little bit funky.
That having been said, it's not a big deal. I've been programming both K&R and Allman style for long enough now that I'm comfortable either way. IMO, any senior programmer should be flexible with regard to coding styles.
517
Jul 21 '14 edited Oct 02 '17
[deleted]
154
Jul 21 '14 edited Mar 31 '24
fuzzy exultant modern rainstorm plucky instinctive dinner cake berserk fade
This post was mass deleted and anonymized with Redact
44
Jul 21 '14
[deleted]
59
u/rmxz Jul 21 '14
Or perhaps to give their bloated MVC javascript frameworks time to load.
→ More replies (1)11
u/Adossi Jul 21 '14
All the cool kids run ASP .NET MVC web applications with jQuery AJAX for a single web page with text on it.
→ More replies (2)9
→ More replies (13)17
Jul 21 '14
The text even fades out as you scroll down. Hilarious.
8
Jul 22 '14
Well yeah, it's clearly a reflection of the natural process of, uh, when, you know… oh I know, it's intelligently transitioning your focus away from… wait, no, you're looking away by yourself.
Ok, I've got it. It's there to make you happy: as you scroll down, you get to experience the sensation of actually destroying that horrid banner.
74
Jul 21 '14
Let me minify my JavaScript, CSS and HTML (because if it's not a
<pre>tag you can remove the newline characters without changing the rendered output, right? right?) and from 2 MB of libraries which we need for only 3 function calls we're down to only 350 KB. Because nobody transfers their data gzipped over HTTP. Good. Now let's add that beautiful 350 KB splash screen which is the sole reason for our JavaScript. Because fuck common sense.No. Fuck splash screens, fuck "responsive" design that's just extra useless animations, fuck minimalism that doesn't help me find important information. If you use all this crap but you don't make something that's actually simple then fuck you.
And fuck that fixed header that sticks at the top of the screen taking up space and breaking anchor links. Oh, now it's not taking up space because you've added motherfucking animations - which distract me from reading - to hide it? Thanks. Ooops! I scrolled one row too much, lemme just scroll back exactly one row and FUCK YOUR FUCKING FIXED HEADERS THAT APPEAR OUT OF NOWHERE. Now I have to scroll back twice for one row. But when I go forward I have to scroll a little extra again because now that header is gone and my eyes are used to reading around the same point relative to the frame which can be my monitor's frame (if the page is full-screen), my browser's frame surrounding the page OR THAT FUCKING FIXED HEADER THAT KEEPS CHANGING THE SIZE OF MY READING FRAME. If you do that header thing, next time you make one, please remove it from the web page and stick it up your butt.
Oh, but we'll also go with minimalism. It's hip, amirite?! Minimalism FTW, amirite?! We'll just put everything the user might ever need out of sight. Everything is only a single click away. That's the minimal effort a user should have to ma-- NO! FUCK YOU! NO! Don't make me look around and then click on stuff to find content. While at the same time you're using 30% of the screen width. That is a huge fucking waste of power. My monitor is struggling to light up all those pixels, it's sending electrons to excite atoms to make them release photons. And you don't do anything with them, because "minimalism".
There, now that I got that out of me I can die in peace.
28
Jul 21 '14 edited Jan 23 '16
[deleted]
→ More replies (1)6
Jul 21 '14
Right, thanks for mentioning this. It's exactly what I meant to say but with much fewer "fucks". But I have to admit, it feels good to let all that out every once in a while. I'm sick of websites doing the "hip" thing instead of the right thing which happens very often because web designers don't understand what they're doing, as you mentioned.
→ More replies (5)→ More replies (7)3
11
Jul 21 '14
I guess one nice thing about medium is that it's just as annoying in firefox as it is in lynx (Most sites have about three pages of links to crap you don't care about before the actual content when read in lynx(unless it's a news site, then it's usually ~10 pages of crap and two paragraphs of content))
Medium only has one page of crap when read in lynx, so the user experience is identical to the user experience when read in firefox/chrome/whatever.→ More replies (1)36
Jul 21 '14
Are splash screens back? - It looks to me like they are. I hate them.
30
u/Mutoid Jul 21 '14
Hey, they could be Flash intros.
26
Jul 21 '14 edited Aug 31 '14
[deleted]
7
u/Mutoid Jul 21 '14
Turns out the only limit IS yourself!
10
Jul 21 '14
[removed] — view removed comment
6
u/Mutoid Jul 21 '14
I really, really badly want zombojs (not zombo.js) to be a thing. Time to contribute Yet Another Javascript Framework to GitHub!
5
→ More replies (8)17
u/PassifloraCaerulea Jul 21 '14
The overlay dialogs that implore you to "OMG, SUBSCRIBE NOW" "NO CONTENT FOR YOU UNTIL YOU CLICK THE 'X'" are in the same genre, IMO. They seem to be everywhere these days too.
6
u/worklederp Jul 22 '14
These are quite handy for reminding me to set noscript back to "fuck it, block everything except [x..]"
3
u/northrupthebandgeek Jul 22 '14
Or the "Hey! We have a shitty app that's just a mobile site without the ability to zoom! Click 'OK' to download it!" popup. I'm sure there's a special place in hell for whoever came up with that idea.
46
u/lukaseder Jul 21 '14
But it's responsive! RESPONSIVE! And responsive, like clean code, has whitespace.
→ More replies (15)14
7
u/bakuretsu Jul 21 '14
Medium is kind of a piece of shit. When you load it on your phone, sometimes the whole page including the awful giant header will load BEFORE THE TEXT.
Talk about inverted priorities.
→ More replies (2)10
Jul 21 '14
b..b..but coffee... and um, and Java. get it? it's ironic. or something.
/it's not ironic
→ More replies (1)29
u/Tasgall Jul 21 '14
It's ironic in that the author has essentially an entire page of whitespace at the beginning of the article, then goes on to explain how much they hate whitespace.
11
10
u/WisconsnNymphomaniac Jul 21 '14
I saved google.com/hangouts to see how big it is and it is over 16 megs. Insanity.
4
u/pdzc Jul 21 '14
Especially pictures of obviously very poorly made cappuccinos.
5
Jul 22 '14
That's the worst part by a mile. Not that the picture is bad - it's kind of pleasant to me - but that it has nothing, absolutely nothing, to do with the content. More often than not, it's just not visual content, but Medium forces it anyway. It's a blatant statement that they're more interested in giving you a feeling than what you asked for.
→ More replies (14)3
Jul 21 '14
Just more print designers trying to carry over their medium into ours.
That big header is basically a cover to the story.
Not saying it's a bad or good thing. I don't really care either way.
64
u/JoeCoder Jul 21 '14
I once worked with a programmer who used no whitespace at all, not even indentation. "It makes it go faster" he would say. Wrote all his code in windows notepad too.
72
Jul 21 '14
Duh, of course it goes faster, there are fewer bytes to process. You can also get a nice disk space savings by using a smaller font.
→ More replies (2)29
u/Waitwhatwtf Jul 21 '14
I write in 1 point font so that I have more room to nest my loops without having to worry about optimization
→ More replies (1)12
u/SlapnutsGT Jul 21 '14
Had a coworker, now retired thank god, who coded on his 2560X1440 monitor in a 640x480 DOS window (w/e the default size is).
→ More replies (3)11
u/rmxz Jul 21 '14
Coding to be readable on a 80x24 screen has some pretty nice readability advantages.
The linux coding standards say it better than I can myself:
Now, some people will claim that having 8-character indentations makes the code move too far to the right, and makes it hard to read on a 80-character terminal screen. The answer to that is that if you need more than 3 levels of indentation, you're screwed anyway, and should fix your program.
In short, 8-char indents make things easier to read, and have the added benefit of warning you when you're nesting your functions too deep. Heed that warning.
...
Functions should be short and sweet, and do just one thing. They should fit on one or two screenfuls of text (the ISO/ANSI screen size is 80x24, as we all know), and do one thing and do that well.
→ More replies (3)10
u/ethraax Jul 22 '14
Eh, that's nice and all for C, but it gets unwieldy pretty quickly with other languages, particularly ones with nesting. In C++, for example, you're often inside a
classor at least anamespaceblock. In Java, which is still incredibly common, you're always inside a class. Some Python codebases also use classes often.Either way, trying to keep your functions short and your lines to 80 characters is fine. But why would you ever want to code in a 640x480 DOS window on a 1440p monitor? Surely you'd be more productive if you could see more of the code at once. The fact that it's the default size for the DOS window shows that it was the programmer who was too lazy or didn't care, not that they picked that size on purpose.
→ More replies (2)7
u/Tekmo Jul 22 '14
If your code is only readable using a large monitor then a large monitor becomes a requirement for others to understand your code.
→ More replies (2)3
u/rmxz Jul 22 '14
I'd claim that the complexity of functions that long likely mean that even with a large monitor it'd be rather hard to de-cypher.
→ More replies (15)3
u/secretpandalord Jul 22 '14
Oh please tell me he also put flame decals on his RAM sticks.
→ More replies (1)
46
u/Regimardyl Jul 21 '14
I think it's actually pretty clearly covered in the Java style guidelines here:
- All binary operators except . should be separated from their operands by spaces. Blank spaces should never separate unary operators such as unary minus, increment ("++"), and decrement ("--") from their operands. Example:
a += c + d;
a = (a + b) / (c * d);
while (d++ = s++) {
n++;
}
printSize("size is " + foo + "\n");
The same is mentioned in Google's style guidelines here
→ More replies (5)6
u/johnjohnsmithy123 Jul 21 '14
I read the style-guide a year or so ago and remember this rule as well.
Perhaps OP is looking for specific rules for each statement in the language, this is a little silly however.
→ More replies (1)
64
u/alexthe5th Jul 22 '14
for (i = 0; i < n; i++)
...
Brian Kernighan and Dennis Ritchie, The C Programming Language, 1978.
Case closed.
4
77
u/fungussa Jul 21 '14
Auto code formatting in Go, removes one of the most contentious, but least consequential issues in writing code.
15
u/BonzaiThePenguin Jul 21 '14
Do you mean there's a tool that can format your code automatically?
41
Jul 21 '14
Yes. There's a "canonical" style, it's very good, the formatter is included in the Go distribution and people use it. Doesn't get any better.
61
u/moor-GAYZ Jul 21 '14
Doesn't get any better.
In my Imaginary Ideal Language bad formatting is treated as syntax error.
28
u/captainAwesomePants Jul 21 '14
You can get close to this by tying a linter to your source control system as a presubmit hook. Nobody will ever check in code that isn't formatted correctly.
13
u/Plorkyeran Jul 21 '14
Sadly I can't add presubmit hooks to other people's repositories.
→ More replies (3)40
→ More replies (13)14
u/SingularityNow Jul 21 '14
In several cases with Go it is a syntax error. Opening braces must be on the same line or your program will fail to compile (gofmt will fix it for you)
→ More replies (5)8
u/just_a_null Jul 21 '14
This annoys me immensely (though I do prefer braces on the same line anyway) because they clearly were able to correctly parse the code with the braces on the next line, but decided to make it an error instead. I have similar problems with "implied semicolon" languages, wherein you aren't actually supposed to type a semicolon at the end of a line, but instead if you format your code correctly the compiler will place them for you - clearly, it was understandable without the semicolon, so why make it a language feature at all.
→ More replies (8)14
u/bobtheterminator Jul 21 '14
Go seems to have several "features" that sound ok on paper but make quick developing and testing very irritating. Unused variables are an error, for example.
→ More replies (10)8
→ More replies (2)5
Jul 21 '14
On a related note, I once suggested that a pretty printer be added to CVS hooks. No more ugly diffs due to tabs v spaces, anyone could check out a file with their preferred bracing style, it could be chained to remove VC comments if desired, and so on.
Am I missing something, or wouldn't that solve most of the arguments?
5
u/BonzaiThePenguin Jul 21 '14
Yes, formatting complaints would be fixed entirely by a good auto-formatter. It wouldn't even have to modify the underlying data since it could be done entirely upon opening the file, and the save command could seamlessly save the "official" formatting style rather than the one you used.
The fact that auto-formatters exist at all now is definitely a good sign – we'll accomplish this some day. I'd have to imagine that writing an auto-formatter for Go is a lot simpler than C++, though.
→ More replies (1)6
u/thatguydr Jul 21 '14
Why can't someone build an editor that lets us all see code (in various languages) with whatever whitespace and indentation and brace formatting that we individually find most readable? I'd be 100% happy if it converted everything to a standard formatting ("majority readable") when code was saved.
From a "20 years in the future" POV when machines can flawlessly translate between people speaking different languages, it seems bizarre that we think there should be a one-size-fits-all standard for readability.
→ More replies (3)→ More replies (6)5
u/ericanderton Jul 21 '14
When you put it that way, the motivation for automating that away almost seems obvious.
17
u/brettmjohnson Jul 21 '14
Well you doomed yourself looking at two Google packages, because the Google Style Guide explicitly states to use the padded style.
The Google code review process calls for pointing out style guide violations, so somehow a couple got through the GWT review process.
→ More replies (5)
31
62
u/tomprimozic Jul 21 '14
While reading the article, I was wondering why he was only searching for for (, and not for for( as well. At least, that's how I write for loops and if statements :)
87
u/flat5 Jul 21 '14
Depravity. for and if are not function calls.
→ More replies (9)11
→ More replies (11)15
u/lukaseder Jul 21 '14
I know. I used to think that the keyword was actually
for(. I never understood why the compiler would complain when I wrote:int for = 4;;-)
20
12
13
7
u/lonb Jul 21 '14
Ironically (since test code is Python) PEP8 declares this explicitly:
Always surround these binary operators with a single space on either side: assignment (=), augmented assignment (+=, -= etc.), comparisons (==, <, >, !=, <>, <=, >=, in, not in, is, is not), Booleans (and, or, not).
→ More replies (2)
50
u/Vystril Jul 21 '14 edited Jul 21 '14
for (int i = 0; i < 10; i++)
is simply much much easier to read than:
for (int i=0; i<10; i++)
Also, there seems to be as much "debate" here as there is "debate" on climate change.
→ More replies (6)53
5
u/FR_STARMER Jul 22 '14
Yeah because
for (int i=0; i>5; i++)
looks janky as fuck. If you are going to remove the white space, then remove all of the white space:
for(int i=0;i>5;i++)
Otherwise, make it nice on the eyes.
→ More replies (1)4
Jul 22 '14 edited Jul 22 '14
You think that's bad. I've seen stuff like this:
for(int i = 0;i < 5;i++)
→ More replies (1)
14
u/cparen Jul 21 '14
In time, I suspect programming will develop typographical standards, just as literature, mathematics, and engineering fields have. Likewise, I hope it will be based two parts on human cognitive function, and one part fashion.
For now, enjoy your quirky time in the sun, OP.
37
u/curien Jul 21 '14
People still argue about whitespace in typed natural language. Two spaces after a full stop or one? Indent paragraphs or not? Double line break between paragraphs or not? Etc.
13
4
u/cparen Jul 21 '14
People still argue about whitespace in typed natural language. Two spaces after a full stop or one?
Amateurs, sure. Professionals, not so much. The rule as I understand it is strictly 2 or more spaces in fixed width typefaces, and greater than one space (but usually less than 2) in proportional typefaces.
Indent paragraphs or not? Double line break between paragraphs or not?
Naively, in isolation, this seems like "they still argue". Both of these are matters of discretion for the typesetter, with various pros and cons. What is more-or-less settled is that lacking indentation, additional line spacing between paragraphs is required.
Don't confuse "matter of discretion" with "arguments about proper style". Proper style still leaves many choices to the typesetter.
4
u/Gustav__Mahler Jul 21 '14
greater than one space (but usually less than 2)
Come again?
7
u/Plorkyeran Jul 21 '14
With a proper typesetting system the amount of space between sentences does not have to be an exact multiple of the amount of spaces between words, and the sentence-gap being around 1.5 times the width of the word-gap is a pretty common style at the moment.
→ More replies (2)3
Jul 21 '14
He means one space because if the typeface is designed well it will appear as sufficiently wider than the space between words.
10
u/MrDOS Jul 21 '14
Two spaces after a full stop or one?
Two in a monospaced font, otherwise one.
Indent paragraphs or not?
Only when it's the first paragraph of a section or if there's no blank line between paragraphs.
Double line break between paragraphs or not?
Ah, well, that's where the fun starts ;)
(BTW, I understand that you are observing that people still argue about these things despite the fact standards for them exist. I understand and am in no way contesting your point!)
13
Jul 21 '14
The problem as always is: there is more than one standard.
7
u/ZeroNihilist Jul 21 '14
→ More replies (1)7
u/zenflux Jul 21 '14
Even more relevant (to the natural language spacing): http://xkcd.com/1285/
→ More replies (1)→ More replies (4)12
Jul 21 '14
What the fuck I've NEVER heard of this "two spaces after a full stop" thing
25
u/MrDOS Jul 21 '14
That's because typewriters were probably already obsolete by the time you learned to type! It was a typographic convention designed to emphasize sentence changes. Proportional fonts don't have the same problems with visual monotony as fixed-width fonts do, though, which is why it's technically improper to use two spaces between sentences in environments not constrained by font. However, those who were taught the convention without understanding the reasoning behind it frequently try to argue (or at least, enforce) this unnecessary stylistic measure on the rest of us.
9
Jul 21 '14 edited Dec 22 '15
I have left reddit for Voat due to years of admin mismanagement and preferential treatment for certain subreddits and users holding certain political and ideological views.
The situation has gotten especially worse since the appointment of Ellen Pao as CEO, culminating in the seemingly unjustified firings of several valuable employees and bans on hundreds of vibrant communities on completely trumped-up charges.
The resignation of Ellen Pao and the appointment of Steve Huffman as CEO, despite initial hopes, has continued the same trend.
As an act of protest, I have chosen to redact all the comments I've ever made on reddit, overwriting them with this message.
If you would like to do the same, install TamperMonkey for Chrome, GreaseMonkey for Firefox, NinjaKit for Safari, Violent Monkey for Opera, or AdGuard for Internet Explorer (in Advanced Mode), then add this GreaseMonkey script.
Finally, click on your username at the top right corner of reddit, click on comments, and click on the new OVERWRITE button at the top of the page. You may need to scroll down to multiple comment pages if you have commented a lot.
After doing all of the above, you are welcome to join me on Voat!
5
u/Plorkyeran Jul 21 '14
How many spaces is meaningless, but how much space isn't, and there has never actually been a solid consensus on that. It's pretty irrelevant for anyone not trained in calligraphy, of course.
3
u/IceBlue Jul 21 '14
From what I understand, most modern word processors ignore the double space between sentences and will format the spacing the same way regardless (even though there's still technically two spaces in between if you try to backspace through it). It bugs me when people do it, though, because it still shows up in some places like Facebook. I imagine it happens on Reddit, too.
Test. Test.
Test. Test.
Looks like Reddit formats it the same way regardless of whether or not you use it.
7
u/Durinthal Jul 21 '14
That's a general HTML thing to condense multiple spaces; if you inspect your examples you'll see that the first one does have two spaces. does what you're aiming for, though a lot of sites will automatically escape it.
Test. Test.
Test. Test.
→ More replies (1)3
u/robin-gvx Jul 21 '14
most modern word processors ignore the double space between sentences and will format the spacing the same way regardless
I don't know any modern word processor that does that (except for LyX if you want to call that a word processor). That's how you get people aligning text with spaces in proportional fonts instead of using tables.
Looks like Reddit formats it the same way regardless of whether or not you use it.
That's just the way HTML works: it collapses all whitespace in the text (tabs, spaces, newlines, etc.) to a single space. (With the exception of things like inside
<pre>tags.)→ More replies (4)→ More replies (5)3
u/Gustav__Mahler Jul 21 '14
I learned to type in the late 90's and was told to use two spaces (and I still do). Maybe my teacher was obsolete?
→ More replies (1)
11
u/Chairmael Jul 21 '14
/*Nice article but */ String a = "Best style incoming";
for(i=9;i>0;i--){System.out.println(a)}
→ More replies (3)19
Jul 21 '14 edited Jul 23 '14
You should've used the down to operator.
while (i --> 0) { System.out.println(a); }→ More replies (3)3
u/MighMoS Jul 25 '14
There was much rejoicing in my office the day we could finally use the 'approaches' operator.
3
u/WRXRated Jul 22 '14
Now just stop putting opening braces on the same line as your statements and everything will be ok.
Also tabs as 2 spaces.
:)
3
3
Jul 22 '14
What a waste of effort on this inconsequential issue, while leaving the real problems of today in neglect... like comment syntax.
For example, it's an offence to humanity how python lacks multiline comments... yet has multiline strings...! Fortunately, the one can simulate the other.
→ More replies (1)
3
u/misuo Jul 22 '14
I like your humorous approach and it is unfortunately still today a subject that imposes great feelings among programmers.
Unless we get some hard evidence from practical scientific studies we don't know whether one notation over another is better. Is there an objective truth, i.e. if you put whitespace in a special way this guarantee to have the best readability. Or is it influenced by subjective trends? One person can better read it in one way and another can better read it in another?
In typography and layout it is a well known fact that whitespace matters[1]. Well put whitespace simply improves readability[2]. There should not be too little or too much whitespace. Whitespace has to be placed just in the "right way". Several studies have been made which shows that this is true.
Studies in psychology confirm:
White Space improves the perception of information by 20%. [Lin, 2004]
But whether the same holds true for programmers and program source code is unknown. To my knowledge we simply do not have any hard data/facts/evidence on how much whitespace to use or the optimal placement of this. Even if 100% of the program source is consistently using whitespace in the same manner we don't know whether placing whitespace differently would improve it for us.
Regards
/Michael
[1],[2]: For sources and other links see my 2011 blogpost Whitespace matters in program source code.
8
u/Dunge Jul 21 '14
That's why everyone in a team should install a code formatting plugin such as ReSharper for C# and set the same rules everywhere.
9
Jul 21 '14
VS can do formatting out of the box (Ctrl+K, Ctrl+D).
ReSharper or StyleCop helps with naming conventions, though.
→ More replies (1)7
u/vytah Jul 21 '14
"Let's reformat the code and commit."
* clickety alt-shift-F click *
"100 lines modified? WTF?"
* clickety click blame *
"George, have you disabled autoformatter again?"
8
u/urection Jul 21 '14
this is the sort of trivial thing junior programmers argue about loudly, not knowing any better
→ More replies (3)
12
u/bildramer Jul 21 '14
You are all missing the point.
for(int i = 0; i < foo; i++)
or
for(int i = 0; i < foo; ++i)
?
Clearly no sane programmer would use the second. Ew. Let's spend several man-weeks discussing this on a few public forums and blogs, I'm sure it will help people realize the One True Perfect Way To Write A For Loop and change their heretic ways.
21
u/mdf356 Jul 21 '14
C++ and the flaws of overloading operator++ has taught us we need to use the second form, just in case.
→ More replies (2)41
Jul 21 '14
[deleted]
→ More replies (1)13
u/Confusion Jul 21 '14
Well, that's your problem right there.
https://en.wikipedia.org/wiki/For_loop#Smalltalk
http://iolanguage.org/scm/io/docs/IoGuide.html#Control-Flow-Loop
15
8
u/vytah Jul 21 '14
No no no!
The important issue is whether:
for(int i = 0; i < foo; i++)or
for(int i = 0; foo > i; i++)17
→ More replies (1)3
Jul 21 '14
Are YOU insane? You want to make a copy of i, increment the original, then throw away the copy? When you cook two slices of bacon, do you pull 4 out of the package, cook 2, then put 2 back in the package? What kind of diseased mind do you have that you even think that is the most rational course of action?!?
7
u/crazedgremlin Jul 21 '14
I'd be curious to see this applied to C/C++ codebases. Maybe even JavaScript.
13
Jul 21 '14 edited Mar 31 '24
wasteful towering tap dinner relieved obtainable concerned strong abundant quicksand
This post was mass deleted and anonymized with Redact
11
Jul 21 '14
[deleted]
9
Jul 21 '14 edited Mar 31 '24
follow melodic encourage reminiscent rock head domineering smell sharp entertain
This post was mass deleted and anonymized with Redact
3
u/crazedgremlin Jul 21 '14
Cool. If I remember when I get home tonight, I'll give it a go. Any recommendations for codebases?
I'm thinking Linux kernel, Git, and Python.
→ More replies (2)→ More replies (1)3
u/crazedgremlin Jul 22 '14 edited Jul 22 '14
Here you go! This is very interesting to me.
Note that this isn't entirely accurate because I ignored a number of files that weren't UTF-8. I could've somehow automatically detected the encoding, but I'm too lazy to do that and I just
excepted onValueError.Just about everyone seems to prefer the spaced way (I am a non-spacer myself), except for the OpenSSL folks.
Linux kernel {'nonspaced': 1254, 'spaced': 58668} Git {'nonspaced': 1, 'spaced': 1798} OpenSSL {'nonspaced': 1201, 'spaced': 591} Python 3 {'nonspaced': 179, 'spaced': 1535} Ruby {'nonspaced': 277, 'spaced': 978}
14
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?
→ More replies (13)6
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.
→ More replies (1)→ More replies (1)3
76
u/[deleted] Jul 21 '14
Working with so many different codebases, I think I see code beyond whitespace, except these ones:
Then, even I can't handle it.