Live data from Hacker News

Developers who use spaces make more money than those who use tabs

stackoverflow.blog

621–630 of 690 posts

Re: Developers who use spaces make more money than those who use tabs

#621
post #452

Earlier quoted context omitted.

> "whatever my editor sets it to". Whats wrong with this? I just accept the defaults. Whether that is what the current project demands or what the editor defaults to. Why waste my time over these things?

> Whats wrong with this? I just accept the defaults. Whether that is what the current project demands or what the editor defaults to. There's your answer: if letting your editor do whatever and not caring to 'waste time over these things' means you've committed a bunch of code ignorant of the convention respected by the rest of the project, that's not that great.

Frankly, if over 90% of your peers are using a given editor/ide, odds are they're using the defaults... as trying to get everyone to change the defaults is painful. Having spent years fighting this in some environments, it's far easier to accept.

If your editor supports a common config format (.editorconfig), then use that... if you're all using the same IDE, then best to adapt to the defaults (mostly).

Re: Developers who use spaces make more money than those who use tabs

#622
post #429
post #314

Earlier quoted context omitted.

Using tabs has the opposite of your intended effect: If there is any text which is vertically aligned beyond the first indent, then this alignment will break for anyone who doesn't have your tab width preference. They're then forced to change their editor settings to view your file in a non-broken way. I get way more pissed about someone else "forcing their preferences on me" when this happens than when I run into a…

I always see this brought and wonder, what are people vertically alogning, and why? I generally see vertical alignment as an anti-pattern that makes it harder to change code.

"that makes it harder to change code".

Hm,... that could actually be a feature! Adding inertia. Not that I would use that, but it makes me think..^^

Re: Developers who use spaces make more money than those who use tabs

#623
post #343
post #207

Earlier quoted context omitted.

> when another developer looks at the code, their IDE will render the tabs as whatever its set up for, 2 spaces, 4 spaces, etc. This is an argument I hear often from tab proponents. What it misses out is the downside: my IDE has a certain arrangement on my screen, and I'll either have to invoke horizontal scrolling or I'll have a bunch of wasted space if you are using different size tabs from me. This is far from fle…

> Further, the only sensible screen width is 80 characters, since that also works everywhere. I'm curious. Where does 80 characters not work now? How many people / industries are still using green-screen terminals with a fixed-width of 80 characters? I'm generally in favour of enforcing line-wrapping requirements, because I've worked with people that would have a tendency to write code that trails off the end of the…

> But I haven't seen a good argument for 80-character line limit other than "that's the way it's always been done."

Having shorter lines makes reading diffs easier (whether it's unified, context, or split diffs).

> The "official/accepted" git commit message format limits the commit message title to 50 characters, and the message body to ~80 characters.

It's actually 72 characters for the commit message body for a similar reason that you mentioned for emails. Specifically, it's because the git log output indents the commit message relative to the diff (when using the -p option).

Re: Developers who use spaces make more money than those who use tabs

#625

= Why Grown-Ups Don't Use Tabs = * Joe likes 4-space tabs, I like 2-space tabs, and Jane is old-school with 8-space tabs. * All goes well until someone aligns something visually, like so: void someNiceMethod( [tab][tab][tab][tab][space][space]int myParam...); * Now it aligns perfectly on my machine, looks mostly ok on Joe's machine, and is ON MARS on Jane's machine. Thus one-or-more of three futures happens: * Someon…

You mean something like this don't you? [tab]void some nice method(int param a, [tab] int param b So long as you only use tabs for indentation, not alignment, tabs look correct on _everyone's_ machine. The real problem with tabs is that (some) people are lazy and do stuff like this: [tab]void some nice method(int param a, [tab][tab][tab][space][space]int param b Personally, I think if you work like that you need to l…

This is like an "eternal September" - when tabs vs spaces comes up each year, most commenters have never seen one of the rather simple ways of using tabs correctly.

Re: Developers who use spaces make more money than those who use tabs

#626

Earlier quoted context omitted.

There's actually a solid argument for "tabs for indentation, spaces for alignment", which solves both for preference and vertically aligning stuff: [tab]void someNiceMethod( [tab][space*20]int arg1 [tab]) But it basically requires having some visual indicator of what is a tab, which most people don't like. (edited for line breaks)

I have visual whitespace turned on in all of my text editors. The massive amount of mixed tabs/spaces and trailing whitespace I find in virtually every document with multiple authors leads me to believe that I'm the only person on the planet who actually cares about whitespace at all.

Trailing whitespace drives me batty! The only reason I can come up with for it is sloppiness.

Re: Developers who use spaces make more money than those who use tabs

#627
post #595

Earlier quoted context omitted.

Who aligns like that? It seems to defeat the purpose of putting it on a separate line. void someNiceMethod( int myParam... ); Hey Presto! You, Joe and Jane all get your preferred size size of tab. As a bonus, this indentation style works equally well if Jim uses a non-fixedwidth typeface.

Do people actually code with non-monospaced fonts? I've never seen anyone doing that before

When I first started programming I had to share a single terminal with the rest of the school, so I wrote my programs on paper first. I used graph paper so that my handwriting would be monospaced.

Re: Developers who use spaces make more money than those who use tabs

#628

Earlier quoted context omitted.

> Don't think you make hiring decisions based on tabs vs spaces? I actually ask candidates "spaces or tabs?" in every single interview. I don't really care what the response is in regard to the holy war, and it doesn't mean anything on its own, but having SOME thought out response can be a GREAT indicator of how well versed someone is in general. e.g. I'm going to think way more highly of someone that says "tabs, bec…

> "whatever my editor sets it to". Whats wrong with this? I just accept the defaults. Whether that is what the current project demands or what the editor defaults to. Why waste my time over these things?

There are two very different reasons for this same answer: the don't care vs the don't know. Not caring is fine, not knowing is concerning.

Re: Developers who use spaces make more money than those who use tabs

#629
post #256

Earlier quoted context omitted.

> But I've never seen any organization actually do that. You haven't looked very far! Most open source projects these days enforce code style through some forms of tooling. But saying that "Any coding standard that relies on humans to do something right is going to fail" is basically giving up and saying "do whatever". I mean, why even ask people to indent consistently if it's doomed to fail? It's a mixed indent part…

> You haven't looked very far! Most open source projects these days enforce code style through some forms of tooling. Sure, but I've never seen a tool that was able to enforce that no-one was doing alignment. > But saying that "Any coding standard that relies on humans to do something right is going to fail" is basically giving up and saying "do whatever". Coding standards that you can implement in your enforcement t…

clang-format, Uncrustify, YAPF, and RuboCop all have options to control alignment.
Post reply on HN