View mode: basic / threaded / horizontal-split · Log in · Help
April 12, 2011
Re: [OT] Spaces/tabs (Was: simple display (from: GUI library for D))
Am 12.04.2011 05:15, schrieb Jonathan M Davis:
> Using tabs screws with that unless you're completely 
> consistent, and while a single developer may be consistent, groups of 
> developers rarely are.
> 
> - Jonathan M Davis

Yeah that is why using spaces screws with that: While a single developer
may be consistent, groups of developers rarely are.
So there may be a developer who uses tabs instead of spaces (maybe
because he thinks his editor will convert the tabs to spaces but he
forgot to check that option in the editors settings)..
And of course then there's that guy who uses two spaces instead of four
(or whatever the convention is), at least from a level of 3 indentations
on, to save space on the screen.
And this other guy who uses eight spaces in his performance critical
code because he thinks that'll prevent unnecessary nesting..
So much for consistency.

As someone else said before: This argument works for both directions.

Cheers,
- Daniel
April 12, 2011
Re: [OT] Spaces/tabs (Was: simple display (from: GUI library for D))
"Jonathan M Davis" <jmdavisProg@gmx.com> wrote in message 
news:mailman.3412.1302578409.4748.digitalmars-d@puremagic.com...
>> On 04/11/2011 08:13 AM, Jonathan M Davis wrote:
>> > They mix tabs and spaces. On some lines, they use spaces and on others
>> > they use tabs.
>>
>> Never seen this, not even once. Messing can only happen when one
>> copy-pastes from modules using spaces.
>
> As Steve pointed out, it frequently happens when you have multiple 
> developers
> working on the same code. It may work with one developer who likes using 
> tabs,
> but as soon as you get a mix of developers, you invariably get a mix of 
> spaces
> and tabs unless _everyone_ involved is really careful, and that rarely
> happens. It's just too easy to use spaces without realizing that someone 
> else
> used tabs or even that you yourself are using spaces, depending on your
> editor's settings.
>

That applies the other way around, too.

> Using only spaces and no tabs avoids the entire issue...

It avoid the issue *as well as* using only tabs for indentation.
April 12, 2011
Re: [OT] Spaces/tabs (Was: simple display (from: GUI library for D))
> "Jonathan M Davis" <jmdavisProg@gmx.com> wrote in message
> news:mailman.3412.1302578409.4748.digitalmars-d@puremagic.com...
> 
> >> On 04/11/2011 08:13 AM, Jonathan M Davis wrote:
> >> > They mix tabs and spaces. On some lines, they use spaces and on others
> >> > they use tabs.
> >> 
> >> Never seen this, not even once. Messing can only happen when one
> >> copy-pastes from modules using spaces.
> > 
> > As Steve pointed out, it frequently happens when you have multiple
> > developers
> > working on the same code. It may work with one developer who likes using
> > tabs,
> > but as soon as you get a mix of developers, you invariably get a mix of
> > spaces
> > and tabs unless _everyone_ involved is really careful, and that rarely
> > happens. It's just too easy to use spaces without realizing that someone
> > else
> > used tabs or even that you yourself are using spaces, depending on your
> > editor's settings.
> 
> That applies the other way around, too.
> 
> > Using only spaces and no tabs avoids the entire issue...
> 
> It avoid the issue *as well as* using only tabs for indentation.

No, because you _always_ have spaces. It's not like you stop using the 
spacebar just because your tab key is actually inserting tab characters. If 
you have tabs, then you're still going to have spaces. It's just a question of 
whether those involved in the project are disciplined enough to avoid ever 
using spaces for indenting. If, on the other hand, you only allow spaces, then 
you don't have the same concern about tabs being inserted. True, someone's 
editor could be set up poorly for either situation and insert spaces where 
they shouldn't or tabs where they shouldn't, but it's generally trivial to set 
up an editor to _never_ input tabs that it's easy to make it so that tabs are 
never used. However, the same can't be said of using tabs, because it's always 
possible to input spaces with the spacebar.

It's true that people occasionally end up inserting tabs in space-only 
environments, but in my experience, it's fairly rare. It's pretty much a 
guarantee, however, that _someone_ will insert spaces in an environment where 
it's supposed to be tabs.

There's not much point in arguing the matter. Some folks prefer tabs, and some 
prefer spaces, but I believe that it's most common for spaces to be preferred 
as far as style guides go, and they're generally less error-prone simply 
because it's easy enough to set up editors so that tabs are never used, and 
you can't do the same with spaces when you're using tabs for indentation.

- Jonathan M Davis
April 12, 2011
Re: [OT] Spaces/tabs (Was: simple display (from: GUI library for D))
Spaces *should* only be used within string constants (as needed), or when
the language otherwise requires them.  The editor should format the code
according to user preferences.

Absent that, spaces represent the lowest common denominator of formatting,
so we can all use them and our text shows up as we desire regardless of
editor or setting.

Can we move along now?  This argument was old 30 years ago.  Perhaps we
should do VI vs. EMACS while we are at it.

</snipe>

On Mon, Apr 11, 2011 at 10:13 PM, Jonathan M Davis <jmdavisProg@gmx.com>wrote:

> > "Jonathan M Davis" <jmdavisProg@gmx.com> wrote in message
> > news:mailman.3412.1302578409.4748.digitalmars-d@puremagic.com...
> >
> > >> On 04/11/2011 08:13 AM, Jonathan M Davis wrote:
> > >> > They mix tabs and spaces. On some lines, they use spaces and on
> others
> > >> > they use tabs.
> > >>
> > >> Never seen this, not even once. Messing can only happen when one
> > >> copy-pastes from modules using spaces.
> > >
> > > As Steve pointed out, it frequently happens when you have multiple
> > > developers
> > > working on the same code. It may work with one developer who likes
> using
> > > tabs,
> > > but as soon as you get a mix of developers, you invariably get a mix of
> > > spaces
> > > and tabs unless _everyone_ involved is really careful, and that rarely
> > > happens. It's just too easy to use spaces without realizing that
> someone
> > > else
> > > used tabs or even that you yourself are using spaces, depending on your
> > > editor's settings.
> >
> > That applies the other way around, too.
> >
> > > Using only spaces and no tabs avoids the entire issue...
> >
> > It avoid the issue *as well as* using only tabs for indentation.
>
> No, because you _always_ have spaces. It's not like you stop using the
> spacebar just because your tab key is actually inserting tab characters. If
> you have tabs, then you're still going to have spaces. It's just a question
> of
> whether those involved in the project are disciplined enough to avoid ever
> using spaces for indenting. If, on the other hand, you only allow spaces,
> then
> you don't have the same concern about tabs being inserted. True, someone's
> editor could be set up poorly for either situation and insert spaces where
> they shouldn't or tabs where they shouldn't, but it's generally trivial to
> set
> up an editor to _never_ input tabs that it's easy to make it so that tabs
> are
> never used. However, the same can't be said of using tabs, because it's
> always
> possible to input spaces with the spacebar.
>
> It's true that people occasionally end up inserting tabs in space-only
> environments, but in my experience, it's fairly rare. It's pretty much a
> guarantee, however, that _someone_ will insert spaces in an environment
> where
> it's supposed to be tabs.
>
> There's not much point in arguing the matter. Some folks prefer tabs, and
> some
> prefer spaces, but I believe that it's most common for spaces to be
> preferred
> as far as style guides go, and they're generally less error-prone simply
> because it's easy enough to set up editors so that tabs are never used, and
> you can't do the same with spaces when you're using tabs for indentation.
>
> - Jonathan M Davis
>
April 12, 2011
Re: [OT] Spaces/tabs (Was: simple display (from: GUI library for D))
On 4/12/11, Cliff Hudson <cliff.s.hudson@gmail.com> wrote:
> Perhaps we
> should do VI vs. EMACS while we are at it.

Don't bring operating systems into this...



... just kidding. :P
April 12, 2011
Re: [OT] Spaces/tabs (Was: simple display (from: GUI library for D))
On 2011-04-11 22:09, Nick Sabalausky wrote:
> "Jonathan M Davis"<jmdavisProg@gmx.com>  wrote in message
> news:mailman.3371.1302508910.4748.digitalmars-d@puremagic.com...
>>> Jonathan M Davis Wrote:
>>>> Personally, I think that it's _horrible_ to use tabs
>>>
>>> Why would one fear tabs?
>>
>> They change depending on your editor settings. Indenting gets screwed up
>> if
>> tabs and spaces are mixed. It's just plain annoying to have an indentation
>> of
>> multiple spaces which isn't actually multiple spaces.
>>
>> The biggest problem though is that it just totally screws with indentation
>> if
>> tabs and spaces are mixed and that invariably happens.
>>
>
> You're drawing a completely invalid conclusion from that, because it works
> the same both ways. If I have a bunch of code indented with spaces, all it
> takes is a few things to be indented with tabs instead to create the *exact
> same screwup*. You've chosen tabs as the villian completely arbitrarily.
>
> Also I find your argument that the mixup is significantly more likely when
> tabs are used for indentation to be extremely questionable. You admit
> yourself that you've rarely come across situations where tabs are the
> default. So how would you know? Based on that *one* piece of anecdotal
> evidence? And even that can be suspect, because if you were involved, we
> know you're accustomed to using spaces for indentation, so that could very
> well have been the reason for the mixup.
>
> I have worked with code that used spaces as indentation on various
> occasions, and I always did wind up accidentally sticking some tabs in
> there. So I know first hand that the idea of the mixups not happening with
> space-indentation is a load of crap. They're equally likely.
>
> And as far as needing to use spaces in code anyway: That's not remotely a
> problem. People know damn well the difference between a space and
> indentation. Fuck, if MS Word users can figure it out, so can programmers.
>
>> Tabs serve no useful purpose IMHO.
>>
>
> Well, IMO, using spaces for indentation serves no useful purpose. At least
> tabs actually *mean* alignment and indentation. Spaces don't and never have.
> Plus, what's the use of being able place the cursor at arbtrary points
> within the "4 spaces" (or 8 spaces, or whatever)? All it does is make me
> have to press left/right-arrow-key a whole hell of a lot more (which I
> really do find to be a PITA). And makes it easier to accidentally end up
> with a messed up indentation of +/- 1 space somewhere. Spaces for
> indentation is just a misuse and a kludge to force on each other the
> idiologies of how large indentation should be.

So true.

-- 
/Jacob Carlborg
April 12, 2011
Re: [OT] Spaces/tabs (Was: simple display (from: GUI library for D))
On 04/12/2011 05:15 AM, Jonathan M Davis wrote:
> So, how you format
> your code matters. Using tabs screws with that unless you're completely
> consistent, and while a single developer may be consistent, groups of
> developers rarely are.

This is as true in the case of spaces. With the additional issue of indent-width.

Denis
-- 
_________________
vita es estrany
spir.wikidot.com
April 12, 2011
Re: [OT] Spaces/tabs (Was: simple display (from: GUI library for D))
On 04/12/2011 05:19 AM, Jonathan M Davis wrote:
> Using only spaces and no tabs avoids the entire issue

spaces <--> tabs works as fine

Why are programmers so blindly unfair when discussing this point?

> and is one of the major reasons (if not _the_ major reason) why it is incredibly common for coding
standards to require spaces and prohibit tabs. Obviously, you _can_ use tabs if 
you're careful - especially if you're the only programmer involved - but it's 
just simpler to disallow tabs when you're dealing with a group of developers.

I guess the true reason why spaces are required in guidelines is a mix of 
conformism and "virality". At one point in time, people started to face the 
issue, thay had to make a choice for coding standard in language libs, 
corporation code, school/university works, etc. They chose spaces because, at 
that time, most people used spaces and did not want to change. Then, even more 
programmers get used to use spaces and don't want to change, so that new coding 
standards are forced to enforce spaces, and so on...
There is no, and there has never been any, logical reason for this choice. 
There cannot be, in fact:

1. Tabs properly separate code content from view,
2. and respect each reader's preference.

In addition to those main reasons, they have a few nice side-effects:

* No indent width issue (!),
* 1 tab <--> 1 indent level conceptually,
* deletion is 1 key press, even with stupid editors.

A drawback is one cannot directly have different indent levels, for instance to 
indent collection contents more, or less, than blocks of code. This can also be 
considered an advantage; and is simply solved by using... spaces ;-)

void f () {
 -> while (true) {
 ->  -> table = [
 ->  -> .."aaa" : 1,
 ->  -> .."bbb" : 2,
 ->  -> .."ccc" : 3,
 ->  -> ];
 ->  -> auto a = this(table);
 ->  -> if (! a) break;
 -> }
}

(yes, the example is stupid)

Denis
-- 
_________________
vita es estrany
spir.wikidot.com
April 12, 2011
Re: [OT] Spaces/tabs (Was: simple display (from: GUI library for D))
On 04/12/2011 07:13 AM, Jonathan M Davis wrote:
> It's true that people occasionally end up inserting tabs in space-only
> environments, but in my experience, it's fairly rare. It's pretty much a
> guarantee, however, that _someone_ will insert spaces in an environment where
> it's supposed to be tabs.

How can you assert that? you stated yourself that in all your work environments 
the convention was spaces. So, logically, all mess up cases you have ever 
experienced are due to the standard beeing spaces.
Your assertion about tab-as-standard causing more mess up is complete guessing.
Please, be fair.

Denis
-- 
_________________
vita es estrany
spir.wikidot.com
April 12, 2011
Re: simple display (from: GUI library for D)
On Mon, 11 Apr 2011 23:08:12 +0000, Adam D. Ruppe wrote:

> teo wrote:
>> XCB (http://xcb.freedesktop.org/) - aims to replace Xlib
> 
> I've heard of it, but never used it before. Since I wanted to write this
> quickly I stuck to what I knew (xlib on linux and gdi on windows).
> 
> Replacing it later, if necessary, won't be hard (the target specific
> code is only about 300 lines, all straightforward. We were considering
> changing to DirectX / OpenGL a bit later anyway, so the xlib might
> actually be secondary in any case).

Yes, it won't be hard, but it is also not that straightforward, because 
XCB is a bit lower-level compared to Xlib.


> 
> But I doubt xlib is going anywhere any time soon. It's older than I am!

Exactly that is the problem. It is old and clumsy (state-of-the-1980s) 
and I suspect that Wayland will eventually replace it. Xlib and the X 
server will remain there for legacy applications.

Wayland is still alpha, however I would consider at least looking more 
closer at it. Currently it uses OpenGL ES (will use OpenGL later) and is 
oriented towards the future of Linux graphics. Two of the leading Linux 
distributions (Ubuntu and Fedora) stated that they will switch to Wayland 
in one of the coming releases.
5 6 7 8 9 10 11 12 13
Top | Discussion index | About this forum | D home