Did you look at age? Interestingly, the author claims that experience is considered to be a confounding variable. Can you gain experience, yet, as a lone programmer? Perhaps, so this is a great point about collaboration. Or after I was hired. Or really in any context other than the online holy war…. This is certainly true for an automotive industry, where spaces are required by static analysis tools. And the automotive industry offers typically better paid job, at least here, in Germany.
Bartek, did you notice that in Germany the difference is actually the loweset. Also interesting. They do this for the obvious reason of consistency ie: lack of flexibility and variation which tends to be more important in such places. In situations where the coder is considerably less concerned with other coders ie: self-centered. All modern editors support automatic insertion of spaces when pressing tab and deleting tab-length runs of spaces with backspace. I use 2 spaces with C-style languages, but 3 with XAML and HTML because with 2 spaces leading angle brackets kinda line up in a smooth line, and it makes it harder to make out separate lines; and 4 spaces take up too much place especially considering how reliant those languages are on nesting.
My code looks beautiful and spaces help. Although with eslint being the current necessary fad, I am losing ground on readability while gaining code style consistency across my team.
Passing code along with 4 leading spaces to a developer that uses 3 leading spaces or someone who uses tabs, is bad code. I think this has more to do with age than the actual effect of spaces vs. Tabs are the obviously superior form of indentation and are way more efficient.
Did you look at number of languages space vs. Tabs are not. When you open an editor and see a mixture of tabs and spaces, all the code can be out of whack. Tabbed spacing also wreaks havoc when the editor does code clean-up or comparison for code reviews. Using a specific number of space characters represents consistency and intentionality, which I suspect reveals more about the personality of the person doing the work.
I agree. I think using spaces instead of tabs indicates forward-thinking and caring about your fellow programmers. I can see that kind of personality being more highly valued and thus the increased salary. With spaces that is not easily done. I guess we need to look the other way.
Developers who earn more are obviously Good at what they Do , Prefer spaces than Tabs. This can be inferred that better programmers prefer spaces. There are so many personality factors behind those two statistics! Know your meme. Like in decades past you could probably say people who smoke make more money.
Read the article. The very first graph plots age, and it starts out with spaces over tabs, and continues. Nothing to do with older age. All professionals know that you cannot write source code that contains tab symbols, because such code will always turn into an unreadable mess whenever exported for example when posted on SO.
Therefore all professionals tend to know that you configure your text editor to insert spaces upon tab, which tends to be the default setting in almost every IDE out there. This risk goes even bigger if you have junior devs working on the codebase. All professional source code out there that uses space tokens, because insert-space-upon-tab is industry standard.
I have no idea why I am the only one raising this question… nobody else used a source code editor before? We frequently press the tab key just like normal people, we just want that to map to spaces, not tabs. On the other hand, the pro-tab people use actual tabs, that is the 0x09 character, in their code.
I think there is some crossover in the discussion on this page about use of Tab key vs actual tabs in code. In general it seems fine to use the tab key, providing it maps to spaces.
Most derivatives of vi and vi itself have shift and unshift commands which are configured separately from tab stop positions. What terrible editor is this?! Sublime deletes all tab spaces together by default when u have tab translation into spaces. Pretty sure Vim also deletes tab spaces. I suppose in an ideal world you could make everyone use the same editor and same auto formatting.
Everyone who is experienced have exported code and viewed it in a different editor. This is not subjective — of course every programmer will eventually end up using different editors.
Upon doing so, anyone with eyes will notice that code indented with tabs turns into a horrible mess. This is not subjective, it is a simple fact, since different editors have different tab settings.
Upon noticing this, people who indent by using the tab key eventually starts configuring their editors to insert spaces. Programmers who have interacted with other programmers will know from experience that this is a phase that most programmers go through as part of learning. This leaves us with 3 categories: inexperienced programmers who indent with tab key to insert tab symbols, experienced programmers who indent with tab key to insert spaces, and programmers no matter level of experience who indent with spacebar to insert spaces.
Tab settings usually just change the spacing of each indention level. Exactly the same effect they have when converting tabs to spaces. I know multiple experienced, professional coders who know all of the above and nevertheless prefer tabs. To determine the salary of people who use both, XOR the average salaries of people who use spaces with the average salaries of people who use tabs.
Spaces always require you to use multiple arrow key presses to move through them. Tabs are a single key press. Or when doing work collaboratively, the last thing you want to be doing is changing the indentation size of spaces causes chaos with alignment cases , yet tabs let you do this visually without affecting anything else.
For example, aligning assignments or dictionaries into columns, or a related-but-not-abstractable series of function calls or math statements, to make it far easier to just scan down.
I prefer tabs for a variety of reasons, but there is ONE aspect I dislike which is aligning statements. Normally I would just say that you should use tabs for indentation, spaces for alignment. My solution is to newline the stuff I want to align. If you use tabs for indentation and spaces for alignment, how do you handle the case where different tab widths break the alignment? When would you align things on different indentation levels?
I might be missing something, but how do spaces help with alignment? That would also probably show up some other patterns in common rather than spaces vs tabs. This seems like a good hypothesis.
To pick on marketing firms and programmers who work for them, I would have to guess these are the low bar jobs from my experience in working in many different organizations in terms of rigor. The enforcement of structure is much more relaxed and code reviews are practically unheard of compared with a software shops that typically pay more. Code shops tend to use spaces over tabs as it tends to work better in command line editors such as vim and then look good on github as well.
Try having tabs on github. It sucks. Maybe this is something I should already know, but that was the most surprising revelation here to me. People with nothing better to do need false dichotomies so that they can pick a side and belong. Anyone who wants to belong to either side of a pointless dichotomy needs to die in a fire.
Of course this also differs within the US Bay area … but even the mean is higher. But I had lived here before, so I already knew those numbers to be meaningless. Where before I had stress and debt, now I have more free time and no money problems. This might sound very strange to my fellow Americans, and U.
This is because housing, healthcare, transportation, and even going out to bars are all massively cheaper here. It way more than makes up for the lower salaries.
Maybe people who use spaces are more likely to overreport their earnings, because they also overcompensate on the lack of control in their lives by repeatedly mashing the spacebar. Do you actually think people who use spaces for indentation press the spacebar for every level indentation that they want? When I go to a newline it inserts the relevant number of spaces. Worth noting that PEP-8 was never meant to be used for anything outside the Python standard library.
Being consistent with every other Python project is a good enough reason for me. The tooling around it makes compliance very easy. While I absolutely hate using whitespace rather than curly braces to denote a block of code, it is far, far outweighed by the fact that most python code looks the same since we mostly all share the same set of guidelines. For instance if I place a line break in a comma delimited list, the editor can align the list vertically with the resolution of a single whitespace, not 2, 4 or 8.
That makes no sense. Tabs are only meant for indentation; You would use spaces either way for alignment. Tabs for Indentation, Spaces for Alignment. The trend is the opposite. Not having to commit it. I believe I just now understood. Like… just hit two keys, and your code looks like you want. Indeed, without that, I would have to rethink about this.
Indeed, I think this whole mess revolves around not using reformatting tools and not understanding that TISA is an option… but whatever. You can use vim editing inside a lot of IDEs nowadays. Best of both worlds? Give it a shot. Newfangled things sometimes are good. I prefer spaces, but naturally one must adapt to the the coding style used in the project, so I am fine begrudgingly with tabs, but what really grinds my gears is when both are mixed — this causes such a horrendous mess…. We cannot do without spaces but we can do without tabs.
This clear reasoning removes ambiguity and is a good practice to use this thought in code for all types of things that cause arguments but are not important. With the same reasoning you could eliminate lots of operators and formats from languages, making the remaining operators have more ambiguous, context-dependent meanings. This is obviously not a desirable thing. We would all do assembly language then by your reasoning.
What are you talking about? Contextually, Crockford was arguing about coding style, not about language design, specifically when it comes to tradeoffs of equal functionality that your team decides as a coding style. It was about context which limits scope. However your sentiment averages toward negative which is unbiased if you use an AI. You are able to change that upward if you want to. You are always correct from your perspective coupled with negative sentiment. Hope that works out for you. Yes it does.
You can do anything in assembler so what is the point of any other programming language? By your logic of course…. Well we use tabs for something different than spaces, when we use it for indentation. By your argument we would all code with 3 symbols as those are the fewest symbols we would need to program. Taken out of context. Douglas was referring to unimportant arguments about code style. If you take it in that context, your argument seems reaching.
Maybe being extravagant in your use of bytes reflects an attitude of plenty that becomes a self-fulfilling prophecy in life. Certified spaces growth hacker. The other confounding variables are exactly the point. No one actually believes that switching from tabs to spaces will gain you a nice raise.
Some languages have universal convention for one or the other — for example Python for spaces and Go code for tabs. So Python programmers definitely earn more than Go programmers?
Yeah, developers who use space over tabs probably do make more money. Because developers who use tabs get the job done faster, and as such, work less hours! Almost every modern editor supports soft-tabs; that is, by hitting the TAB key, you insert N space characters. Do you honestly think people actually hit the space multiple times? Everyone just changes the TAB output to X spaces. Try to grasp this concept, apparently it will make you earn more money if you do.
Nobody is hitting the spacebar eight times, people just use tab but render it as spaces. Nobody wastes eight keystrokes for indentation. Us space users use the tab key just like you guys.
On what side am I? I prefer spaces for indentation. The only logical answer is that you are in the tabs group, because you are pressing the tab key to indent.
Prefer tab key for efficiency, but understand the spaces necessity. Does this data account for the ability to use the tab key to execute spaces? How would you categorize this group? We got into a heavy debate about this at work, to the point where I made team tabs and spaces shirts.
I know nobody who favours hitting the space bar multiple times over hitting tab once. But this would certainly be an interesting hypothesis! Every modern IDE can be configured for the tab key to enter the proper number of spaces.
Dude, get a better editor! Firstly, the file size will be smaller. That has to be the preferred choice. Who would choose to have their files be larger? Secondly, it gives you total flexibility in terms of choosing how big a tab is in your editor. Those who have incredibly nested logic can use 1 or 2 characters. Personally I always choose 4. The thing is, you choose how you want to see it. The indentation will look the same always.
If you want to ensure that people always see it the same, you simply specify in your coding standards that people should always set their indentation level in their editor to 4. The advantage of a tab is that it allows you to choose your visible indent size. However, varying indent size makes it functionally impossible to enforce column width.
Therefore if you have a coding standard with a fixed width, spaces are the appropriate choice for justification. Why would you need to enforce a column width though? Alignment after indentation? By column width, I meant the total document width. If a document has a column max width, and one person uses two space tabs, and another uses four space tabs, and another uses eight, and they all use a character width, then when one person views the work done by another, then the formatting will look wrong.
Alignments say, for simple ascii images are going to be off too. You want to use spaces in your code? Their code could look messy and take longer to walk through. The main advantage as I see it is that everyone on a project seems the same code. Sometimes a previous version of myself. It solves the multi-programer problem without sacrificing any principles. I wish more programming languages would supply such tools code formatting normalization. TISA is the best solution.
If all developers on your team are using tabs, how would spaces benefit the team or its members? Thus, it can be impossible to distinguish between words separated with a tab and words separated with a single space. Though, I acknowledge that some modern editors will display a symbol for a tab, which solves that problem.
Due to the nature of code, lining things up with one tab setting may look awful in any other tab setting, thus making the code harder to read for some, easier for others.
You can make the argument you should never attempt to neatly line up code, but there are sometimes good reasons to do so. Can you work around all these issues with tabs, or simply live with these edge cases?
Yeah, probably. Most people I know who use tabs only use them at the beginning of the line. The correct answer is tabs for indentation, spaces for alignment, and alignment is generally to be discouraged. The problem with spaces for indentation has exactly the same foundation as people are complaining about for tab width: one developer wants to use 2 spaces per indent level, the next wants to use 4.
We can certainly agree that if everyone always uses tabs consistently and everyone always uses the same editor configured in the same way, then tabs will work fine, and even allow people to use different indentation widths.
Once you have a mixture of tabs and spaces, the code will start looking weird for someone, not necessarily you. My favourite example is when you look at code written by tab fans who configure their tab width to say 4 spaces.
I mean really, that argument could be applied anywhere where there is any sort of debate on how or what to use — package managers, specific packages, etc. Or am I missing something? Now, to your question: The thing is, if everyone uses only spaces or only spaces and 8-space tabs, it mostly works everywhere because all editors and viewers understand spaces well, HTML interpreters ignore them unless in pre tag, but… and many viewers also handle 8-space tabs okayish.
Now someone figured out that you can use tabs as a sort of system, just like when tabulating data. The benefit is it enables people to configure their favourite tab width. And some people do that, and THEN we have the problem because suddenly we have non-standard tabs so the file is going to look different to everyone else than the author and people with editors configured like the author.
Worse, the code can end up being inconsistent, unnoticed, and then it can garble up completely for other people. The only way to fight that is to start being careful about the tabs. You seem to think that you can standardize everyone to use tabs. And there are still downsides. My life was simpler when I decided jwz was right and I made my editor not insert 8-space tabs, navigation became much more intuitive. Now this is an argument, mostly against inserting non-standard spacing in text that other people may have to look at.
For example, in yaml, you have to use spaces because people with 8 space tabs could be confused with those who use 2 tabs with 4 spaces each. If you colleagues use 2, 4, or 8 space tabs code will not be aligned for everybody.
Only using spaces guarantees it. Readability trumps trying to save bytes. You use tabs at the start of the line and everyone can use whatever tab size they prefer. Especially with the ever-widening gap between how few bytes code requires vs how much bandwidth and storage is available.
Uh, no. This is the beauty of tabs. The main advantage of using spaces is that they always display the same way. I know that those who praise tabs use the same exact argument as a disadvantage or rather the point that tab can be displayed according to ones preference but this argument is invalid. There is plenty of places in which such a setting cannot be set. GitHub has quite narrow, not configurable code view. Tab is displayed as 8 spaces. Especially inconvenient for side-by-side view of a diff.
Age is likely to track with salary. The reason spaces are encouraged when training coders has to do with printing on paper. So older developers will have a different habit then newer developers. Readability concerns are valid on screen just as much as on print. Interesting hypothesis. Never once did I think about the ramifications of printing when thinking about spaces or tabs. Nor can one find a tendency where developers with the same years of experience that used tabs tended to be younger.
In general, older employees do have a higher salary floor. However, developers with the same level of experience most likely trained for it around the same time, so they very likely learned the same habits. If age was a primary factor in the pay gap, I would expect that at the very least, the older languages would stand out in the regression chart.
Might be harder to transition to an open source stack because no one has been willing to pay me to work in one, but I am familiar with several. To me it seems like blatant ageism to assume because someone has been in the industry for 20 years they favor or are currently using old languages.
That was not my intent, I apologize. To be fair, something like Assembly would probably be more like embedded systems programmers. So it may already be a disproved hypothesis.
Writing this comment made me hate myself. I had a coworker who did essentially this. You can set your editor to automatically translate all tabs to spaces. Sure he will notice. He will likely set his editor to expand tabs to wrong number of spaces, given how many possibilities there are, and all the code will look fugly.
Spaces cause problems when reusing code,. Besides, spaces are generally much more variable than tabs in different fonts, I mean considering you get the whole fixed versus variable width fonts into the argument. I mean I agree with you, copy and paste of code provided you wrote it, trust its author, or at least read it thoroughly is a pretty normal thing to do. But still, maybe pick a year? What makes you think copying and pasting is wrong? Well, that statement was not meant to insult you.
Yes, sometimes we have boilerplate code which we copy as a template, like a default HTML file. But everytime you copy code you risk that you have to fix a bug in that code in two places at a later time. Copy-pasting is not always bad, but copy-pasting from Stack Overflow day in and day out is a deadly, deadly trap. I copy and paste code all day along. It saves me hours of time. The main goal of a code review is to maintain the quality of the programming being done, not to teach new developers.
When this is used as a learning tool, it will typically backfire in spectacular fashion. Errors made during the coding process can lead to an application or software program being unstable. It is your job as a programmer to learn more about common coding errors so you can avoid them.
If you are interested in learning about common Java performance errors, be sure to read more here. Below are just some of the errors you need to steer clear of during the app coding process. One of the biggest mistakes you need to avoid when developing a new program is reusing old code. While your client may request this to save time and money, you need to do all you can to talk them out of it.
Unless the code in question was specifically designed to be reused, you will end up basically rewriting it anyway. This is why starting with a fresh batch of coding is a must when trying to have success. As a programmer, your main goal should be providing your clients with the bug-free code they need. The only way to ensure the code you have written is correct is by testing it at every phase of development.
Getting in too big of a hurry will lead to big mistakes and may cause app crashes in the future. While utilizing the power of space and indentation in your code will take some practice, it will be worth the effort. Finding a more experienced programmer to mentor you on this practice is a great idea that will help you progress at a rapid pace.
The Need For Indentation. And in an ideal world it would In reality, you can't see the difference between spaces and tabs, they always seem to get mixed up when moving code around, and viewing the code in another program that has tabs set to 8 columns is a nuisance. Every editor has a "show whitespace" option now, and Visual Studio has a 'tabify' option — Chris S. Good argument. That's the reason I gave up on trying to convince people that tabs are more logical.
Even programmers who should be used to abstract thinking seems to confuse tabs and spaces "if it looks like four spaces, then it must be four spaces! The nail in the coffin for me was that it seems to be impossible to configure Emacs to indent only with tabs. It is too easy to silently do the wrong thing with tabs. I used to use tabs too, but I was running into trouble with some IDEs that couldn't insert spaces for continuation lines and I hated to replace all those auto-inserted tabs with spaces Visual Studio was one of them.
So I just sticked with spaces. Some relevant opinions that may be of interest: Guido says spaces Joel says spaces Atwood says spaces Zawinski says spaces, sort of. Just because you're famous doesn't make you correct. Xepoch: have you read their rationale :?
Matthieu M. I don't like olives either but doesn't make me wrong because others do. I find it ludicrous that people wouldn't use the tab for indentation, but this is why they call them CS holy wars Xepoch: yes, I suppose everyone is entitled to one's opinion : I do think though that Guido has pointed the main issue: mixing tabs and spaces is evil, because both appear as "blank space" to the user. Fishtoaster: When you say that Joel says spaces, shouldn't the link be to an actual Joel quote?
The link just goes to the JoelOnSoftware forum where some ppl most likely not speaking for Joel discuss tabs vs spaces. Show 2 more comments. Tabs for the win. Joel Barsotti. Unfortunately I'm the minority. You are inefficient at keyboard code browsing. So indentation wouldn't matter. Tabs are called tabs tabulators because they were invented for tabulation, not indentation , and they do a dreadful job at both.
Lorenzo: You are inefficient at keyboard code browsing. You should use w and b or e and ge to skip through whitespace and tokens :P — R. Martinho Fernandes. For the sake of devilish advocacy: don't inflict badly-formatted code on editors that you consider inferior.
Use tabs. Timwi: sorry to necro, but the computer tab key was NOT invented for tabulation. Your argument is akin to claiming that the computer return key was intended to start a new line and move the cursor to the far left, because that's what it was for in a typewriter : — Beofett.
Show 7 more comments. That breaks as soon as you start indenting for anything other than statement nesting. For example if you want to align function arguments on the same column, one per line. It's possible by mixing tabs and spaces but very tedious.
It's not tedious at all, since it means you can tab most of the way there and then just use a couple of spaces, rather than having to type dozens of spaces just to get to the right column. If you have non-whitespace chars to the left of your first argument, there's no way to guarantee arguments on subsequent lines will align for everyone.
You've never tried writing HAML, have you. I hate to say this, but I can't imagine programming in a variable-width font. The sheer wrongness of it dwarfs brace standards, tabs vs spaces, everything What happens when you get an error message with a line and a column number? I do not think that there is such thing as proper indentation at least not without minor war.
Josip Medved. Would babies really die if we just said 4 spaces, everywhere, always, no choice - and moved on? Four spaces do not look the same everywhere. More programmers now are choosing proportional fonts in their IDE for a more pleasant and productive coding experience. Four spaces can look like a pretty tiny indent in these situations. That is a really good feature of many editors -- the ability to go quickly through mounds and mounds of spaces.
I would add: Tabs musn't be used for alignment. If you are tab user and want to align you must first type correct amount of tabs for indentation and THEN correct amount of spaces for alignment.
Only then you see tab formatted code right across all users and editors. Tabs are the natural and orthodox choice, as they are by definition used for indentation. Unfortunately, tabs are unevenly implemented, so the only real world solution is 4 spaces. By their very definition they were invented for tabulation although they do a dreadful job at that too.
Technically, the return key was invented to move the typewriter head to the front of the line, whereas the move to the next line was performed by rotating the roller. Later, the return key would also automatically advance the roller as well. The tab key was clearly added to computers to perform indentation. It's a digital analog of the tab stop, which I had on my old non-electric typewriter. Tab stops could be set to move the roller to any position you chose, almost identical to the tab key's current role in indentation.
Yeah, but that is really an OS issue, not a keyboard issue. No matter what computer you are on, you expect hitting either the enter or the return key to take you to the next link.
Connect and share knowledge within a single location that is structured and easy to search. Are there objective reasons for using spaces instead of tabs for indenting files as per PSR-2 standard, can someone provide:. Authors of PSR-2 standard had in mind something more than "look and feel", something more than just opinion based thing, and lots of people have trouble understanding why spaces are better during teamwork.
According to Farsides' answer: repositories thing may be an exact case of why spaces are in PSR-2 explained as indentation tool. PSR-2 is standard developed to assist teamwork. Single accidental spaces at the beginning of line - when using tabs - may not be visible in the IDE and can sneak out to repository.
If a couple of people work on same file it is highly possible to generate unnecessary conflicts. Using spaces instead of tabs makes it possible to easily catch such an accidental space on eyeball and this is probably a reason, why using them become a standard. It damages your ability to effectively compare revisions in source control , which is really scary.
It never going to happen when you are having spaces only. The tab width in spaces depends on your environment text editor, OS, preferences, etc. IDEs are smart enough to treat white spaces up to your personal taste, but the output generated for collaboration should be up to standards.
As PSR-2 states , using only spaces, and not mixing spaces with tabs, helps to avoid problems with diffs, patches, history, and annotations.
The use of spaces also makes it easy to insert fine-grained sub-indentation for inter-line alignment. Using spaces instead of tabs is associated with an 8. Using spaces instead of tabs is associated with as high a salary difference as an extra 2. If every collaborator on your project would keep the same standards on coding - it will be good in the long run, collaboration is more efficient and professional, the same indent when you refactor or develop.
Studies regarding that:. For example, Ben Shneiderman confirmed this in Exploratory experiments in programmer behavior :.
When statements were shuffled, the experts' superiority was reduced. Our empirical results put teeth into these rules: It is not merely a matter of aesthetics that programs should be written in a particular style.
Rather there is a psychological basis for writing programs in a conventional manner: programmers have strong expectations that other programmers will follow these discourse rules. If the rules are violated , then the utility afforded by the expectations that programmers have built up over time is effectively nullified. Many people think standard is better than metric as well.
0コメント