News for hackers. Stuff that matters.
Re:Who decided indenting with spaces was a good idea? by smt88 on Wednesday April 01, 2015 @09:14PM (#9308098)
Oh god. You might as well have posted, "Why do people use Mac instead of Windows?" in the year 2002.

People use spaces because they're a fixed width, not in spite of that fact. They allow you to know that your code will look exactly the same with any monospace font, which is especially important if you do things like lining up operators.

I personally use a hybrid: the entire line is indented with tabs. This tells you which block you're in.

Then, for alignment or anything else that isn't related to the entire block, I use spaces.

Many IDEs support this hybrid mode, including the IntelliJ family. It gives you the best of both worlds.

Re:Who decided indenting with spaces was a good idea? by woah on Wednesday April 01, 2015 @11:00PM (#9308421)
Makes sense in a way I guess, but I would hate to work with you. I've now got to use some different text editor or install a plugin to alternate between white space characters?
Re:Who decided indenting with spaces was a good idea? by smt88 on Thursday April 02, 2015 @01:04AM (#9308768)
It's not a problem working with others, since you can replicate this manually without much effort.

Let's say I have the following code:

        if (test1) {
            if (test2) {
                executeSomething({
                    "first"  : "1st",
                    "second" : "2nd"
                });
            }
        }
Here's the same code with spaces replaced by "S" and tabs replaced by "T":

    TifS(test1)S{
    TTifS(test2)S{
    TTTexecuteSomething({
    TTTT"first"SS:S"1st",
    TTTT"second"S:S"2nd"
    TTT});
    TT}
    T}
You could set your IDE to use tabs, and then for fine-grained indentation (where I've lined up the property definitions in the object), you'd use spaces.

Many IDEs and text editors will automatically detect indentation settings, and some of the popular ones (WebStorm, Netbeans, I think vim) also support hybrid indentation.

So it's only really a problem when someone uses a plain-text, Notepad-like text editor, but I haven't met a professional developer who does that in a long time.

Re:Who decided indenting with spaces was a good idea? by dozzie on Thursday April 02, 2015 @05:35AM (#9309516)

  TTifS(test2S&&
  TTSSSStest3)S{
  // ...
Show me an editor which can tell indentation from alignment at the beginning of the line. And moreover, which can tell it for a dozen of unrelated languages, like Perl, C, make, Erlang, XML and YAML.
Re:Who decided indenting with spaces was a good idea? by smt88 on Thursday April 02, 2015 @10:49AM (#9310986)
All IntelliJ products[1], vim[2], and emacs[3] support this. They call it "smart tabs". Sublime has a plugin that does something similar[4].

I don't have it installed and can't find documentation for it, but I believe NetBeans does this by default.

Again, this is something that usually happens naturally when you're indenting with tabs. Very few humans or programs are going to do alignment with tabs, even if they're indenting with them.

1. https://www.jetbrains.com/idea/help/code-style-java.html#d53...

2. http://vim.wikia.com/wiki/Indent_with_tabs,_align_with_space...

3. http://www.emacswiki.org/emacs/SmartTabs

4. http://wbond.net/sublime_packages/alignment

Re:Who decided indenting with spaces was a good idea? by dozzie on Thursday April 02, 2015 @02:02PM (#9312327)
OK, and now explain me why none of these work correctly with all the mentioned languages.
Re:Who decided indenting with spaces was a good idea? by smt88 on Thursday April 02, 2015 @06:49PM (#9313649)
They work fine with Perl, C, XML, and YAML. I wouldn't know about Erlang, but I'd imagine they work with that, too.

It seems as though you have an idea in your head that you're unwilling to research, and when I present you with information, you're unwilling to accept that you could be wrong.

Re:Who decided indenting with spaces was a good idea? by dozzie on Sunday April 05, 2015 @08:47AM (#9323885)
> They work fine with Perl, C, XML, and YAML.

Or do they? Either they are language agnostic or they are not. If they are language-independent, they can't work properly, since indentation and alignment are syntax-specific (that is, need some information extracted from syntax). If they are language-specific, they can't work with all the languages I happen to need, which may include some DSLs rarely used by programmers and some languages defined by myself. I see no other option.

I have checked plugin for Vim; it doesn't work as you advertise. It either puts only spaces or only tabs at the beginning of the line, depending on expandtab setting. I assume from your comment that others work as well as this one.