Dear Rails, Please Remove The Stick From Your Ass
So as some of you know, a very favourite project of mine is the Edmonton Free Library (code here). It’s built on a technology that many of you are familiar with: Ruby on Rails. Overall, I’ve been extremely happy with it, the growing pains are mostly over and I’m moving on to actually knowing what I’m doing. Part of this I have to lay at Brendan’s (bct) feet for being a very flexible dude about convention, but knowing most of the best ways to do things (omg rake db:migrate…. why is this not in the screencasts? It’s so fucking awesome).
Now there is one thing that bugs me though… this two-space indent thing the Rails community has going doesn’t really fly for me. I want to highly emphasize that I prefer two-space code indenting to four-or-other weird space indenting forms. If you’re going to use spaces, it’s better than the other options. And if you really like it, thats cool, I don’t really care. Personally I prefer custom-widthed tabs, and I won’t rehash the common reasons why. What is important either way is that you follow a single convention. Or so I thought.
NetBeans IDE for Ruby was pretty good… but I couldn’t get the indenting to work right, and it was really just a flashy editor. Not really worth the overhead of starting the entire thing. I eventually got pointing to vim /w rails.vim.
I want to be clear: rails.vim is FUCKING AWESOME. I haven’t even begun to tap its potential, but its so good that I can’t handle it. But all its indentation is done with two spaces. That’s fine, its the convention, logically that would be the default. So I set .vimrc for noexpandtabs and set my tab width.
Strangely, this does not work.
I had literally spent two full days thinking I was nuts (and working only on .rhtml files where our indentation conventions hadn’t been established yet anyways) before I gave up, tracked down the rails.vim website (I got it via an Ubuntu package), and hopped into #rubyonrails (one of the channels suggested). The following is a paraphrasing of the dialogue (nicknames have been changed so nobody gets uptight about being identified):
[medwards] Hey has anyone tried configuring rails.vim to use non-standard indentation?
[R] No that would be retarded
[P] Why would you want to do that? 2 spaces is the standard, duh.
[medwards] That's great guys, I just want some help. If you disagree with my preferences, thats cool but I don't think you need to be an ass to me about it.
[Q] some link to pastebin with vim commands
[R/P] more random disparaging remarks about why anyone would use different indentation, the implication that I am an utter moron, omg horizontal scrolling, etc.
[medwards] /ignore R P
[medwards] Q: Thanks, but my .vimrc hasn't worked yet... btw thanks for not being a dick"
[Q] medwards: Oh, maybe try .exrc? Also, two spaces IS the standard and you should really use it...
[In my head: oh. my. god.]
Yeah. #rubyonrails. Go there if you want help figuring out if you can sustain a bunch of implications that you have no idea what you’re doing. OK, whatever, they’re uptight assholes, the other channel to try is #vim (I am ever hopeful). So I ask the same question:
[T] medwards: I advise against it but it is supported
[medwards] tpope: I've already got the raking over the coals in #rubyonrails
[T] types the command I need
(I should have shut up around here)
[medwards]overall I love rails.vim man
[medwards] it's really awesome, but this indentation holy war is getting kind of ridiculous...
[T] it's ridiculous to come into the one community that's actually managed to standardize and then not follow it.
[In my head: fuuuuuuuuuckkk]
Ok, I’m going to be blunt: This is bullshit. I am not Microsoft coming from on-high to embrace, extend, and exterminate. I am coding a project, with a person who agrees that my indentation style is fine with them, and so we have agreed on a convention on coding style. This is hypocrisy, blasphemy, apostasy, or any other term I could come up with. I am not doing a massive insult and destroying Ruby on Rails by using TABS instead of SPACES. Oh. My. God. People. Grow UP.
The colour of my car is a purely personal outcome, and it happens that I want a blue car. Get over it. Because all your cars are red with white stripes is not something that is massively important, your convention is not the holy standard. I wish this was simply an attitudinal problem of specific people in this community, but the utility and popularity of rails.vim is going to make this more of a pain soon. See this excerpt from rails.vim doc file:
A value of 2 is used for ’shiftwidth’ (and ’softtabstop’), and ‘expandtab’ is
enabled. This is a strong convention in Rails, so the conventional wisdom
that this is a user preference has been ignored.
In conclusion: The Rails convention ([whine]theeeee staaaaannnddaarrrddd[/whine]) is so important that it means that we do not follow vim convention (aside: in the process undermining the very idea of standard and convention which is meant to ENABLE wildly divergent implementations). This coding style zealotry goes far above and beyond the required zeal for aesthetically pleasing code. In fact I felt very much like I was programming in the Cathedral and not the Bazaar. This is not community, it is monoculture.
The discerning (or spittle-ridden) readers might wonder why I wrote such an angry little note. It’s a good question: I want to reiterate that Rails is really really good so far. Concerns about scalability aside, I’m happy that I’m on it. What I want to demolish is this Rails-messiah/golden-boy concept: Rails can do no wrong, Rails does it right (ALL THE TIME NO EXCEPTIONS), Rails is so amazing I should lick the feet of the two-space indenting crowd. This isn’t entirely their communities fault: Outsiders have been treating Rails like the new AJAX, becoming Rails groupies in unquestioning droves. There needs to be some critical thinking on their side of the fence that includes ways to make their stack into something other than a strait-jacket. While I may have previously been fairly dismissive of the entire disagreement centred around ruby gems, I am now forced to wonder if this is a cultural issue where the Ruby on Rails community thinks they are too superior to enable other developers to develop their own way.
For those who cite the classic mantra: “If you don’t like it, fix it.” Well, I plan on it.. I’m working my way through rails.vim scripts to figure out how the indenting is done and will make a pull request once I have done so.. in the meantime I give you the command I was given for my .vimrc:
autocmd User rails set sw=4
(unfortunately this merely changes my auto-indent to 4 spaces… adding noexpandtab/ts doesn’t seem to do anything because either the autocmd is only parsing the first argument, or the rails.vim stuff never inserts tabs so the tab settings are irrelevant. Maybe both. I’m now looking at ~/.vim/plugin/[rails-toolkit.vim,rails.vim,surround.vim,supertab.vim] but I’m pretty green at this).
I hope that was a satisfying rant
Sadly the Rails community somehow never inherited the helpful and friendly parts of the Ruby community embodied by matz and _why. (I’ve posted about this before.)
For the record, I tend to use 2 spaces myself but only out of habit; tabs really do make more sense (in the same way that separation of content and style do).
Comment by necronomicorp.com/bct — January 20, 2009 @ 4:12 pm