Live data from Hacker News

Tabs slower than spaces in Firefox

bugzilla.mozilla.org

11–20 of 129 posts

Re: Tabs slower than spaces in Firefox

#11
post #2

From the comments, it looks like there's an "optimization" that kicks in when a function is under 100 characters long. It seems that optimization is backfiring and actually making a tabbed function slower.

Obvious fix: Count the length of the function without whitespace characters, so that both versions are equally slowed down by the optimization.

Unfortunately, this sounds like one of those problems where a non-fix like that is still the best you can really do. If nothing else, this should still be at least a more accurate representation of the complexity of the function.

Re: Tabs slower than spaces in Firefox

#12
post #9
post #7

This is great bug, right up there with the Dwarf Fortress bug that involved a dwarf planting a bed in a farm plot.

Would you be able to link this? I'm interested in reading about it. A quick google for 'dwarf planting a bed in a farm plot bug fortress' turns up nothing relevant at a glance.

It's mentioned in the wikipedia page under "further updates"

https://en.wikipedia.org/wiki/Dwarf_Fortress#Further_updates

Which refers to a brief mention here:

http://www.pcgamer.com/community-heroes-tarn-adams-for-dwarf...

but there are no details.

Re: Tabs slower than spaces in Firefox

#13

I'm going to use this as fodder next time I get into an argument with someone about why spaces are better than tabs when writing code. Or maybe I've just been watching too much silicon valley...

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

Re: Tabs slower than spaces in Firefox

#14
post #10

I'm going to use this as fodder next time I get into an argument with someone about why spaces are better than tabs when writing code. Or maybe I've just been watching too much silicon valley...

I thought that was the most unrealistic thing this season: a supposedly genius programmer who loves tabs and hates spaces.

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/tabs)

Re: Tabs slower than spaces in Firefox

#15
post #10

Earlier quoted context omitted.

I thought that was the most unrealistic thing this season: a supposedly genius programmer who loves tabs and hates spaces.

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)

Re: Tabs slower than spaces in Firefox

#16
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)

Tab width can vary between editors, i.e. do a "set shiftwidth=8" in vim, and it'll be 8 spaces. Spaces are more constant.r

Re: Tabs slower than spaces in Firefox

#17
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)

The reason is probably similar to why there's now top posting in emails.

The support in editors is abysmal and doesn't work out of the box correctly for tabs (e.g. invisible whitespace).

I've never seen an argument for spaces that would hold iff all editors would have sane defaults for programmers. Of course, it's also bad that some programmers can't configure their tools correctly, but that is a complete different issue.

The best of both worlds would be "tabs for indentation, spaces for alignment" but as it is now, you only need one programmer with wrong settings to screw that up, so that's why most projects have settled on the most conservative setting.

Re: Tabs slower than spaces in Firefox

#18
post #16
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)

Tab width can vary between editors, i.e. do a "set shiftwidth=8" in vim, and it'll be 8 spaces. Spaces are more constant.r

Isn't that the whole point of tabs? So everyone can have their own width preference without going mad with git merges.

Re: Tabs slower than spaces in Firefox

#19
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)

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 lines just because you introduced a variable one character longer than the others. Irrelevant, though; such alignment is perfectly fine to do with spaces in a context where you indent with tabs.

The other type of alignment is beginning-of-line alignment, which is indeed not doable with spaces. Some people recommend doing such alignment with spaces despite the tab indent (cf. http://dmitryfrank.com/articles/indent_with_tabs_align_with_...). It's a valid argument but I feel it's too much of an aberration to be taken seriously.

I personally find such alignment generally repulsive anyway. Take a look at the following code and tell me which method looks better:

http://sprunge.us/ZFHJ

Too many times have I seen such function calls where the space between the parenthese and the soft wrap leaves <10 characters to work with. And here we go with one small argument per line, every argument preceded by 70+ spaces. I know programmers who could fit video games in the bytes used for just a single function call like that.

Re: Tabs slower than spaces in Firefox

#20
post #11
post #2

From the comments, it looks like there's an "optimization" that kicks in when a function is under 100 characters long. It seems that optimization is backfiring and actually making a tabbed function slower.

Obvious fix: Count the length of the function without whitespace characters, so that both versions are equally slowed down by the optimization. Unfortunately, this sounds like one of those problems where a non-fix like that is still the best you can really do. If nothing else, this should still be at least a more accurate representation of the complexity of the function.

Then the next guy comes and complains why `var a = 42` is slower than `var abc = 42`. And so on. I wonder if it also counts comments. It soon becomes quite complicated. Maybe you can count the number of dots in non-comments and non-strings and will get a better heuristic.
Post reply on HN