Beta
×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

Visual Studio 2010 Forces Tab Indenting

kdawson posted more than 4 years ago | from the one-man's-readable dept.

Microsoft 390

An anonymous reader writes "For years, Microsoft has allowed Visual Studio users to define arbitrary tab widths, often to the dismay of those viewing the resultant code in other editors. With VS 2010, it appears that they have taken the next step of forcing tab width to be the same as the indent size in code. Two-space tabs anyone?"

cancel ×

390 comments

Sorry! There are no comments related to the filter you selected.

This is news at any level how? (5, Insightful)

Foredecker (161844) | more than 4 years ago | (#30885938)

This tab thing makes Slashdot front page and the following didnt? Windows 7 way hotter than Vista off the line, now more popular than all OS X versions [engadget.com] . Okay then...

How is this tab things news or interesting at all? Here is what Brittany Behrens a PM for the editor team said:

Hi Brien,

Thank you for logging this issue. Before making this change we solicited feedback on the decision to combine Tab Size and Indent Size from a wide variety of sources, including public blog posts and forum threads, and found that the vast majority of user feedback was in favor of combining the two. If its seriously impacting your code to have Tab Size always equal Indent Size, it is possible to write a short editor extension to override the Tools->Options dialog and set the two options separately. If thats something youd be interested in, please let me know and Ill see about posting sample code for how to do this.

Im resolving this issue as By Design because we intentionally combined these options for VS 2010, but please feel free to post again here if you have any further questions or comments and well be happy to help.

Thanks for trying Visual Studio 2010 Beta 2 and sending your feedback!

Brittany Behrens

Program Manager, VS Platform - Editor

(bolding above mine for emphasis)

Gee, the team solicited comments, did some research and made a change that people wanted. Of course, any change will make somebody unhappy.

Brittany even volunteered to give folks a simple editor extension to make the settings different for those that want it. My assumption is that anyone using Visual Studio is a developer and capeable of using such an extension, or writing it themselves. It is not difficult.

-Foredecker

Re:This is news at any level how? (0)

Anonymous Coward | more than 4 years ago | (#30885976)

Microsoft gets big attention because they are an industry leader. The relatively small decision of mandatory tab indententation affects many, many people. Jealous much?

Re:This is news at any level how? (3, Insightful)

j741 (788258) | more than 4 years ago | (#30885978)

This tab thing makes Slashdot front page and the following didnt?

Windows 7 way hotter than Vista off the line, now more popular than all OS X
versions

Of course id did; it's a developer tool so it immediately has street cred at /.
Everything else that has nothing to do with coding or Linux is immediately a 3rd rate info byte unworthy of these hallowed pages ;->

Re:This is news at any level how? (5, Insightful)

black3d (1648913) | more than 4 years ago | (#30886024)

This tab thing makes Slashdot front page and the following didnt?

Windows 7 way hotter than Vista off the line, now more popular than all OS X
versions

It's kdawson's shift. He'll never post any article that's even mildly favorable of anything Microsoft related. However, if you can find a story that says some kid in Sweden doesn't like the Windows 7 box-colors, you've got yourself a kdawson front-pager! :)

Re:This is news at any level how? (-1, Flamebait)

Anonymous Coward | more than 4 years ago | (#30886246)

"It's kdawson's shift. He'll never post any article that's even mildly favorable of anything Microsoft related. However, if you can find a story that says some kid in Sweden doesn't like the Windows 7 box-colors, you've got yourself a kdawson front-pager! :)"

If that's so, then please mark kdawson as "+5 Insightful."

Re:This is news at any level how? (0)

mgblst (80109) | more than 4 years ago | (#30886606)

Yeah, well I don't want to read Microsoft propaganda as much as I don't want to read Apple propaganda. I still don't like Windows 7/Vista, and probably never well.

And the fact taht W7, that is bundled with almost every PC sold in the world, has surpassed OS X is not news in the least. It was only a matter of time. If Microsoft released something interesting, like how many people reformat the drive to go back to XP, or how many people who bought Vista down/upgraded to XP, that would be news.

You do realise that there is a lot of developers here?

Re:This is news at any level how? (1)

oldhack (1037484) | more than 4 years ago | (#30886060)

Dude, you are so fired for not clearing with the legal before posting.

Re:This is news at any level how? (0)

Anonymous Coward | more than 4 years ago | (#30886152)

This tab thing makes Slashdot front page and the following didnt? Windows 7 way hotter than Vista off the line, now more popular than all OS X versions.

How on earth is that news? Windows has well over 90% of the desktop market, of course their new OS is more popular than all versions of OS X (and Linux, *BSD, AmigaOS, etc). Everyone knows the popularity of windows has more to do with MS' aggressive and unethical "marketing" than with quality...

Re:This is news at any level how? (4, Insightful)

Wumpus (9548) | more than 4 years ago | (#30886186)

No.

They solicited input from each other and in a blog post that generated a handful of responses. They did this to eliminate "a class of bugs" in the new editor that was triggered by setting the two numbers to different values. Which means they had a bunch of bugs (probably due to confusion between the two settings in the code) and someone had the brilliant idea that the bugs will go away if they just crippled the editor in such a way that the bugs will never be triggered. They solicited input, very quietly, and did it. This also means that the workaround they offer (writing a fucking extension, for fucking crying out loud - what is this, emacs?) will trigger all those bugs because they didn't fix them.

Idiots.

Re:This is news at any level how? (0)

Anonymous Coward | more than 4 years ago | (#30886370)

Gee, the team solicited comments, did some research and made a change that people wanted.

This isn't what the customers wanted. They wanted IronPython support and the team interpreted it as people asking for silly tab/indent settings.

Foredecker is learning... (2, Interesting)

symbolset (646467) | more than 4 years ago | (#30886388)

Nice. I'm sure you'ld prefer to have something closer to the Windows core than this, but nice first post. If you're going to advocate it pays to have front billing.

Now if you're going to drive off course from source code formatting to operating system adoption I can be forgiven for also going wide afield.

How's that Window Mobile thing working out for you? Have they canned Roz Ho yet for the Danger debacle? Will she have to extrapeneur to a startup and bring back its corpse to prove her loyalty, or will she choose to spend more time with her family? Is September a solid date for WinMo7, and even then how do you expect phone vendors to personalize their experience and ship product for Christmas?

Frankly I think two team reboots in the last year means you've got nuthin' for Christmas '10, and Christmas '11 is looking like less than even money. That's a long time for iSlates and Android tablets to be walking all over you. Of course I've got it being any good at 30:1 against.

And what about Ballmer? Is an off 40% decade while Apple grew 7x and Google grew 4x not enough evidence that he's not getting it done? You would figure with all of the leverage and cash he's got he could do better if he was any good. Hell, I think I could do better than that even if I gave half the gross profits away to get some global love. With the money Ballmer has wasted on obvious dead ends over the last decade we could buy each Haitian refugee his own quake-proof palace.

Re:This is news at any level how? (3, Informative)

Col. Klink (retired) (11632) | more than 4 years ago | (#30886440)

Did you read the blog post [msdn.com] where they solicited feedback? It had 9 comments in total. Among them was this comment from the author of the blog (4th comment):

I assure you we won't be changing that option [tab vs spaces] any time soon :-)

So they solicited comments on a blog that no one reads and immediately say they aren't planning to change anything when questioned. After saying they wouldn't be changing the option, no one complained. Wow, what due diligence.

Windows 7 still sucks but just not as much. (1)

MikeFM (12491) | more than 4 years ago | (#30886446)

Do they count all of us who bought computers with Windows 7 pre-installed and then deleted it? Sure people rushed to Windows 7 - it's been a while since anyone running a PC could buy it with an OS that wasn't total crap so they could all finally get the updates they wanted. Windows PCs tend to be cheaper than Macs. Saying they outsell Macs is like saying they sell more Ford Focus's than BMW's. A PC does what a Mac does for half the price. It just doesn't look as good, work quite as well, last as long, or offer the same smug bragging rights. And of course you can get a juiced up PC just like same people will take a Ford Focus and soup it up. Why I dunno but I guess some people enjoy the challenge or are just smoking to much crack.

Re:Windows 7 still sucks but just not as much. (1)

MightyMartian (840721) | more than 4 years ago | (#30886646)

Do they count all of us who bought computers with Windows 7 pre-installed and then deleted it?

On one hand, sure.

Re:This is news at any level how? (5, Informative)

cgenman (325138) | more than 4 years ago | (#30886556)

This tab thing makes Slashdot front page and the following didn't?

Of course the tab thing made Slashdot front page. Some people here virtually LIVE in Visual Studio, and code indentation is a heavily entrenched basic function of coding that people get surprisingly fired up about. Even if this particular aspect of code indentation isn't going to effect people, it's just begging for a heated emacs level discussion.

Your article, on the other hand, basically confirms that people like Windows 7 more than Vista, and that Windows 7 continues the well known and understood tradition of Windows outselling OSX by a factor of 10 to 1. These are things we already knew. Also, the article you site isn't even the source of the information, but refers to a much better Ars Technica article, which itself gets the data from Net Applications. I wonder if you didn't link the Ars Technica [arstechnica.com] article directly because it claims that "Linux was the only operating system [in December] to show positive percentage growth in market share." Or maybe this one "When putting this into perspective across the whole year, though, we see that Windows was actually sliding steadily throughout 2009 (93.66 percent in January 2009), while both Mac OS (4.71 percent in January 2009) and Linux (0.90 percent in January 2009) have been gaining." Or maybe the fact that Windows XP continues to hold onto 2/3rds of the active Windows installbase.

Also, it might be nice to point out that you're work at Microsoft in the Windows org as a development manger. It would boost your credibility as a poster, and reduce potential conflicts of interest.

Visual Python (1)

c0d3r (156687) | more than 4 years ago | (#30885956)

Visual Python anyone? Doesn't Python force tabbed spacing for scoping?

Re:Visual Python (0)

Anonymous Coward | more than 4 years ago | (#30885974)

Yeah, but it doesn't matter what the indent is as long as your consistent. Python 3 won't let you mix tabs and spaces so you won't run into issues. You will still run into issues with Python 2 (which I believe IronPython is still using) since Python always considers tabs to be 8 spaces regardless of what your editor is set to.

Re:Visual Python (1)

MichaelSmith (789609) | more than 4 years ago | (#30886090)

Python always considers tabs to be 8 spaces regardless of what your editor is set to.

Well its not psychic, isn't it?

Re:Visual Python (4, Funny)

broken_chaos (1188549) | more than 4 years ago | (#30886330)

import psychic

You can then retrieve the exact number of tabs the last editor to that block/line of code had in mind when they wrote it. This does add a bit of overhead, mind you, such as needing a pint of goat's blood every time you run the program.

#include "less.h" (1)

VortexCortex (1117377) | more than 4 years ago | (#30886498)

If the VC IDE was as "smart" as any that I use it would just write a comment in the file containing the indent and tab settings, use default settings if the special comment doesn't exist, and allow the user to override / adjust those settings.

e.g.
/* MS_VC_INTENT=2; MS_VC_TAB=4 */

It's the old "Use Comments for Meta-Data" trick (As seen everywhere else...)
<!DOCTYPE> anyone?

The point is that they didn't want to fix their own bugs related to the setting so they eliminated the cause...
They got rid of the setting and claimed "It's not a bug, it's a feature!"

Re:Visual Python (1)

Capsaicin (412918) | more than 4 years ago | (#30886476)

Yeah, but it doesn't matter what the indent is as long as your consistent. Python 3 won't let you mix tabs and spaces so you won't run into issues. You will still run into issues with Python 2 (which I believe IronPython is still using) since Python always considers tabs to be 8 spaces regardless of what your editor is set to.

Just as well too! You wouldn't really want the compiler to react to code differently depending on what editor it was written in, and depending on what settings the particular editor had in place a the time it was written, would you?

In any case, as PEP 8 makes clear, the 8 space/tab equivalence is there for "really old code that you don't want to mess up." The official recommendation is to "[u]se 4 spaces per indentation level" and that "[f]or new projects, spaces-only are strongly recommended over tabs."

With any halfways decent editor (ie. vim instead of vi :o) one should really never feel the need to touch the [Tab] button for the sake of indenting code. Of course Visual Python would throw the cat among the pidgeons now.

Anyone, anyone? (5, Funny)

Blakey Rat (99501) | more than 4 years ago | (#30886244)

Ending sentence fragments with anyone, anyone? Does anyone like this convention, anyone? Can we just see it die horribly in flames, anyone?

Re:Anyone, anyone? (0)

Anonymous Coward | more than 4 years ago | (#30886536)

Drinks, anyone?

Re:Anyone, anyone? (0)

Anonymous Coward | more than 4 years ago | (#30886718)

You misspelled ne1.

Most editors do this... (1)

SuperKendall (25149) | more than 4 years ago | (#30885962)

It seems to me that most editors jump to the current indent level when you press tab - or if not, they should. I can't imagine many people want tabs to really go eight spaces...

But this is why rather than using tab characters in code I've always felt editors should backfill with spaces instead of tabs (outside of editing makefiles of course!)

Re:Most editors do this... (1)

aflag (941367) | more than 4 years ago | (#30886640)

It seems to me that most editors jump to the current indent level when you press tab - or if not, they should. I can't imagine many people want tabs to really go eight spaces...

It's actually quite common, though. Linux' coding style text states that 8-spaces-wide tabs are the standard. It seems to me that it's also the way people work in OpenBSD's code as well. I personally like 8-space-wide tabs for C code. For C++ and Python I rather use 4 spaces because I feel there is usually more nesting in those languages.

Tabs vs. Spaces (5, Funny)

dziman (415307) | more than 4 years ago | (#30885988)

FIGHT!

Best argument for using spaces (1)

smoot123 (1027084) | more than 4 years ago | (#30886012)

It's things like this that convinced me using spaces is the only way to fly. You also need an editor that knows how to indent to the right place by inserting the right number of spaces (i.e. not vi out of the box or notepad). Anything else will always get screwed up by someone or some tool.

Re:Best argument for using spaces (2, Funny)

Sehnsucht (17643) | more than 4 years ago | (#30886064)

Anything else will always get screwed up by someone or some tool.

Why are you repeating yourself?

Re:Best argument for using spaces (1)

God of Lemmings (455435) | more than 4 years ago | (#30886098)

Yep, it happens so much our workplace standardized on 3 space indentation; absolutely no tabs in the code.

Re:Best argument for using spaces (3, Insightful)

nullchar (446050) | more than 4 years ago | (#30886770)

And if you prefer to look at 2 or 4 spaces per tab, you're hosed. Tabs-only is best. Then each person can set the level of indent they want to see. As long as you don't mix spaces and tabs, you're fine.

Why put tabs in code anyway? (1, Offtopic)

harryjohnston (1118069) | more than 4 years ago | (#30886034)

One of the first things I've always done when setting up Visual Studio on a new computer is to set the option to insert spaces instead of tab characters. I find tab characters, to put it bluntly, irritating and utterly unnecessary. (You can imagine my opinion on standard makefile syntax!)

So, for all those tab fans, what is it about tabs that you find useful?

Re:Why put tabs in code anyway? (4, Insightful)

mgkimsal2 (200677) | more than 4 years ago | (#30886128)

They're a meta character, and the meaning can be changed later.

* If I'm hitting the tab key and it's inserting X spaces, and I hit the key once too many times, I have to hit delete X times instead of just once.

* If the code is reused in a new environment where everyone wants their indentation levels at 4 spaces instead of 2 or 3 or 8, you have to reformat a lot of code manually. If tabs are used, remap the sizing of the tab character and you're done.

* The tab character itself has some semantic meaning - indent. The space is a word and symbol separator. Use an indentation character when you want to indicate indentation.

Re:Why put tabs in code anyway? (2, Insightful)

harryjohnston (1118069) | more than 4 years ago | (#30886298)

They're a meta character, and the meaning can be changed later.

* If I'm hitting the tab key and it's inserting X spaces, and I hit the key once too many times, I have to hit delete X times instead of just once.

Or press shift-tab or undo...

* If the code is reused in a new environment where everyone wants their indentation levels at 4 spaces instead of 2 or 3 or 8, you have to reformat a lot of code manually. If tabs are used, remap the sizing of the tab character and you're done.

I don't think it's really all that hard to automate the process of changing the indent spacing. In my experience, a bigger problem is changing other formatting conventions, such as where to put the line breaks.

* The tab character itself has some semantic meaning - indent. The space is a word and symbol separator. Use an indentation character when you want to indicate indentation.

While I see some value in what you're saying here, I'm doubtful that giving an invisible character semantic meaning is wise. It means you can't tell easily the difference between valid and invalid code. (Yes, I really hate makefile syntax!)

I also note that your latter two points only apply if the tab size is also the indent size.

Re:Why put tabs in code anyway? (3, Informative)

weicco (645927) | more than 4 years ago | (#30886554)

I'm doubtful that giving an invisible character semantic meaning is wise

(In the voice of dr. Farnsworth) Yes, yes. Let's all forget about those nasty invisible characters like \r \n and especially \0

Tabs suck. Use a space. (1)

MikeFM (12491) | more than 4 years ago | (#30886474)

Or you can intent with a single space and your code will be clear and easy to read instead of quickly rolling off the end of my 30" monitor. I should never have to scroll horizontally when reading code. Of course some dipshits think the entire program should be on one line. Who uses a crappy editor that doesn't adjust formatting to match your preferences? The tab character has the semantic meaning of jumping to a random spot in the middle of the page with the behavior being different in every app on every computer. It's best left for meaningless tasks like switching between windows.

Re:Why put tabs in code anyway? (1)

d3matt (864260) | more than 4 years ago | (#30886532)

For your second point...
What happens when you put tabs after the start of the line to make columns? Spaces would stay lined up as long as you use a fixed width font. Tabs cause the column spacing to change (when you change the tab size) depending on how much text is in each column.

I do prefer tabs for the other two stated reasons; also GNUmake forces the issue, and Python recommends the use of tabs.

Re:Why put tabs in code anyway? (1)

John Whitley (6067) | more than 4 years ago | (#30886538)

If I'm hitting the tab key and it's inserting X spaces, and I hit the key once too many times, I have to hit delete X times instead of just once.

This is only true if your editor is being stupid. For example, TextMate has a "soft tabs" mode that inserts spaces, but the UI works exactly as if tabs are in use. The same convenience when editing, without the dagger-eyed looks from your collaborators.

Re:Why put tabs in code anyway? (3, Informative)

poopdeville (841677) | more than 4 years ago | (#30886678)

* The tab character itself has some semantic meaning - indent. The space is a word and symbol separator. Use an indentation character when you want to indicate indentation.

No, it doesn't mean "indent". It means "tabulate". You shouldn't be using tab to indicate indentation. You should use tab align table columns -- i.e., to indicate tabulation.

Re:Why put tabs in code anyway? (3, Insightful)

Artraze (600366) | more than 4 years ago | (#30886132)

I find the use of spaces irritating and stupid, to be equally blunt. I mean, the tab is a character that exists _specifically_ for aligning text. It behaves predictably across editors and allows easy changing of width for various programmers. You never have to worry about half indents choking the editor. Why replace tabs with spaces? So you can hit the space bar a thousand times whenever you need to edit something outside a programming editor? So you can't change indent size without some obscene editor voodoo that may change the spaces and corrupt your diff history? But I doubt I'll ever understand... Most of the "benefits" I see people listing for using spaces I consider either more true for tabs, or disadvantages.

Re:Why put tabs in code anyway? (4, Insightful)

harryjohnston (1118069) | more than 4 years ago | (#30886332)

I find the use of spaces irritating and stupid, to be equally blunt. I mean, the tab is a character that exists _specifically_ for aligning text. It behaves predictably across editors [...]

Not in my experience it doesn't!

You never have to worry about half indents choking the editor.

I don't understand what you mean by this.

Why replace tabs with spaces? So you can hit the space bar a thousand times whenever you need to edit something outside a programming editor?

Ironically, one of the reasons I prefer to use spaces is so that the code is readable when I do want to edit (or view) something outside of the programming editor. Code with tabs in it is usually completely messed up.

Ah, well, it'd be a funny old world if we were all the same!

Re:Why put tabs in code anyway? (1)

MikeFM (12491) | more than 4 years ago | (#30886482)

What I hate most is cutting and pasting tabs. One program will treat it as a tab, another as x number of spaces, and another as y number of spaces. It's horrible. If you use spaces you know what you are getting.

Re:Why put tabs in code anyway? (1)

JimboFBX (1097277) | more than 4 years ago | (#30886552)

Why would knowing the number of spaces ever be important when you are writing indentations in code? I mean, do you make comments with arrows that move horizontally and then point up or down to the beginning of the code they are referring to or something?

Re:Why put tabs in code anyway? (1)

cheekyboy (598084) | more than 4 years ago | (#30886694)

Stop using said shitty programs dude. If X program doesnt do its job why on earth do you force yourself to use it and adjust your whole workflow to suit it.

Bloody hell.

Are you coding cobol on a 70s mainframe?

Re:Why put tabs in code anyway? (1)

Mad Merlin (837387) | more than 4 years ago | (#30886742)

If you use spaces you know what you are getting.

Sure, and it's always wrong.

Re:Why put tabs in code anyway? (1)

cheekyboy (598084) | more than 4 years ago | (#30886690)

How hard is it to find an editor that will handle TABS nicely?
If you are forced to use notepad then jeez, find a way to install scite or something small that works better.
Dont force your self to use a crap editor that is NOT meant for code.

Seriously, thats a poor mans excuse, "because i have to use a shit editor" , get a better editor / viewer. There are 100s of em.

You are forced to edit source on a C-64 40col text editor.

Re:Why put tabs in code anyway? (1)

JimboFBX (1097277) | more than 4 years ago | (#30886520)

I think its an old person new person thing. People who are used to programming with 80 chars being their monitor's limit are also used to the default tab size being like 5 spaces or so and they probably never figured out how to change that size and save it. New people who grew up with a monitor that manages more than 800 pixels horizontally and with an operating system that you can alt-tab with *should* prefer tabs, but it appears some people still hang on to old ideas, probably because some 40 year old or 50 year old told them spaces was better, or more likely their preferred editing software by default inserts 3 or 4 spaces when they hit tab and they dont want to admit they never learned how to change that in the options.

The rule in programming classes should ALWAYS be:

Tab up to the first non-white space character then use spaces for things that follow.

Re:Why put tabs in code anyway? (2, Insightful)

John Whitley (6067) | more than 4 years ago | (#30886548)

It behaves predictably across editors and allows easy changing of width for various programmers.

I'm amazed that you can utter this with a straight face. "behaves predictably" and "allows easy changing of width" are pretty much diametrically opposed concepts, at least if you actually share your code with any other human being. If tab-width were somehow a universally self-describing attribute in text files, then this could fly. But without it, we're left in a place where others viewing your code open the file (or heaven forbid, use cat/more/less!) and then feel fscked.

I'll also observe that a number of popular editors don't even have clean per-project (or per-file) concepts of tab-width setting and such settings are often clunky in the best of those that do.

Re:Why put tabs in code anyway? (1)

JimboFBX (1097277) | more than 4 years ago | (#30886578)

Do you draw naked ladies in your code or something and insist on using the tab key for white space? Explain how if I like my tabs to be 2 spaces and I am sharing code with someone who likes 5 spaces, that we can get along unless we both use tabs and have our editor of choice configured to use our preferred number of spaces?

Re:Why put tabs in code anyway? (1)

poopdeville (841677) | more than 4 years ago | (#30886710)

I would be annoyed if I was a 5-space using user, and downloaded somebody's code, and found that it flowed off the screen because of 2-space nesting in the author's environment... I would rather see 2-space nesting than 5, in that case.

Re:Why put tabs in code anyway? (2, Funny)

Dan East (318230) | more than 4 years ago | (#30886134)

Tabs can be represented by as many "virtual" space characters in the editor as desired by the programmer, allowing them to work with the amount of indentation they prefer without forcing that representation as spaces in the sources. Plus it saves a lot of bytes for those that still save their source code on floppies.

Re:Why put tabs in code anyway? (1)

avxo (861854) | more than 4 years ago | (#30886352)

Dan East wrote:

Plus it saves a lot of bytes for those that still save their source code on floppies.

LOL! I'd mod you funny, but I'm out of points!

Re:Why put tabs in code anyway? (1)

harryjohnston (1118069) | more than 4 years ago | (#30886362)

I think I've got to quote Dilbert here: "That must come in handy when someone calls from 1993." :-)

Re:Why put tabs in code anyway? (0)

Anonymous Coward | more than 4 years ago | (#30886138)

1) select several lines
2) press tab
3) lines have one more indentation level (depends on your IDE of course)
---
1) select several lines
2) press space
3) ???
4) no profit

Re:Why put tabs in code anyway? (2, Insightful)

scdeimos (632778) | more than 4 years ago | (#30886282)

You're confusing the tab key with the tab character. Do you expect to see arrow characters in your code when you use the arrow keys on your keyboard too?

Re:Why put tabs in code anyway? (1)

harryjohnston (1118069) | more than 4 years ago | (#30886366)

Uh ... you understand there's a distinction between the tab key and tab characters?

Re:Why put tabs in code anyway? (1)

Buttink (1449239) | more than 4 years ago | (#30886142)

fewer keystrokes, personalized source code viewing, and faster to fix tabs when VS messes up. (YES it does happen) The question that this all brings up is "So, for all those space fans, what is it about spaces you find useful?" Randomly asserting your right is FUN!

Re:Why put tabs in code anyway? (1)

harryjohnston (1118069) | more than 4 years ago | (#30886396)

fewer keystrokes,

Not really. The tab key still works, you understand, it just inserts the appropriate number of spaces.

personalized source code viewing,

That one's valid, except that it requires you to use tabs consistently, which I find hard to do since they're invisible.

and faster to fix tabs when VS messes up. (YES it does happen)

Not sure what sort of mess-up you're talking about, or how tab characters make it faster to fix, so can't comment.

The question that this all brings up is "So, for all those space fans, what is it about spaces you find useful?"

Mainly that they're interpreted the same way by all software. For example, if I happen to open a bit of source code in notepad or type it in a command window, it'll typically look just right if I've used spaces, and unreadable if I've used tabs.

Re:Why put tabs in code anyway? (0)

Anonymous Coward | more than 4 years ago | (#30886472)

You need to use spaces for fine-indenting on line continuations anyway. May as well just use them the whole time instead of having a mixture.

What I mean by that is say I'm calling a function with numerous arguments, so I start a new line partway through. With using only tabs, the majority of the time you will not be able to get the second row of arguments to start at the same position as the first row of arguments and it will look ugly, so you need to fine tune the line with spaces. On top of that, you can't tab as far as possible and then fine-tune, because then if someone else views the file with a different tab-size, it will be off. You need to run out the same amount of tabs as you had on the previous line and then use spaces the rest of the way to keep things in synch.

Re:Why put tabs in code anyway? (5, Insightful)

yvajj (970228) | more than 4 years ago | (#30886146)

The biggest benefit to tabs (especially if you code in a corporate environment) is that people can view the code based on *their* preferred indentation / spacing e,.g. I may like my tabs to be 2 spaces, another developer may prefer 3 or 4 spaces.

By setting up their IDE / editor to their preferred tab width, the code indents to the way they like it.

By forcing all your tabs to be spaces, anyone else viewing the code will be forced to view / edit it in your indentation.

Re:Why put tabs in code anyway? (1)

Lord Kano (13027) | more than 4 years ago | (#30886192)

By forcing all your tabs to be spaces, anyone else viewing the code will be forced to view / edit it in your indentation.

I think that's precisely the point. They've decided what the optimal indentation is and they're going to force everyone else to see it their way.

LK

Re:Why put tabs in code anyway? (1)

TrancePhreak (576593) | more than 4 years ago | (#30886256)

You can still set the indentation. They are merely merging tab size & indentation.

Re:Why put tabs in code anyway? (1)

nhytefall (1415959) | more than 4 years ago | (#30886664)

Programmers.... always telling us what to do.

Re:Why put tabs in code anyway? (2, Insightful)

harryjohnston (1118069) | more than 4 years ago | (#30886420)

That's a valid point, although I'm not sure how you avoid a mixture of tabs and spaces, which would make the code look completely wrong (instead of just a bit wrong!) for everybody else.

Re:Why put tabs in code anyway? (0)

Anonymous Coward | more than 4 years ago | (#30886502)

Exactly. In my place, tabs are used for indentation and spaces are used for formatting. It stops the bullshit that some like 2 space indent, other likes 3 and some other may prefer 4 or 6 or even 8.

To make sure everyone knows what they are using and not to fsck up, spaced/tabs visualization is enabled.

Re:Why put tabs in code anyway? (1)

Lord Kano (13027) | more than 4 years ago | (#30886148)

So, for all those tab fans, what is it about tabs that you find useful?

When you find yourself debugging an If inside of a For inside of a While inside of an Else, I find it easier to visualize which level in I'm at by the number of tabs.

LK

Re:Why put tabs in code anyway? (1)

harryjohnston (1118069) | more than 4 years ago | (#30886406)

How do you see the tabs?

Re:Why put tabs in code anyway? (3, Insightful)

Nikker (749551) | more than 4 years ago | (#30886164)

I don't have to backspace many times when I remove nested loops and they always line up properly (a personal thing that drives me nuts when two lines in the same scope don't line up) and it only needs one tap of a button to make it done. Hitting the space bar isn't a bad thing but it just feels inefficient when you have to repeat it so many times also most editors will allow you to highlight code blocks and use tab or shift-tab to increase/decrease white space which I'm not sure if they will do the same for you for spaces.

Re:Why put tabs in code anyway? (1)

harryjohnston (1118069) | more than 4 years ago | (#30886432)

If they're properly coded, they will. Visual Studio certainly does.

Re:Why put tabs in code anyway? (1)

SpryGuy (206254) | more than 4 years ago | (#30886696)

Dude, the editor takes care of that for you. Why micromanage spaces and alignment when that's what computers are good for? There's a reason things like ReSharper exist. I never ever use tabs (option is set to insert spaces instead), and I've never had to deal with any of these issues the "tabs not spaces" crowed insist exist if you use spaces.

And of course selecting text and using Tab/Shift-Tab to change indenting works just fine if you're not using tab characters. Why wouldn't they?

Re:Why put tabs in code anyway? (0)

Anonymous Coward | more than 4 years ago | (#30886166)

makefile... If you ever have to hand edit one, you'll find that it refuses to work with spaces instead of tabs.

Don't ask me why, but the open source people are inflexible about their version of make.

Re:Why put tabs in code anyway? (3, Insightful)

harryjohnston (1118069) | more than 4 years ago | (#30886442)

Don't get me started on makefiles. An syntactically significant invisible character? Dumbest idea ever.

Re:Why put tabs in code anyway? (1)

poopdeville (841677) | more than 4 years ago | (#30886730)

When did \n become a visible character? Just about every language I know of uses \n as a syntactically significant character... spaces are syntactically significant in most mainstream languages too. You always need at least one between tokens, right? That makes them syntactically significant.

Re:Why put tabs in code anyway? (0)

Anonymous Coward | more than 4 years ago | (#30886208)

Using tabs means I'm not a fag. Just sayin.

Re:Why put tabs in code anyway? (1)

TrancePhreak (576593) | more than 4 years ago | (#30886228)

If you need to go back and comment out some lines or something then spaces will screw up and tabs will not.

void foo(bool something)
{
..if (something)
..{
//....int blah = 0;
//....void* v =
....something = false;
..}
}

Re:Why put tabs in code anyway? (1)

harryjohnston (1118069) | more than 4 years ago | (#30886470)

Could you expand on this a little? I don't get it.

Re:Why put tabs in code anyway? (1)

JimboFBX (1097277) | more than 4 years ago | (#30886626)

He forgot to use the code tag. Except his example using "..." to represent a section of whitespace just shows he's not only new around here, but to coding as well. Never tab after non-white space characters. In his example he stuck the "//" at the beginning of the line and was indenting after it.

Re:Why put tabs in code anyway? (5, Insightful)

nmb3000 (741169) | more than 4 years ago | (#30886268)

So, for all those tab fans, what is it about tabs that you find useful?

  1. I can have my indent be 2 spaces and you can have it be 8 spaces, all without changing the source code.
  2. Files are not constantly being changed and updated in the source control system due to the number of spaces changing as different developers edit the code.
  3. If I want to print out a section of code, I can modify the tab/space equivalency so that the lines easily fit on the page without wrapping.
  4. Tabs provide a one-to-one relationship between the level of indentation and the number of characters used. This isn't usually a big deal, but in terms of parsing and editing I personally find this more elegant than using spaces (an inconsistent many-to-one relationship).
  5. It saves electrons. One tab character generally fills the shoes of four space characters. That's a savings of 75%! Smaller storage and transmission requirements means fewer servers in the datacenter which means less heat created which means smaller refrigeration units which means less energy consumed which means fewer greenhouse gases emitted which means less global warming which means continued survival of the human species.

So there you go. In addition to just being more manageable and flexible, using tabs over spaces will help ensure the future existence of the human species on this planet.

Okay, so while the last point was in jest (mostly ;), I stand by the first four. Honestly, I've yet to see any pro-spaces people give any substantial reasons (when applied to modern computers and development tools) that spaces work better than tabs.

So, for all those space fans, what is it about spaces that you find useful?

Re:Why put tabs in code anyway? (4, Insightful)

nmb3000 (741169) | more than 4 years ago | (#30886336)

I know it's bad form to reply to yourself, but really Slashdot? THAT is how you render an HTML ordered list? What blind, drunk monkey on an acid trip designed that stylesheet?

Of course the icing on the cake is that in the preview it was properly rendered as an ordered numeric list. WTF, Taco?

Oh, look at the name of the CSS files responsible: idlecore-tidied.css. Makes sense now I suppose. Anything to do with idle.slashdot is already horribly broken.

Re:Why put tabs in code anyway? (3, Funny)

Bill Dog (726542) | more than 4 years ago | (#30886488)

You mean you can't see the brilliance of a preview mode that doesn't match what the real thing will look like? ;)

Re:Why put tabs in code anyway? (0)

daVinci1980 (73174) | more than 4 years ago | (#30886550)

Spaces work better than tabs because the code is always formatted properly. Code that is formatted improperly does not do what you think it does. This matters a lot when you have projects developed by 200+ developers with multiple millions of LOC. It matters even more when you have 3000+ developers working on many such code bases and they move between said projects with high frequency.

You cannot have your indent be two and me with 8 and have the code line up properly, especially when lining up complex if or math statements (where you may be using the level of indent to help with showing how the parens or operators nest). While you could argue "then split into multiple statements", I could argue "it's actually more readable as is". Subjective is neat that way.

Files that are being constantly updated because someone doesn't like someone elses formatting is dumb. Have a standard, stick to it. Fire the offender who refuses to play ball, problem solved.

Who prints code? Fine, let's say you do. Modifying the number of spaces per tab causes the issue I pointed out at phase 1.

Relationship argument makes no sense to me, sorry. Where the code lines up is what matters to me, not how many invisible characters appear between the beginning of the line and the first character.

Re:Why put tabs in code anyway? (2, Insightful)

Blakey Rat (99501) | more than 4 years ago | (#30886274)

If you use Tab characters, everybody on your team can pick whatever tab level they prefer. In short, everybody's happy.

If you use Space characters, and you prefer 4 spaces but someone else prefers 2, well, then they're fucked. (Or you're fucked. Somebody's going to be unhappy.)

Frankly, from a logical perspective, I've never figured out what benefit spaces have over tabs... my guess is that it's related to, "I learned programming in 1976 and damned if I'm going to change my extremely ancient and obsolete habits for you young un's. Also, get off my lawn!!"

Re:Why put tabs in code anyway? (1)

mrboyd (1211932) | more than 4 years ago | (#30886320)

So, for all those tab fans, what is it about tabs that you find useful?

  • When I want to dedent I can press del once, not four times.
  • I like my code when the indent size is about 4 space wide, my neighbor likes his code cramped at 2 spaces and some other weird people like it at 8 spaces. With tab and the editor settings we can all get what we want. Without generating a whole file modification changeset each time we decide to disagree on code spacing.
  • ~15% in code file size reduction. I know, who cares, but still.. It feels cleaner.
  • The key is called "Tab" when I press it I want a \t not random number of spaces. I don't care that VT-XYZ did not support it in 1980.

What are the benefits of using spaces in 2010? The only rational I've heard is that back in the time of computer dinosaurs some editors only knew how to render tab with 8 spaces and that was too much for the people who had 80 columns screens so they decided to type 4 spaces instead of using the tab character. So more code would fit on their screen.

Re:Why put tabs in code anyway? (1)

MichaelSmith (789609) | more than 4 years ago | (#30886348)

The only real problem I have with tabs is when they get used other than for indenting, as a way of inserting three spaces because that was the distance to the next tab stop when the code was last touched. Then somebody inserts characters earlier in the line and bizarre things start happening over to the right. I think its that kind of thing which sometimes get tabs banned in some environments.

Re:Why put tabs in code anyway? (0)

Anonymous Coward | more than 4 years ago | (#30886580)

1 ASCII character vs N characters.

Re:Why put tabs in code anyway? (1)

Punto (100573) | more than 4 years ago | (#30886608)

tabs can be displayed any way you like. if you indent with 4 spaces, the tab can be 4 spaces. if you indent with 9 spaces, the tab can be 9 spaces. everyone can configure their own editor the way they like it. if you use spaces, you're forcing your own indenting preference (which is probably stupid and ugly) on everyone else.

Re:Why put tabs in code anyway? (1)

SpryGuy (206254) | more than 4 years ago | (#30886650)

I'm with you. I *hate* tabs embedded in source files. They're nothing but trouble for all the reasons cited in TFA by those who want the setting separated.

I always set the "Insert spaces" option for tabs, and the first thing I do with any legacy code or other code I take over is "untabbify" the entire thing. I've worked to make it part of our coding standards that there be NO TABS in source files.

Tabs provide no benefit, and cause nothing but problems. You are correct: they irritating and utterly unnecessary.

This is bad (1, Flamebait)

mysidia (191772) | more than 4 years ago | (#30886036)

It's an example of Microsoft imposing a policy decision on users of the software. Some of them don't want this, but they're going to be forced to do it this way because Microsoft is defining a tab policy

The problem with this is.... old code, created with different settings in VS 2008 or earlier.

And the need to be able to open it in VS 2010 and actually make sense out of it.

E.g. backwards compatibility.

Also, configurability of tab width and indent width is probably a good thing.

If the other editors can't config tab width, they suck.

Obviously companies and developers using the software should have coding standards that specify what tab width and indent width to use (normally 4 spaces)

But still, regardless of software used, the number of spaces to use for a tab is a policy thing, that should be dictated by the developer(s) or their company.

Re:This is bad (1)

MichaelSmith (789609) | more than 4 years ago | (#30886050)

Also commit policies. Even if it leaves untouched lines alone you might have fiddled with the indenting of a line you didn't intend to commit a change to.

Re:This is bad (0)

Anonymous Coward | more than 4 years ago | (#30886140)

None of your rant has anything to do with the article. VS still allows you to configure the number of spaces to use for a tab. The issue here is that there is no UI way anymore to set an indent size different from the tab size, an unusual (but apparently not unheard-of) requirement. However, in that bug, the Microsoft PM also posted the source code required to configure it separately. Which, considering Visual Studio is a developer tool, isn't all that unreasonable.

Re:This is bad (1)

scdeimos (632778) | more than 4 years ago | (#30886480)

FWIW, "Brittany" did have this to say:

I would encourage anyone who would prefer VS return to two separate options to vote on this bug, as your feedback can certainly influence decisions about this issue in the future.

So, would the six Microsoft developers reading /. please go and place your votes?

Personally, I find it interesting that the change is about coalescing the "tab stops" and "indent characters" into a single setting and yet discussion has boiled down to a Tabs vs. Spaces debate. Oh that's right, nobody reads TFA around here.

close to dropping /. (1)

MarkvW (1037596) | more than 4 years ago | (#30886264)

Tabs are news?

Have you no sense of responsibility to your audience?

What's that old saw? (3, Insightful)

liquiddark (719647) | more than 4 years ago | (#30886276)

Herb Sutter once observed in relation to C++0x that when it comes to complex, interesting questions of language design, very few people are even vaguely qualified to comment, and when it comes to issues of whitespace every idiot on the planet has an opinion. And when those idiots get the chance, they'll post those issues as news on an aggregator of some sort (ok, that last part wasn't Herb Sutter).

Not just Microsoft... (1)

Angst Badger (8636) | more than 4 years ago | (#30886436)

For years, Microsoft has allowed Visual Studio users to define arbitrary tab widths, often to the dismay of those viewing the resultant code in other editors.

There are editors that don't let you define arbitrary tab widths? No, seriously -- I'm not sure I've ever seen an editor that didn't provide the option, generally along with the option to have the tab key insert spaces instead of tabs, thereby avoiding that issue and the inevitable problems that arise as tabs and spaces are mixed.

And if that doesn't work, there's this really newfangled tool called indent that you can use...

Tabs = Evil (1)

Korbeau (913903) | more than 4 years ago | (#30886524)

Plain and simple. If they standardized tabs with a quantity of space chars in all their editors then it is very, very good news. That's the only way to have consistency across all viewers/editors.

Isn't 8 the "standard"? (1)

VortexCortex (1117377) | more than 4 years ago | (#30886688)

Standardized tabs was great back in the old "10: if ( x ) goto 100" days...

But today 8 spaces per tab is far too much for most folks.
Nearly all newer code has portions that are deeply nested.

if ( x ) {
        x.addEventListener (
                "hover",
                function() {
                        window.status = "Hovering Over X";
                        x.changeColor (
                                {
                                        text: "green",
                                        background: "black",
                                        outline: "white"
                                }
                        );
                },
                true
        );
}

This is a mild example of 5 levels of nesting.

Some code is more deeply nested than others, and some fonts are wider than others.
Changing the tab spacing let's us see more without having to scroll horizontally decrease our font size.

Here's the same code with 1/2 the tab width.

if ( x ) {
    x.addEventListener (
        "hover",
        function() {
            window.status = "Hovering Over X";
            x.changeColor (
                {
                    text: "green",
                    background: "black",
                    outline: "white"
                }
            );
        },
        true
    );
}

What looks fine on my screen may look very different on someone else's.
Using tabs and editors that allow tab size adjustment allows coders to manage the source code more efficiently.

The only way to maintain sanity (2, Insightful)

Technomancer (51963) | more than 4 years ago | (#30886600)

in cross-platform project is to force everyone to use spaces only.
The shit that happens to code with tabs that get edited on unix and windows and different editors make the text to travel towards the right side of screen at exponentially increasing speeds.
Add some retarded editors and direct copying of sources between unix and windows without going through source control system that converts line endings and you will also have empty lines being added as well.
The end result is 1/100 ratio between code and whitespace.
Hello from the trenches ;-)

TABS (0)

Anonymous Coward | more than 4 years ago | (#30886686)

Terrific Alternative, Beyond Spaces!

Editor Features (1)

dziman (415307) | more than 4 years ago | (#30886766)

Honestly, where is the editor that has at least as much functionality aimed at a developer as a word processor? I'm not saying the SAME functionality, but an equal amount of functionality.

As for the same functionality, starting with a spell checker for comments (in the very least) would be kinda nice.

Load More Comments
Slashdot Login

Need an Account?

Forgot your password?