News for hackers. Stuff that matters.
Re:Ask HN: Why do the majority of JS developers prefer space... by bjourne on Friday August 15, 2014 @12:51PM (#8183022)
Because spaces are rendered the same everywhere. Suppose I write this code, indenting using spaces.

    im_a_long_method(argument_no_1,
                     set_indentation_true(...),
                     no_string_cutoff,
                     whatever)
Now suppose I used tabs to indent and my editors tab width is 4 spaces while your is 8 spaces, then the above would look like:

    im_a_long_method(argument_no_1,
                                      set_indentation_true(...),
                                      no_string_cutoff,
                                      whatever)
Since not every editor agrees on how wide a tab character is, you get crappy alignments. Therefore use spaces.
Re:Ask HN: Why do the majority of JS developers prefer space... by dragonwriter on Friday August 15, 2014 @12:56PM (#8183051)
> Because spaces are rendered the same everywhere. Suppose I write this code, indenting using spaces.

Then it'll look wrong in a proportional font; indenting and aligning with non-indented text are different things. Either spaces or tabs indent consistently when used consistently in a source file. Alignment cannot be acheived consistently (with spaces or tabs) unless you also assume a monospaced font, or (with tabs) have elastic tabstops.

Re:Ask HN: Why do the majority of JS developers prefer space... by J_Darnley on Friday August 15, 2014 @06:10PM (#8184547)
I really don't get the point of tabs for visual layout in any kind of document be it plain text, source code, or a word processor document. They never seemed to work right for me.

I remember using the tab key to enter tabs back in school to make something like an informal, 2-or3-column table (or whatever I was actually doing). This would have been in Word. Things would line up pretty until I wanted to change some text. If I made it longer I would need to add another tab because the tab had shrunk to nothing. If I made it shorter the tab would jump into the previous section and no longer line up with the other lines.

As far as I can see, the same will happen with this source example if it were using tabs and a proportional font.

Re:Ask HN: Why do the majority of JS developers prefer space... by dragonwriter on Saturday August 16, 2014 @10:30AM (#8186307)
Elastic tabstops are so named because the width adjusts based on the content, avoiding that problem. http://nickgravgaard.com/elastictabstops/
Re:Ask HN: Why do the majority of JS developers prefer space... by lutusp on Saturday August 16, 2014 @12:23AM (#8185411)
> Then it'll look wrong in a proportional font

Programmers don't use proportional fonts. Source code maintenance is hard enough without asking for trouble.

Re:Ask HN: Why do the majority of JS developers prefer space... by dysfunction on Friday August 15, 2014 @01:37PM (#8183229)
...and maybe that's why most popular coding fonts are monospaced?
Re:Ask HN: Why do the majority of JS developers prefer space... by dragonwriter on Friday August 15, 2014 @04:24PM (#8183971)
> ...and maybe that's why most popular coding fonts are monospaced?

Yes, the desire to use alignment without something like elastic tabstops being widespread is the limitation which prevents wide adoption of otherwise-superior proportional fonts in coding.

Re:Ask HN: Why do the majority of JS developers prefer space... by iLoch on Friday August 15, 2014 @01:50PM (#8183300)
This is a great argument, thanks.