www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Fatal flaw in D design which is holding back widespread adoption

reply Matt <euroquigs hotmail.com> writes:
Hello all.  I've been so fascinated with D ever since I first read about it a
few years ago.  I read the design descriptions and language features just for
fun sometimes at work when I'm bored.

It makes me so sad, though, that the language will never take off because of
one fatal flaw that plagues the widespread adoption of the language.  It's a
flaw that makes educated people move on because they simply won't take the
language seriously.  I daresay there have been millions who were about to learn
D and then found out this flaw, unfortunately figured it was a beginner's
language, and moved on to another exciting new language.

The fatal flaw is that tabs are 8 characters in D's official style guide,
including Phobos and other official D source code.  WTF???? Lolz, is it 1968? 
Not only that, but INDENTION IN D is 4 CHARACTERS.  That's right, I'm not
kidding... tabs are 8 characters but indention is 4 characters.  I truly
apologize to you people who were born in 1950 or earlier who actually don't
understand why this idea is retarded.  Tabs have been 4 characters for DECADES
now.  

What's that comment from the back?  Speak up!  Oh, haha well, you say that most
printers use 8 characters for tabs, so D should consider them the same? 
HAHAHAHA I think you want me to throw this pie in your face.  This is 2010.  We
don't print source code with dot matrix printers!  Not only that, we don't F'N
PRINT SOURCE CODE, have you ever heard of the Internet?  Why would you waste
paper anyways?  We won't be printing ANYTHING in an office in another decade.

Oh you guys, stop telling me it's no big deal and I need to try it.  I did! 
Can you believe it, the source code that comes with the D implementations is
indented by 4 characters... but get this, whoever wrote this stuff used 4
spaces on odd columns, and tabs for 8 spaces on even lines!  No kidding?  Have
you tried maneuvering with the arrow keys around that crap?  Yeah, it's like a
joke source code, something you give to someone on April Fools day to give them
a hard time.  You never know what pressing UP, DOWN, LEFT, or RIGHT will get
you when you're navigating the indented space to the left of the source code. 
Sometimes it jumps left by 2 columns (i.e. 8 characters), but sometimes it only
moves 1 character.  You never know until you try it.

I mean, who goes through the trouble of pressing tab, then figuring out he
didn't want to indent 8 characters because he's on an odd column, so he presses
backspace and then the spacebar 4 times.  Of course, he has to do this all the
time because when he's not concentrating on indention, he doesn't remember
which column uses spaces and which ones he'll have to press tab for.  Or does
he always use spaces, and then go back and optimize any 8 spaces he finds in
the indented area with tabs?

And then, as always, the comments that MY editor is too old to handle this, and
that all modern editors should be able to automate the indention process.  They
should, in theory, use the tab key to generate spaces when needed, or tab
characters when needed.  Or, they should automate save actions which affect the
indention area, defined as whitespace on a line before non-whitespace, by
replacing 8 character spaces with tabs.  Hhhmph, so it's my fault now?  I
shouldn't be using notepad, I should be using YOUR editor which makes your
faulty method work?  Oh sure, blame me.  But I'm not the retard who said tabs
are 8 characters, indentions are 4 characters, and just mix 'em up and have fun!

Maybe there will be a D 3.0 which will fix this fatal absence of logical design
and reasoning.  Well, a boy can dream...

http://www.digitalmars.com/d/2.0/dstyle.html
Mar 30 2010
next sibling parent reply Don <nospam nospam.com> writes:
Matt wrote:
 Hello all.  I've been so fascinated with D ever since I first read about it a
few years ago.  I read the design descriptions and language features just for
fun sometimes at work when I'm bored.
 
 It makes me so sad, though, that the language will never take off because of
one fatal flaw that plagues the widespread adoption of the language.  It's a
flaw that makes educated people move on because they simply won't take the
language seriously.  I daresay there have been millions who were about to learn
D and then found out this flaw, unfortunately figured it was a beginner's
language, and moved on to another exciting new language.
 
 The fatal flaw is that tabs are 8 characters in D's official style guide,
including Phobos and other official D source code.  
It's being phased out of Phobos, in D2 it only exists now in the really old stuff which is scheduled for deprecation. That particular convention has only ever been followed by Walter. So the DMD source code (which is written in C++, not D) will probably always use that idiosyncracy, but I don't think anything else will. I think that the style guide should be removed. It's rather obsolete and was never completely accepted. It's misleading, and not adding much value any more.
Mar 30 2010
parent reply bearophile <bearophileHUGS lycos.com> writes:
Don:
 I think that the style guide should be removed. It's rather obsolete and 
 was never completely accepted. It's misleading, and not adding much 
 value any more.
A style guide is important to increase the uniformity of code written in D, I have followed most of it in my dlibs1. One of the main purposes of a module system is to help sharing working units of code. Conventions are important when you want to use modules written by other people. The C/C++ code you can find in value of more uniformity. Too much freedom in style and form is not positive. D can improve on this too compared to C/C++. Tango team has not followed it and I think they are partially wrong. So I think the D style guide should be kept, improved, and better enforced, few bits of Phobos2 can be changed to follow the conventions more (for example the name of some templates of D2 can start with an upper case). Once the style guide is updated, Andrei can follow it. Bye, bearophile
Mar 30 2010
parent reply Matt <euroquigs hotmail.com> writes:
 Don:
 I think that the style guide should be removed. It's rather obsolete and 
 was never completely accepted. It's misleading, and not adding much 
 value any more.
A style guide is important to increase the uniformity of code written in D, I have followed most of it in my dlibs1. One of the main purposes of a module system is to help sharing working units of code. Conventions are important when you want to use modules written by other people. The C/C++ code you can find in value of more uniformity. Too much freedom in style and form is not positive. D can improve on this too compared to C/C++.
forces you to do your OWN style in any particular way. But having a uniform presentation in the shared language code goes a long way in learning and adoption. And although my original post was semi-joking... much of me has seriously thought when first perusing the language and code examples, "Why would someone mix tabs and spaces together and write a style guide saying that it's SUPPOSED to be that way? This language must be a joke..." I know this conversation thread is a silly anecdote to many hardcore readers in this newsgroup, but it's message is dead-on serious when it applies to intelligent outsiders who peruse D, and sophomores in college trying to learn how to program, among others.
Mar 30 2010
parent Walter Bright <newshound1 digitalmars.com> writes:
Matt wrote:
 I know this conversation thread is a silly anecdote to many hardcore readers
 in this newsgroup, but it's message is dead-on serious when it applies to
 intelligent outsiders who peruse D, and sophomores in college trying to learn
 how to program, among others.
The thing is, often people focus on something silly when deciding what technology to use. For example, just go to any C++ forum and say you don't use C++ because of X. You'll get a million vehement responses saying how X isn't really an issue and has a trivial workaround.
Mar 30 2010
prev sibling next sibling parent reply "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Tue, 30 Mar 2010 14:52:47 -0400, Matt <euroquigs hotmail.com> wrote:

 It makes me so sad, though, that the language will never take off  
 because of one fatal flaw that plagues the widespread adoption of the  
 language.  It's a flaw that makes educated people move on because they  
 simply won't take the language seriously.  I daresay there have been  
 millions who were about to learn D and then found out this flaw,  
 unfortunately figured it was a beginner's language, and moved on to  
 another exciting new language.
[...]
 Hhhmph, so it's my fault now?  I shouldn't be using notepad, I should be  
 using YOUR editor which makes your faulty method work?  Oh sure, blame  
 me.  But I'm not the retard who said tabs are 8 characters, indentions  
 are 4 characters, and just mix 'em up and have fun!
I agree. Something has to be done to capture the millions of serious non-beginner developers using notepad to write code. Walter, make this -Steve
Mar 30 2010
parent reply Matt <euroquigs hotmail.com> writes:
Steven Schveighoffer Wrote:

 I agree.  Something has to be done to capture the millions of serious  
 non-beginner developers using notepad to write code.  Walter, make this  

 
Haha, good comeback! :) BTW, I hope nobody serious is using Notepad. The point still stands, and I'm glad that others agree that the style guide should either be removed, or if there ever were an official style guide then that particular idiosyncrasy would be altered.
Mar 30 2010
next sibling parent reply "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Tue, 30 Mar 2010 16:48:08 -0400, Matt <euroquigs hotmail.com> wrote:

 Steven Schveighoffer Wrote:

 I agree.  Something has to be done to capture the millions of serious
 non-beginner developers using notepad to write code.  Walter, make this

Haha, good comeback! :) BTW, I hope nobody serious is using Notepad. The point still stands, and I'm glad that others agree that the style guide should either be removed, or if there ever were an official style guide then that particular idiosyncrasy would be altered.
Couldn't help myself :) Yes, I do agree the style guide should be updated. However, I really really don't agree that the style guide is dissuading would-be adopters of D. A style guide is just a guide, it's not a requirement. Most people ignore it. -Steve
Mar 30 2010
parent reply bearophile <bearophileHUGS lycos.com> writes:
Steven Schveighoffer:
A style guide is just a guide, it's not a requirement.  Most people ignore it.<
If most people ignore it, then it's useless or worse than useless. C/C++ programs are too much free in such regard because those languages were you will see class methods written with a starting upper case. If you download code from most Python repositories you will usually find Classes, variable_names, etc. Bye, bearophile
Mar 30 2010
parent reply "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Tue, 30 Mar 2010 17:16:19 -0400, bearophile <bearophileHUGS lycos.com>  
wrote:

 Steven Schveighoffer:
 A style guide is just a guide, it's not a requirement.  Most people  
 ignore it.<
If most people ignore it, then it's useless or worse than useless. C/C++ programs are too much free in such regard because those languages most sites you will see class methods written with a starting upper case. If you download code from most Python repositories you will usually find Classes, variable_names, etc.
I guess, but when I write code in languages I'm not used to, I just use D) code uses lowerCamelCase for methods and properties. It doesn't make it any less readable, and it doesn't make it useless, it's just different than other projects. I just don't see a style guide as being that important for either adoption or readability. I think it is important that the same style be kept within a project, but other than that, anything is fair game to me. Let's not make this into a big deal, unified style is not that important in the grand scheme of things. -Steve
Mar 30 2010
parent bearophile <bearophileHUGS lycos.com> writes:
Steven Schveighoffer:


properties.<
code, you will find people that complain if you want to give/share/show them enough time).
I think it is important that the same style be kept within a project,<
Let's not make this into a big deal, unified style is not that important in the
grand scheme of things.<
You have missed an essential detail of my post. D and Python have modules. A well designed module system allows something very important, that's mostly absent in units of C/C++ code. If you go here http://pypi.python.org/pypi you can find tons of Python libraries, they are often single modules, and other times they are packages. The success of languages like Python partially comes from the fact that you can take one of those modules (or packages) and put it into your project, and often it just works and looks almost like a part of it. If everybody writes Python code following a common style, then the "project" becomes the whole ecosystem of the language, and not just your project. You need less time to read code written by other people, you save the time needed adapt yourself to their style, and when you compose a python project assembling modules and packages taken from (for example) pypi, your resulting project doesn't look like a patchwork of different styles! So having a common style has some importance in the grand scheme of things for a language with modules that hopes to build a community of shared modules. If you think some more about it I think you will agree with me. This is something that Guido Van Rossum has understood lot of time ago (and I think Walter can agree). A shared style is not necessary to build a healthy community of shared modules (see Perl CPAN, where coding style is not so uniform), but it helps. Bye, bearophile
Mar 30 2010
prev sibling parent Walter Bright <newshound1 digitalmars.com> writes:
Matt wrote:
 Haha, good comeback! :)  BTW, I hope nobody serious is using Notepad.  The
 point still stands, and I'm glad that others agree that the style guide
 should either be removed, or if there ever were an official style guide then
 that particular idiosyncrasy would be altered.
My notepad uses 8 column tabs - and it's the default behavior.
Mar 30 2010
prev sibling next sibling parent reply Lutger <lutger.blijdestijn gmail.com> writes:
Matt wrote:
 I shouldn't be using notepad, I should be using YOUR
 editor which makes your faulty method work?  
D does not support notepad.
Mar 30 2010
parent reply Walter Bright <newshound1 digitalmars.com> writes:
Lutger wrote:
 Matt wrote:
 I shouldn't be using notepad, I should be using YOUR
 editor which makes your faulty method work?  
D does not support notepad.
D doesn't care what text editor you use. BTW, type a file to a console window. Tabs come out as 8 characters, on Windows, Linux, and OSX.
Mar 30 2010
next sibling parent reply "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Tue, 30 Mar 2010 16:56:32 -0400, Walter Bright  
<newshound1 digitalmars.com> wrote:

 BTW, type a file to a console window. Tabs come out as 8 characters, on  
 Windows, Linux, and OSX.
So do 8 spaces. This is the surest way to make code easily viewable/editable anywhere. Just set the "expand tabs" option on your favorite editor. My recommendation is to say indentations are 4 spaces and tabs should not be used for indentation. -Steve
Mar 30 2010
next sibling parent Walter Bright <newshound1 digitalmars.com> writes:
Steven Schveighoffer wrote:
 On Tue, 30 Mar 2010 16:56:32 -0400, Walter Bright 
 <newshound1 digitalmars.com> wrote:
 
 BTW, type a file to a console window. Tabs come out as 8 characters, 
 on Windows, Linux, and OSX.
So do 8 spaces. This is the surest way to make code easily viewable/editable anywhere. Just set the "expand tabs" option on your favorite editor. My recommendation is to say indentations are 4 spaces and tabs should not be used for indentation.
Sure, that's a good plan. My only objection was with the notion that 8 character tabs only appear in printers. He's right in that I never print source code anymore, haven't in decades, but I do type to the screen all the time.
Mar 30 2010
prev sibling parent reply "Nick Sabalausky" <a a.a> writes:
"Steven Schveighoffer" <schveiguy yahoo.com> wrote in message 
news:op.vaefb7p3eav7ka localhost.localdomain...
 On Tue, 30 Mar 2010 16:56:32 -0400, Walter Bright 
 <newshound1 digitalmars.com> wrote:

 BTW, type a file to a console window. Tabs come out as 8 characters, on 
 Windows, Linux, and OSX.
So do 8 spaces. This is the surest way to make code easily viewable/editable anywhere. Just set the "expand tabs" option on your favorite editor. My recommendation is to say indentations are 4 spaces and tabs should not be used for indentation.
I've always found using spaces for indentation to make editing a real PITA. (Why woudn't I rather be able to move in/out one level of indentation with one arrow-key press instead of 4 (or so) ?) But really, I don't see why the whole issue hasn't already been made 100% personal style by a VCS that handles it the same way SVN handles EOLs. If one person has problems involving another person using a different indentation system, then at least one of them is doing something very wrong. Seriously, how is it that this is 2010, we have things like syntax highlighting as standard featutres in every editor that anyone ever actually uses...and yet the whole world of programmers still can't abstract away something as simple as f*cking tab sizes? Bah!
Mar 30 2010
next sibling parent reply Walter Bright <newshound1 digitalmars.com> writes:
Nick Sabalausky wrote:
 But really, I don't see why the whole issue hasn't already been made 100% 
 personal style by a VCS that handles it the same way SVN handles EOLs. If 
 one person has problems involving another person using a different 
 indentation system, then at least one of them is doing something very wrong. 
 Seriously, how is it that this is 2010, we have things like syntax 
 highlighting as standard featutres in every editor that anyone ever actually 
 uses...and yet the whole world of programmers still can't abstract away 
 something as simple as f*cking tab sizes? Bah!
It all started in the 80's when someone wrote a text editor that had customizable tab lengths (before then, tabs were 8. End of story.). Things went downhill from there. Since there's no way for an editor to figure out what the tab setting might be for any particular file, the only solution that works is to not use tabs. Thanks to some nameless programmer who ruined it for everyone <g>.
Mar 30 2010
parent reply "Nick Sabalausky" <a a.a> writes:
"Walter Bright" <newshound1 digitalmars.com> wrote in message 
news:houh5g$29cs$1 digitalmars.com...
 Nick Sabalausky wrote:
 But really, I don't see why the whole issue hasn't already been made 100% 
 personal style by a VCS that handles it the same way SVN handles EOLs. If 
 one person has problems involving another person using a different 
 indentation system, then at least one of them is doing something very 
 wrong. Seriously, how is it that this is 2010, we have things like syntax 
 highlighting as standard featutres in every editor that anyone ever 
 actually uses...and yet the whole world of programmers still can't 
 abstract away something as simple as f*cking tab sizes? Bah!
It all started in the 80's when someone wrote a text editor that had customizable tab lengths (before then, tabs were 8. End of story.). Things went downhill from there. Since there's no way for an editor to figure out what the tab setting might be for any particular file, the only solution that works is to not use tabs. Thanks to some nameless programmer who ruined it for everyone <g>.
See, I think this is looking at things completely backwards: "...there's no way for an editor to figure out what the tab setting might be for any particular file...". Now that Pandora's box is open (or heck, even if it weren't), it makes sense to think of tab as meaning "indent" abstractly and *not* "x number of spaces". Ie, "Tab setting for a given file" should be viewed as a nonsensical concept, as "tab-size" is (or rather SHOULD be considered) purely a presentation concept (Granted, mixed-spaces/tabs screw that up, but nearly everyone considers mixed spaces/tabs to be evil anyway, and it's not as if there's a chance of that genie ever getting back into his bottle). The consequence of this approach is that people can set their tabsizes to whatever the hell they want, and things will *just work*. If someone wants their editor to behave as if the tabs are a series of x-number spaces, then fine, it can do that and convert back to tabs (ie, "indents") upon saving (or the VCS can do it in much the same way SVN and FTP can take care of line-endings). In that case it's, in effect, still just a UI-only concept. This way, in all but that absolute weirdest of the weird situations (specifically, people and apps that insist on mixing tabs and spaces), everyone eats their cake and still has it. But then some people insist on always using spaces instead of a dedicated indent symbol (ie, "tab"), thus destroying indent-size as a user-setting, all for absolutely no real benefit to anyone. And then editors do none of the rather simple things they could do to mitigate tab/space mixing. So there too, the problem persists. And then a tiny handful of people actually go mixing tabs and spaces on a regular basis. Totally fucks things up too. There's absolutely no need whatsoever for any kind of magical "figure out the tab-size for a file". Everyone can have everything the way *they* want it without screwing up anything for anyone else all by the convention of treating tab as *the* "indent" symbol. (Note that this *is* very different from the "everyone will get along if they just think like I do" argument pattern.)
Mar 30 2010
next sibling parent reply Walter Bright <newshound1 digitalmars.com> writes:
Nick Sabalausky wrote:
 There's absolutely no need whatsoever for any kind of magical "figure out 
 the tab-size for a file". Everyone can have everything the way *they* want 
 it without screwing up anything for anyone else all by the convention of 
 treating tab as *the* "indent" symbol. (Note that this *is* very different 
 from the "everyone will get along if they just think like I do" argument 
 pattern.)
That would work for indent, but nothing else (such as tabbing over to the comment column).
Mar 31 2010
next sibling parent reply Bane <branimir.milosavljevic gmail.com> writes:
I wonder do Python folks have same problems.
Mar 31 2010
next sibling parent Fawzi Mohamed <fawzi gmx.ch> writes:
Tabs versus Spaces:
An Eternal Holy War.

http://www.jwz.org/doc/tabs-vs-spaces.html

:)
Mar 31 2010
prev sibling parent reply bearophile <bearophileHUGS lycos.com> writes:
Bane:
 I wonder do Python folks have same problems.
In Python3+ if you mix tabs and spaces to indent code, the "interpreter" raises a parsing error. So you are forced to use only tabs or only spaces to indent code. Only really newbies mix tabs and spaces in Python 2.x code. And the Python coding standards (PEP8, http://www.python.org/dev/peps/pep-0008/ ) says: "Use 4 spaces per indentation level." And all a little serious Python programmers follow it. Bye, bearophile
Mar 31 2010
parent "Matthias Pleh" <matthias.pleh ltw.at> writes:
"bearophile" <bearophileHUGS lycos.com> schrieb im Newsbeitrag 
news:hov7j7$svd$1 digitalmars.com...
 Bane:
 I wonder do Python folks have same problems.
In Python3+ if you mix tabs and spaces to indent code, the "interpreter" raises a parsing error. So you are forced to use only tabs or only spaces to indent code. Only really newbies mix tabs and spaces in Python 2.x code. And the Python coding standards (PEP8, http://www.python.org/dev/peps/pep-0008/ ) says: "Use 4 spaces per indentation level." And all a little serious Python programmers follow it. Bye, bearophile
And the D dstyle doc (http://www.digitalmars.com/d/2.0/dstyle.html) says: "Each indentation level will be four columns" and "Using spaces instead of tabs is preferred" And all a little serious D programmers follow it. Bye, nocide
Mar 31 2010
prev sibling parent "Nick Sabalausky" <a a.a> writes:
"Walter Bright" <newshound1 digitalmars.com> wrote in message 
news:houstg$44a$1 digitalmars.com...
 Nick Sabalausky wrote:
 There's absolutely no need whatsoever for any kind of magical "figure out 
 the tab-size for a file". Everyone can have everything the way *they* 
 want it without screwing up anything for anyone else all by the 
 convention of treating tab as *the* "indent" symbol. (Note that this *is* 
 very different from the "everyone will get along if they just think like 
 I do" argument pattern.)
That would work for indent, but nothing else (such as tabbing over to the comment column).
I was only talking about indent. The rest should just be spaces.
Mar 31 2010
prev sibling parent Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
Nick Sabalausky wrote:
 "Walter Bright" <newshound1 digitalmars.com> wrote in message 
 news:houh5g$29cs$1 digitalmars.com...
 Nick Sabalausky wrote:
 But really, I don't see why the whole issue hasn't already been made 100% 
 personal style by a VCS that handles it the same way SVN handles EOLs. If 
 one person has problems involving another person using a different 
 indentation system, then at least one of them is doing something very 
 wrong. Seriously, how is it that this is 2010, we have things like syntax 
 highlighting as standard featutres in every editor that anyone ever 
 actually uses...and yet the whole world of programmers still can't 
 abstract away something as simple as f*cking tab sizes? Bah!
It all started in the 80's when someone wrote a text editor that had customizable tab lengths (before then, tabs were 8. End of story.). Things went downhill from there. Since there's no way for an editor to figure out what the tab setting might be for any particular file, the only solution that works is to not use tabs. Thanks to some nameless programmer who ruined it for everyone <g>.
See, I think this is looking at things completely backwards: "...there's no way for an editor to figure out what the tab setting might be for any particular file...".
My strategy for saving time: stop reading a post as soon as I detect it's even remotely pro-tabs. Andrei
Mar 31 2010
prev sibling parent reply Jacob Carlborg <doob me.com> writes:
On 3/31/10 03:53, Nick Sabalausky wrote:
 "Steven Schveighoffer"<schveiguy yahoo.com>  wrote in message
 news:op.vaefb7p3eav7ka localhost.localdomain...
 On Tue, 30 Mar 2010 16:56:32 -0400, Walter Bright
 <newshound1 digitalmars.com>  wrote:

 BTW, type a file to a console window. Tabs come out as 8 characters, on
 Windows, Linux, and OSX.
So do 8 spaces. This is the surest way to make code easily viewable/editable anywhere. Just set the "expand tabs" option on your favorite editor. My recommendation is to say indentations are 4 spaces and tabs should not be used for indentation.
I've always found using spaces for indentation to make editing a real PITA. (Why woudn't I rather be able to move in/out one level of indentation with one arrow-key press instead of 4 (or so) ?) But really, I don't see why the whole issue hasn't already been made 100% personal style by a VCS that handles it the same way SVN handles EOLs. If one person has problems involving another person using a different indentation system, then at least one of them is doing something very wrong. Seriously, how is it that this is 2010, we have things like syntax highlighting as standard featutres in every editor that anyone ever actually uses...and yet the whole world of programmers still can't abstract away something as simple as f*cking tab sizes? Bah!
Eclipse with descent can reformat the files to your own personal preferences.
Mar 31 2010
parent Lutger <lutger.blijdestijn gmail.com> writes:
Jacob Carlborg wrote:

 On 3/31/10 03:53, Nick Sabalausky wrote:
 "Steven Schveighoffer"<schveiguy yahoo.com>  wrote in message
 news:op.vaefb7p3eav7ka localhost.localdomain...
 On Tue, 30 Mar 2010 16:56:32 -0400, Walter Bright
 <newshound1 digitalmars.com>  wrote:

 BTW, type a file to a console window. Tabs come out as 8 characters, on
 Windows, Linux, and OSX.
So do 8 spaces. This is the surest way to make code easily viewable/editable anywhere. Just set the "expand tabs" option on your favorite editor. My recommendation is to say indentations are 4 spaces and tabs should not be used for indentation.
I've always found using spaces for indentation to make editing a real PITA. (Why woudn't I rather be able to move in/out one level of indentation with one arrow-key press instead of 4 (or so) ?) But really, I don't see why the whole issue hasn't already been made 100% personal style by a VCS that handles it the same way SVN handles EOLs. If one person has problems involving another person using a different indentation system, then at least one of them is doing something very wrong. Seriously, how is it that this is 2010, we have things like syntax highlighting as standard featutres in every editor that anyone ever actually uses...and yet the whole world of programmers still can't abstract away something as simple as f*cking tab sizes? Bah!
Eclipse with descent can reformat the files to your own personal preferences.
vote++ The descent reformatter is crazy, no matter how funky your style is the chances are pretty good you can autoformat all that pesky code written by others :) Not to mention you can use it as a tool to save time formatting yourself. I would perhaps even pay for it as a standalone utility /salestalk>
Mar 31 2010
prev sibling parent Lutger <lutger.blijdestijn gmail.com> writes:
Walter Bright wrote:

 Lutger wrote:
 Matt wrote:
 I shouldn't be using notepad, I should be using YOUR
 editor which makes your faulty method work?
D does not support notepad.
D doesn't care what text editor you use. BTW, type a file to a console window. Tabs come out as 8 characters, on Windows, Linux, and OSX.
That was supposed to be irony, like this whole thread seems to be :) Anyway, this is from the linux kernel coding standards, you might like it: Tabs are 8 characters, and thus indentations are also 8 characters. There are heretic movements that try to make indentations 4 (or even 2!) characters deep, and that is akin to trying to define the value of PI to be 3. Rationale: The whole idea behind indentation is to clearly define where a block of control starts and ends. Especially when you've been looking at your screen for 20 straight hours, you'll find it a lot easier to see how the indentation works if you have large indentations. Now, some people will claim that having 8-character indentations makes the code move too far to the right, and makes it hard to read on a 80-character terminal screen. The answer to that is that if you need more than 3 levels of indentation, you're screwed anyway, and should fix your program.
Mar 30 2010
prev sibling next sibling parent reply BCS <none anon.com> writes:
Hello Matt,

 The fatal flaw is that tabs are 8 characters in D's official style
 guide
I've said it before, the only way to have anything relating to formatting (a standard or even a standard of not having a standard) that doesn't drive half the people up the wall is to have the only legal formatting (compiler enforced) be *so bad* (and thus drive everyone up the wall) that everyone is forced to use real time auto-formatting. I'm not even half joking (maybe a third). This is not a solvable problem. That said, I think just flat out avoiding any official stance on formatting would be better than what is there. But I really have a hard time caring about the opinions of someone who would drop a language over such an issue. -- ... <IXOYE><
Mar 30 2010
parent Matt <none none.com> writes:
BCS Wrote:

 I'm not even half joking (maybe a third). This is not a solvable problem. That
said, I think just flat out avoiding any official stance on formatting would be
better than what is there. 
Indeed. I don't think it should be solved, either. I just don't think the style guide should state that tabs are 8 characters and indents are 4 characters. When that's the case, you can't use tabs to indent. You also have issues when moving around with the arrow keys in the indention areas, and other small issues. If indeed there should be 8 character tabs, then so be it. Just don't mix it up.
 But I really have a hard time caring 
 about the opinions of someone who would drop a language over such an issue.
Aww. If you couldn't tell from the humor, it was a joke. And no, I don't use notepad, either. -Matt
Apr 13 2010
prev sibling parent reply "BobR" <brhodes simple.access.com> writes:
Matt wrote:
 Hello all.  I've been so fascinated with D ever since I first read
 about it a few years ago.  I read the design descriptions and
 language features just for fun sometimes at work when I'm bored.

 It makes me so sad, though, that the language will never take off
 because of one fatal flaw that plagues the widespread adoption of the
 language.  It's a flaw that makes educated people move on because
 they simply won't take the language seriously.  I daresay there have
 been millions who were about to learn D and then found out this flaw,
 unfortunately figured it was a beginner's language, and moved on to
 another exciting new language.

 The fatal flaw is that tabs are 8 characters in D's official style
 guide, including Phobos and other official D source code.  WTF????
 Lolz, is it 1968?  Not only that, but INDENTION IN D is 4 CHARACTERS.
 That's right, I'm not kidding... tabs are 8 characters but indention
 is 4 characters.  I truly apologize to you people who were born in
 1950 or earlier who actually don't understand why this idea is
 retarded.  Tabs have been 4 characters for DECADES now.
I've used 3 ("three" the soon to be only LEGAL tab setting) for tabs for the last 20 years or so, FWIW. Try it. You will see that there is no need for 4 and more code will therefor fit on lines, not to mention the extra available comment space. Yes, more characters per line then your, decidedly, antiquated, and wasteful practice of using 4! Get with the times man! FWIW also, 2 is definitely too few. 3 is just right and if you don't agree with me and change your practice immediately, you must stop programming (in any language). You must do as I say!!! It will soon be ILLEGAL to use anything other than 3 spaces for tabs and any company selling text editors that allow changing the tab setting will be prosecuted to the full extent of THE LAW! So you see, it not only behooves you to comply, but to do so immediately and to rid your computer of any software that allows ILLEGAL setting of tabs different thatn what THE LAW OF TABS states or you may well indeed be considered a co-conspirator of the evil-ones-who-want-a-CHOICE-of-tab-setting. Don't risk personal incarceration and impounding of your assets!!! ACT NOW!
Apr 02 2010
parent reply =?ISO-8859-1?Q?Pelle_M=E5nsson?= <pelle.mansson gmail.com> writes:
Am I the only one using 4 tabs for indentation?
Apr 03 2010
parent "Simen kjaeraas" <simen.kjaras gmail.com> writes:
Pelle M=C3=A5nsson <pelle.mansson gmail.com> wrote:

 Am I the only one using 4 tabs for indentation?
I do that! With a tab size of 1. -- = Simen
Apr 03 2010