3 ms·
I use tabs for indentation, and I don't particularly care that I'm "out of touch with the JavaScript community." That strikes me as a fairly arrogant thing for
by Stratoscope 14y ago
I use tabs for indentation, and I don't particularly care that I'm "out of touch with the JavaScript community." That strikes me as a fairly arrogant thing for the article to say, but regardless, two spaces doesn't work for me. It's just not enough indentation for my eyes.
In particular, I like to code in a proportional font. I find this more pleasant for reading code, just as I prefer proportional fonts for other text. Two spaces is definitely not enough in a proportional font. It's like a single space in a monospaced font.
But even when I switch to a monospaced font, I just don't enjoy reading code with two-space indentation.
- atroche 14y agoThese are all good points. I'm curious: if you were starting an open source project and you wanted to make contributing as seamless an experience as possible, would you still use tabs for indentation? As for coding in a proportional font, I've never even heard of that before. I'm tempted to try it just for a day, to see if I can get over the initial revulsion. Which font do you use?
- Stratoscope 14y ago> I'm curious: if you were starting an open source project and you wanted to make contributing as seamless an experience as possible, would you still use tabs for indentation? That's an interesting question, because reducing friction for contributors is important. But yes, I'd still use tabs. It honestly sounds like the least of my worries. Clearly, many people prefer two-space indents as your study shows. But how many people are seriously inconvenienced if they have to edit a file using tabs? Don't modern programmer's editors detect a file's indentation settings automatically? Or do they? I'd hate to use an editor that didn't. I use Komodo IDE and even though I have tabs as my default, when I load a file using space indentation it uses the correct setting for that file. > As for coding in a proportional font, I've never even heard of that before. I'm tempted to try it just for a day, to see if I can get over the initial revulsion. Which font do you use? Well, if you think you'll find it revolting, then maybe you will. :-) It depends a lot on your coding style. If you use column alignment (alignment after the indent, as opposed to simple indentation) much, a proportional font won't work for you. I stopped using alignment in my code a long time ago, so when I tried a proportional font I hardly noticed any difference. I've tried a number of fonts, but the one I keep coming back to for some odd reason is Georgia - I just like the way it looks on my ThinPad display. Georgia is kind of a radically proportional font - numbers are proportionally spaced along with letters, where many other proportional fonts have monospaced numbers - but I just find it pleasing to my eye. Komodo has a killer feature for proportional font programming: when you set up a font/color theme, you specify two fonts, a proportional font and a monospaced font, and you can switch between those two fonts easily. Oddly enough, they don't provide a keyboard shortcut by default, but it's easy to set one up in their keyboard shortcut dialog - I use Alt+O on Windows. So when I'm reading code from someone who uses column alignment, I can just hit Alt+O and read it in a monospaced font.
- Evbn 14y agoThere is huge programmer bigotry against writing code in a readable font. I do not understand why.
- artlogic 14y agoIf by readable you mean proportional, then I believe a lot of the resistance comes from vertical alignment issues. For instance: def func_with_lots_of_parms(parm1, parm2, parm3, parm4): In my experience that's pretty difficult to do consistently with a proportional font, and then when someone changes to a different font, the alignment will be off. To me, formatting code is more about creating a good experience for other people (and future me) and less about pleasing present me.
- Stratoscope 14y agoThere's a way to eliminate vertical alignment issues and make your code equally readable in a proportional or monospaced font: don't use vertical alignment. About ten years ago, I got tired of having to adjust the spacing whenever I edited the function name in code using vertical alignment. I'd been running across too many cases where people would take code like this: def func_with_lots_of_parms(parm1, parm2, parm3, parm4): and change it to: def betterFunctionName(parm1, parm2, parm3, parm4): Oops. So I asked myself, who do we have a different rule for indenting with parentheses than we do for braces? We don't indent functions like this (JavaScript example): function foobar(param1) {doSomething(); doSomethingElse(param1); andWrapItUp(); oneMoreThing();} Geez, you'd have to re-indent the whole thing if you came up with a better name for foobar()! So I tried indenting function parameter declarations and function calls just like function bodies, and I found I liked it quite well: def func_with_lots_of_parms( parm1, parm2, parm3, parm4 ): doStuff() or JavaScript: function doSeveralThings( param1, // one interesting param param2, // another interesting param paramWithLongerName, // comment too, but don't "align" comments lastParam // that's enough ) { doOneThing(); finishUp(); } Some time later I discovered that whatever version of Visual Studio I was using back then supported proportional fonts, so I tried it out and found my code looked pretty much the same either way, just nicer looking and more of it fitting on the screen with the proportional font. If I'd still been using a lot of column alignment, though, I probably wouldn't have liked the proportional fonts at all.
- cheald 14y agoI resisted the switch for a long while, but once I did switch, I rapidly grew used to it, and I don't think I'd ever go back. A lot of it really is just "what you're used to".