Live data from Hacker News

Tabs slower than spaces in Firefox

bugzilla.mozilla.org

31–40 of 129 posts

Re: Tabs slower than spaces in Firefox

#31

Earlier quoted context omitted.

One of the main drivers for spaces is alignment, which you should never attempt to do with tabs (except in contexts which normalize tabstops, which generally excludes programming). Aligning within a line can and should be done with spaces. There's good reasons against alignment in such cases -- for example, it creates git blame/git diff noise when reformatting due to having to update alignment on a bunch of other lin…

Indeed, column alignment is just about the only reason to prefer spaces for indentation. If you use column alignment, then indenting with spaces avoids the question of "tabs for indentation, spaces for alignment." But I'm with you: that kind of column alignment is harmful to maintainability, and I find it much less readable too. Some time ago I posted a few examples of column alignment gone bad, from the Servo source…

Hah, those are beautiful examples, thank you! :) The latest I encountered was a few days ago in the allauth codebase, where I found several instances of things like these: https://github.com/pennersr/django-allauth/blob/07d70fd68c4c...

I remember that page, actually. It's a really good point that code alignment breaks proportional fonts, I never considered it. More points for accessibility I suppose!

Re: Tabs slower than spaces in Firefox

#32
post #13

Earlier quoted context omitted.

the only reason to use spaces over tabs is if your tab key broke and you can't map it to a double-tap space (yeah, I did that once). /thread

> map it to a double-tap space How do you do that?

In vim, adding the following to your .vimrc should do it:

    inoremap  

Re: Tabs slower than spaces in Firefox

#33
post #15

Earlier quoted context omitted.

This is interesting. Why do we use spaces anyway? I mean, really - what are the advantages spaces have over tabs? (I use spaces only because I try to follow common coding styles, like PEP 8, but I never gave it enough thought)

The common argument is that with spaces the indent is the same in not only every editor, but also every tool used, such as cvs, diff, patch, build tools, web viewers (e.g., for your cvs tool, issue tracker, and/or code review), shell tools (e.g., less and cat), et etcetera. With tabs you need to configure each and every tool you use to use the right indent (2? 4? 8?), with spaces, every tool just works, and copy/past…

If you're interested in another view, see scrollaway's code example linked above, along with my other comment in this thread that links to a couple of my previous discussions of the topic.

In short, the real issue with tabs is that you can't reliably use them for column alignment. But many of us have concluded that column alignment is a harmful practice, preferring indentation instead to show the structure of our code.

And once you give up column alignment, you can use tabs for indentation, and it just doesn't matter what tab size the person reading your code prefers. It will read just the same in any tab size and any font, even proportional fonts.

It's really quite liberating to stop using column alignment. :-)

Re: Tabs slower than spaces in Firefox

#34
post #15

Earlier quoted context omitted.

Poe's law and all, I hope your comment isn't serious. The whole point was to highlight Richard's "neurotic" side. (It failed to convey it for me when his girlfriend started audibly indenting by hitting the spacebar 8 times... I'd go nuts, who wouldn't?) Also, plenty of geniuses use tabs :) the Linux kernel included. It obviously has no relation. (Seriously though, tabs are a matter of accessibility. https://leclan.ch…

This is interesting. Why do we use spaces anyway? I mean, really - what are the advantages spaces have over tabs? (I use spaces only because I try to follow common coding styles, like PEP 8, but I never gave it enough thought)

Tabs don't work very well when you use whitespace for alignment, for example in multi-line statements. Change the tab size and it's all off...

And seeing as 80 characters is still the normal line limit, because of window splitting, it does happen quite often.

Re: Tabs slower than spaces in Firefox

#35

Earlier quoted context omitted.

The common argument is that with spaces the indent is the same in not only every editor, but also every tool used, such as cvs, diff, patch, build tools, web viewers (e.g., for your cvs tool, issue tracker, and/or code review), shell tools (e.g., less and cat), et etcetera. With tabs you need to configure each and every tool you use to use the right indent (2? 4? 8?), with spaces, every tool just works, and copy/past…

If you're interested in another view, see scrollaway's code example linked above, along with my other comment in this thread that links to a couple of my previous discussions of the topic. In short, the real issue with tabs is that you can't reliably use them for column alignment . But many of us have concluded that column alignment is a harmful practice, preferring indentation instead to show the structure of our co…

It's been mentioned elsewhere, but I figured I'd emphasize it here, given

> And once you give up column alignment, you can use tabs for indentation

You don't have to give up alignment for tabs if you like it occasionally; just indent with tabs and align with spaces. (I highlight leading spaces in a slightly different shade from the background to allow for this.)

Re: Tabs slower than spaces in Firefox

#36
post #15

Earlier quoted context omitted.

This is interesting. Why do we use spaces anyway? I mean, really - what are the advantages spaces have over tabs? (I use spaces only because I try to follow common coding styles, like PEP 8, but I never gave it enough thought)

Tabs don't work very well when you use whitespace for alignment, for example in multi-line statements. Change the tab size and it's all off... And seeing as 80 characters is still the normal line limit, because of window splitting, it does happen quite often.

The problem there isn't tabs, it's column alignment.

If you stop using alignment and use only indentation for your multiline statements, these issues go away. Your code will be just as readable with any tab size, and even in a proportional font. And your line lengths get much shorter in the process.

For specific examples, see the other comments in this thread from scrollaway and myself, in particular the Servo source code I linked to.

Re: Tabs slower than spaces in Firefox

#37
post #15

Earlier quoted context omitted.

This is interesting. Why do we use spaces anyway? I mean, really - what are the advantages spaces have over tabs? (I use spaces only because I try to follow common coding styles, like PEP 8, but I never gave it enough thought)

One of the main drivers for spaces is alignment, which you should never attempt to do with tabs (except in contexts which normalize tabstops, which generally excludes programming). Aligning within a line can and should be done with spaces. There's good reasons against alignment in such cases -- for example, it creates git blame/git diff noise when reformatting due to having to update alignment on a bunch of other lin…

How I wish for a universal standard of two tabs producing automatic alignment with whatever also follows a corresponding two tabs on adjacent lines.

Re: Tabs slower than spaces in Firefox

#38
post #15

Earlier quoted context omitted.

Poe's law and all, I hope your comment isn't serious. The whole point was to highlight Richard's "neurotic" side. (It failed to convey it for me when his girlfriend started audibly indenting by hitting the spacebar 8 times... I'd go nuts, who wouldn't?) Also, plenty of geniuses use tabs :) the Linux kernel included. It obviously has no relation. (Seriously though, tabs are a matter of accessibility. https://leclan.ch…

This is interesting. Why do we use spaces anyway? I mean, really - what are the advantages spaces have over tabs? (I use spaces only because I try to follow common coding styles, like PEP 8, but I never gave it enough thought)

How do tab advocates deal with max column widths? Many projects require that lines not exceed 80 chars, but I'm not sure how'd you establish that kind of limit with variable length tabs.

Re: Tabs slower than spaces in Firefox

#39

Earlier quoted context omitted.

Tabs don't work very well when you use whitespace for alignment, for example in multi-line statements. Change the tab size and it's all off... And seeing as 80 characters is still the normal line limit, because of window splitting, it does happen quite often.

The problem there isn't tabs, it's column alignment. If you stop using alignment and use only indentation for your multiline statements, these issues go away. Your code will be just as readable with any tab size, and even in a proportional font. And your line lengths get much shorter in the process. For specific examples, see the other comments in this thread from scrollaway and myself, in particular the Servo source…

[deleted]

Re: Tabs slower than spaces in Firefox

#40

Earlier quoted context omitted.

Tabs don't work very well when you use whitespace for alignment, for example in multi-line statements. Change the tab size and it's all off... And seeing as 80 characters is still the normal line limit, because of window splitting, it does happen quite often.

The problem there isn't tabs, it's column alignment. If you stop using alignment and use only indentation for your multiline statements, these issues go away. Your code will be just as readable with any tab size, and even in a proportional font. And your line lengths get much shorter in the process. For specific examples, see the other comments in this thread from scrollaway and myself, in particular the Servo source…

So you're trying to dictate a coding style to make up for tabs' weaknesses? That's like Apple's reaction to bad reception on phones: "You're holding it wrong".

No, thanks, I'd rather use spaces that don't require any workarounds.

Post reply on HN