Twitter on Ruby and Scala

Ever heard a code-smell in a conversation? Like this guy is giving you gyan about how he's doing x in language y and it's such a pain in the ass, and you're thinking to yourself "x is such a darn stupid idea in the first place," know what I mean?

The reason I bring this up is because this interview with some of the Twitter hackers came up on the ThoughtWorks software dev mailing list today, and it smelt faintly of cowpats so I thought it worth a mention.

Most of the interview is fairly quiet, sensible stuff; you're ambling along going 'Ho, hum, mildly interesting...' and then something fearsomely ignorant bumbles out and gores you someplace delicate. Here's an example that got pointed out:
Alex Payne: I’d definitely want to hammer home what Steve said about typing. As our system has grown, a lot of the logic in our Ruby system sort of replicates a type system, either in our unit tests or as validations on models. I think it may just be a property of large systems in dynamic languages, that eventually you end up rewriting your own type system, and you sort of do it badly. You’re checking for null values all over the place. There’s lots of calls to Ruby’s kind_of? method, which asks, “Is this a kind of User object? Because that’s what we’re expecting. If we don’t get that, this is going to explode.” It is a shame to have to write all that when there is a solution that has existed in the world of programming languages for decades now.
Aargh. Aargh, I say. I would freakin' bust someone who wrote object-oriented code with is_a? or kind_of? in it, and here's this laddie out on the world wide internetworks proudly admitting that his people write that kind of code. nil checks everywhere? The solution to that has been around for ten years now, for crying out loud. Hasn't anyone told them this kind of code is a people problem, not a language problem?

Here's another bit that seemed suspicious:
Alex Payne: I think programmers who’ve never worked with a language with pattern matching before should be prepared to have that change their perceptions about programming. I was talking to a group of mostly Mac programmers, largely Objective-C developers. I was trying to convey to them that once you start working with pattern matching, you’ll never want to use a language without it again. It’s such a common thing that a programmer does every day. I have a collection of stuff. Let me pick certain needles out of this haystack, whether its based on a class or their contents, it’s such a powerful tool. It’s so great.
Needle in a haystack, eh? In my limited fp experience, pattern matching is used in functional languages for both terseness and for polymorphism. What they seem to be describing - using pattern matching as a glorified regexp and an accessory to the violation of encapsulation - seems pretty unnecessary, given that they're using an OO language that supports polymorphism through objects anyways. This kind of stuff was why I put my Scala studies on hold until I learned how to think correctly in functional terms; Scala makes it easy for a novice to write code that is neither good FP nor good OO.

I have this feeling that Twitter is always 'discovering' something which the rest of the world already knows and has used for a long time. What's worse, they won't go look at the tons of work that's out there and learn from that; no, they'll make the same naive mistakes all over again, like they did a couple of years ago with message queues, a story I've heard from a lot of people.

Don't get me wrong here, I'm not dissing everything they've said; they're good chaps and have a fantastic service deserving of respect. I've also written a little Scala myself and have been lurking on the /Lift/ lists for over a year and I agree with them when they say Scala is a nice language. But frankly, a little engineering and attention to code quality might help them solve more problems than switching languages.
Post a Comment