Live data from Hacker News

Tabs slower than spaces in Firefox

bugzilla.mozilla.org

61–70 of 129 posts

Re: Tabs slower than spaces in Firefox

#62
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.

Yes. If the optimization actually worked then tabs would be better than spaces in some cases and spaces would never out-perform tabs.

Re: Tabs slower than spaces in Firefox

#63

Earlier quoted context omitted.

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.

> So you're trying to dictate a coding style to make up for tabs' weaknesses? Not in the slightest. The disadvantages of column alignment have nothing to do with whether you use tabs or spaces. I don't recall for sure, but I think I was using spaces for indentation at the time that I stopped using column alignment. Column alignment has the same problems if you indent with spaces: it leads to excessive line length, it…

That's a good question. Lisp programmers such as myself do indeed format code like your first example all the time.

In fact, having done a lot of Lisp programming recently, I wanted to format some Java code using that style too, but IDEA's code formatter is too limited to allow me to do that.

Re: Tabs slower than spaces in Firefox

#66
post #59
post #23

Earlier quoted context omitted.

I've never quite understood why lots of IDEs don't convert a file to your preferred variation of tabs or spaces when you open a file, and then convert it back again when you save it. On disk the indentation could be one thing while in the editor it's something else. That way everyone's happy.

I think the whole notion of programming language as pure text and even using "files" as a unit is veering towards obsoletion. We do it that way because that's the way it's always been done, but I can see plenty of cases where an IDE that uses a more hybrid graphical approach would be beneficial, and we wouldn't have arguments like this :)

I feel like WASM could be a first step in that, a binary AST/graph-like format with a preferred textual representation. It even has a bidirectional codec.

Re: Tabs slower than spaces in Firefox

#67
post #23

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…

I've never quite understood why lots of IDEs don't convert a file to your preferred variation of tabs or spaces when you open a file, and then convert it back again when you save it. On disk the indentation could be one thing while in the editor it's something else. That way everyone's happy.

The "tabify" and "untabify" commands do this in Emacs, and many languages have linters which can flag either (which you can then run, e.g. as a git pre-commit hook).

If spaces/tabs were just about nesting code blocks then this would all be a no-brainer, but vertical alignment can convey much more information than that (for example, splitting statements into semantically equivalent columns).

Re: Tabs slower than spaces in Firefox

#68
post #44
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 make no sense to me as they're clearly control codes. I maintain that if tabs are permitted, so are other ASCII control codes, like vertical tab, form feed (which is actually used in GNU code), and bell. int foo(void) { /* This bit is really important. */ ... } int blah(void) { ... } :-)

I like the idea :-)

The GNU coding standards request form-feed (\f or ^L) to separate code into logical pages.

https://www.gnu.org/prep/standards/standards.html#index-cont...

Re: Tabs slower than spaces in Firefox

#69
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…

> Take a look at the following code and tell me which method looks better:

That seems like a strawman to me. I would go with something like:

    function() {
        nested_code() {
            some_very_long_function_call(
                long_argument_one,   long_argument_two,
                long_argument_three, long_argument_four,
            );
        }
    }

Re: Tabs slower than spaces in Firefox

#70

Earlier quoted context omitted.

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.

> So you're trying to dictate a coding style to make up for tabs' weaknesses? Not in the slightest. The disadvantages of column alignment have nothing to do with whether you use tabs or spaces. I don't recall for sure, but I think I was using spaces for indentation at the time that I stopped using column alignment. Column alignment has the same problems if you indent with spaces: it leads to excessive line length, it…

> If the column-aligned way of writing a multiline function call or expression is such a good thing, why don't we also format blocks of statements this way:

I don't see any reason not to. Your example is pretty ugly though, as it's not particularly aligned. What about:

    if( foo == bar ) { if( baz == moo ) { console.log( "yes" );
                                             this.that = true ; }
                                   else { console.log( "no"  );
                                             this.that = false; } }
Post reply on HN