IME, they mandate it because furniture police. They could as easily mandate using tabs exclusively for indent – a style checker can warn of mixes on commit. More often than not, very senior developers prefer tabs, not because it adds any stylistic or technical value, not at all because it saves a few bytes on disk, but simply because it makes sense. In a given editor, a tab has always exactly the same width. It happens to me repeatedly that upon code reorganization the IDE mixes up indentation, and unless I want my whole file reformatted I need to fix this manually.
What's more, a wise man once said that it isn't typing that slows you down, when coding. Using spaces for indentation is simply a dogma that has caught on among enterprise developers. But it doesn't really have any advantage over using tabs.
Of course, mixing tabs and spaces is plain stupid, but if tabs for indent proponents can do the mix, so can spaces for indent proponents do it. I use spaces but prefer tabs, due to working in code bases that included multiple languages with multiple developers all using different indentation settings. It's very irritating to try to understand indentation when part way through a function the indentation level (two spaces – four spaces, etc.) changes. I haven't encountered any professional here in the states that uses tabs in a professional capacity. I have worked with a codebase that's older than me.
If your spacing is consistent , then you can change between tabs and spaces arbitrarily with no significant effort. Just mass replace t with however many spaces you want and you're in your space paradise. Just mass replace however many spaces your tabstop is set to with t and you're in tab paradise. If you've got large blocks of inline text in the code that might be affected by tab/space differences, you need to fix that anyway so do it before the mass replace. The problem of arcane legacy code is the changing coding conventions of the past developers, not whether they used spaces or tabs.
I've been coding for over forty years, in that time I have used at least a dozen different editors. I don't want to look up how to configure tabs to make my code look right. I would expect something as sophisticated as, say, Resharper to get that right (and as far as I know, Resharper does get that right, though I don't have my work machine in front of me to verify that). But unless the plugin knows how to parse your code syntax, you will either get two tabs on the second line, or one tab + four spaces on the third line, neither of which is the correct result. And since I've never found a plugin that did the right thing in the rather-basic use case of a simple if statement split across two lines, I find that "tabs for indentation, spaces for alignment" is not practical for me.
Yes, it's ABSOLUTELY the right approach if you're going to use tabs at all. But since I don't want to be made to care about whitespace, and just want to get on with coding, I have to use spaces-only since that's the only one the editor won't screw up. Most editors convert the Tab to spaces, so developers basically indent pressing the Tab, but that just creates e.g. 4 spaces. So if I was asked what do I use – spaces or Tabs I would be confused, and I guess a lot of people did answer spaces but they do use tab to do it. Personally, good coding style was a major emphasis in my first computer science class.
We were taught to use four spaces to indent each line. I started off using spaces, but later switched to tabs. If I need to submit code with spaces, I will write the code with tabs and then Replace All tabs with four space characters , or configure my IDE to do this automatically.
Other than space usage, I am very persistent on style and will fix the style of code I receive before I read or compile it. Because of my positive style habits, I anticipate that I will be in the "Spaces" category of developers as far as salary goes. This means those less skilled developers, instead of contributing evenly to each pool, actually are skewed towards 'tabs' and lower the average pay rate of 'tabs' vs 'spaces. You can preach "indent with tabs, align with spaces" all you want. In the real world, people who use tabs for indenting will also sometimes use tabs for alignment. I've seen it with my own eyes by really brilliant programmers.
People who do not use spaces predominantly give a clue that they have used various tools to read the code and admit that a tab in code makes the code look bad. Going off the indentation, lengthy lines, different display in each OS/IDE/Editor. This means that they have used multiple tools in different environments is which is not just years of experience but exposure and adaptability to many tools.
Such developers care about the code being written. It can be the perfection about the code that is maintainable, the code that is concise and expressive, the code to use nice design patterns or anything that will help manage well. When one goes an extra mile about not just working code but manageable code, it also means that they are better ones than their counterparts with similar experience who just write some code but not love code. The love part here is what makes more money. If you need to further align code you would just use spaces here, no tabs or mixture of tabs and spaces. This way the code will always carry both the indentation and further alignment properly between editors, and has the added benefits of user defined tab widths and slightly smaller file sizes.
I think the survey could have been poorly developed. Code will always turn into an unreadable mess whenever exported . 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. Then you can indent by pressing the spacebar or by pressing the tab key and it doesn't matter. Assuming you know these things, the question "tabs or spaces" doesn't even make any sense.
The new edition of this book provides an easily accessible introduction to the statistical analysis of network data using R. The central package is igraph, which provides extensive capabilities for studying network graphs in R. The new edition of this book includes an overhaul to recent changes in igraph. The book begins by covering tools for the manipulation of network data. Next, it addresses visualization and characterization of networks.
The book then examines mathematical and statistical network modeling. This is followed by a special case of network modeling wherein the network topology must be inferred. Network processes, both static and dynamic are addressed in the subsequent chapters. The book concludes by featuring chapters on network flows, dynamic networks, and networked experiments.
Statistical Analysis of Network Data with R, 2nd Ed. Sorry, but you can't build any conclusion on this dataset because only half the respondents included their salary information and there are a number of other factors that can be skewing this dataset in this way. Such as it is immediately skewed towards respondents that brag about their salary. Anyone that knows anything about computer science will know not to use spaces when the tab key is being used for your indentation in the code you are in. If your tabs a wrong then you change them and avoid hitting the space bar three times on each line.
Makefiles are impossible without tabs and hence nothing will compile because some idiot used spaces instead of tabs. Read the linked article for more details, but it seems to me that the causal factor is probably somewhere in the "Contributes to open-source software" realm. And it also seems likely that most open-source software uses Git, and that most open-source software uses spaces for indentation rather than tabs.
(The latter is my intuition, and would need to be verified — but it matches my experience). However, the cause of my better than industry median salary is not that I use spaces, but rather I think about why things are done, and stick with proven, measurably superior results. What is measurably superior than either tabs or spaces, for overall results is keeping coding styles consistent within a file, and application. This is far more effective than dogma (i.e. spaces and tabs both have pro's and con's). You never press the space key repeatedly to create indentation, you use the tab key. What's it to you, if there's a tab inserted or spaces?
The only real difference occurs when code is shared between programmers using different indentation sizes. Spaces force everybody to look at code the same way. Thus, we cannot use causal language in describing this estimate. The main issue would be the huge amount of missing outcome data, some of which is probably missing at random, some of which is most probably not. Certain variables also contain multiple responses for each person, which would have to be dummy-coded, but that's not too big of an issue. There are more interesting approaches as well (e.g. double machine learning)..
That ambiguity is a feature of tabs, not a bug. Those of us that like compact code with two space indentation can coexist peacefully with our coworkers that use 4 space tabs. As long as tab characters are in the code it is just a editor setting and both groups can be happy. Even that one weirdo that prefers 8 spaces per tab can do his thing without bothering the rest of us. Really, spaces just mean "I gave up and didn't want to deal with my tools".
I prefer tabs (that's just my world, but I can work with spaces if needed). But what happens when I'm walking through someone else's code and they use spaces, but for some reason didn't always use a 4 space indent. Their code could look messy and take longer to walk through. LOL. I imagine people here know the survey is about the characters that is saved, spaces or tabs.
And not about the key which is pressed, which is the TAB key for most programmers . I can imagine that can exist a few programmers which press space a lot of times, but they are really a few. "Spaces force everybody to look at code the same way. Tabs don't" – That is exactly the reason why I use spaces. If I write code in some way, I would want that other people would see it in exactly the same way as I did when I wrote it.
When somebody else writes a code, I would want to see it in the exactly way that the author saw when he wrote it. I don't want to lose time trying to figure out what should be the tab size, specially when working on multiple projects with different settings, because, frankly, I have no time to lose on this stupidity. Ideally your functions should not have that many arguments that this becomes necessary. It's true this is a failing of tabs, but using spaces to indent now means that you're forcing every single dev working on that code to use the exact same number of spaces everywhere.
So it doesn't matter if Joe likes 4-space indentation and Bob prefers 2 on his screen, everyone has to have the same. Using tabs, that isn't a problem, everyone gets to set the visual width of tabs as they please on their own IDE. I don't think there's a rational argument for keeping your base files indented with actual tab characters.
Thankfully most IDEs at this point afford you the option — yes i use the tab key but the resulting files are indented with spaces. I just got through reading this thread, and I don't see what you're seeing about "most" of the tab-preferring responses being confused people who think the key, not the character, is being discussed. Tabs as leading white space only, all other alignment spaces. Tabs stops don't exist because there is only tab indent.
Most editors allow you to set how wide a tab is, 2, 4, 8. Multi line comments by definition would span multiple lines and therefore couldn't have code to the left for any line after the first. Any thing else would be multiple lines with single line comments.
He discovered that was a problem in files that mixed tabs and spaces because how your IDE renders tabs might differ from how many spaces someone inserted. If everybody uses spaces and not tab characters, the file will render the same for everyone. I'm sure the OP uses the tab key to insert his space-character indents. The main advantage as I see it is that everyone on a project seems the same code. While it should be avoided, we sometimes like to line stuff up in columns, or align multiple lines of code or data so that it's easy to read.
These alignments simply don't survive varying tab widths. Combined with the fact that you can't see tabs, so "foobar" may appear as "foo bar" or "foo bar". Do you actually think people who use spaces for indentation press the spacebar for every level indentation that they want? Because that's not the case, you just configure your editor to use spaces for indentation, to convert tabs to spaces.
So when I hit Cmd+] or Tab, it inserts or removes 4 spaces. When I go to a newline it inserts the relevant number of spaces. Tabs will make a larger file size, but bytes don't matter if the file doesn't even RUN because of a different tab setting that screws consistent indentation in the interpreter. If you have a stable environment you can trust an expander to auto convert your tabs, but then he's clearly not conversant with good practice because he expands his tabs to 8 spaces! It was really obvious something was wrong when confirmed he was using Emacs instead of Vim. The reason you earn more using spaces … is because spaces are BETTER.
I rely very heavily on indentation to provide clues to nesting, in all languages . I like my code to look exactly the same no matter what software interprets the file. So I forced the habit of not taking advantage of any short cuts with a tab key.
Spacing is second nature to me and I don't have to think about it or count spaces or anything else. It produces consistency in the code and to me makes it easier to debug; in fact I consider bad indentation in my code to BE a bug, even if the compiler is not affected by it. It is a bug in supporting the future maintenance and understandability of the code.
The only argument for spaces instead of tabs that's in favor of spaces, presented in this discussion so far, is that messy developers make a mess when tabs are allowed. That's a non-argument – sloppy developers make a mess when tabs are forbidden too. The only advantage of tabs is that everyone can configure the tab size to his liking, something spaces can't provide. There really isn't anything making spaces better than tabs. Here's a potential confounding factor.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.