Thursday, August 5, 2010

Why Not Add Some Ruby?

If twitter is good for one thing it’s starting debates amongst your friends. Today didn’t disappoint as Mike started us off with: “things i miss from rails while i'm doing java: rails.”

It started in the productivity trap, which is going to be subjective toScreen shot 2010-08-04 at 10.53.23 PM the developer doing the work, so it’s a tough one to measure. Can I do some things faster in Ruby than I can C#? Yes, but the inverse is still true.

One point I need to make is I’ve seen a few of these discussions and often they become Rails v. C#/.Net, which isn’t really a fair comparison because Rails is a web framework. To go apples to  apples, you need Screen shot 2010-08-04 at 11.01.34 PMto compare Rails to ASP.Net MVC, not .Net in general. You wouldn’t compare WebForms or WPF to Ruby or Python, would you? (You shouldn’t compare WebForms to much of anything…but I digress.)

So, Jon asked a pretty valid question: Why don’t more people switch? Since I come from a .Net background, I’ve really only seen this debated as it pertains to .Net.

For a number of the arguments around the IDE, Intellisense, Static v. Dynamic typing, there are plenty of other blogs that have covered this, here’s a recent one I really liked: Ruby is Scary.

For my quick entry here, I’ll say this…I can have VIM or TextMate open and have a couple tests written before the VisualStudio splash screen has closed. Also, those two tools have yet to throw an “Out of Memory” exception on me, can’t say the same for Studio.

And I don’t really miss intellisense.

On with the show…

On the heels of Jon’s question Bill Sempf jumped in. As a bystander, Bill was very much representing the average .Net dude, and the arguments I’ve heard from the average .Net dude. (Bill has looked into Ruby, we’ve paired writing Ruby. That’s not really the point here, though.)

Ruby, the Average Dev, and the Complex System

@JonKruger: That's not my problem. I just don't think that 80% of the dev teams out there can handle coding in Ruby. (link)

That was Bill’s entry to the discussion, and I’m not sure I can disagree with him. However, I’m going to be snobbish and self centered and say I want to work with the 20%. If you’re in the 80% and can’t code Ruby…or Python, or F#, or any other language you have to learn…I don’t want to work with you. You can stay in “The Enterprise.”

@JonKruger: My point is those stories are told by top-tier devs, and not everyone is one of those. (link)

Again, tough to disagree with Bill’s assertion here. Not everybody is a rock star, and that’s cool. If you’re a budding rock star, you’ll be able to write some effective Ruby code.

In between those tweets were a few others, mainly around supporting complex systems using Ruby. Personally, I haven’t written a large scale application in Ruby, so I can’t lean on any experience here in writing the typical central Ohio “claims app” in Ruby.

What I have done with it has worked well. So my first counter to Bill’s argument on the complex systems: Use it where it fits. Ruby brings a great set of DSLs to the table for testing, web frameworks, and testing. Yeah, said it twice. Year one of Codemash (Jan of ‘07) I listened to Neal Ford talk about DSLs to help write your applications and Polyglot programming. Using Ruby to support your app – to write build scripts, tests, POC web sites – falls right in on the polyglot thing.

On the testing side, I’d much rather read a batch of RSpec tests than a batch of nUnit tests. Cucumber is already helping my current team get through some testing issues. Let me repeat that: I’m using Cucumber in a .Net environment RIGHT NOW to help the team get better test coverage on their application.

Learning a New Language

@JonKruger: There is a difference between learning the language, and being productive in it. (link)

I’m in total agreement with Bill here. Which is why I’m such a big fan of the incremental approach to using Ruby on your projects.

Great place to start: use Rake as your build script. I’ve done this for a couple years now, it’s a great way to dip your toe into Ruby, get comfortable with the language and a few of its concepts without really getting in on your production code. On the .Net side, use Albacore with Rake and you’ll have a build script in no time.

Next up you can start writing some tests in it. That’s a pretty good way to pick up a new language, anyway. And with the nice testing tools with Ruby, you can learn a new language and ease some testing pain.

But, the main point here, don’t be afraid of picking up a new language. How many do you know already? If you’re a web developer, you probably already know Javascript, CSS, HTML, C# (or some back end language), a little SQL, and a healthy dash of XML. Picking up another one isn’t going to be too difficult.

Essence v. Ceremony

I first heard this from Neal Ford, possibly at eRubyCon a couple years back. But, Stuart Holloway had a great blog post about it prior to when I heard Neal speak.

To me (and many others), Ruby gets to the essence of what you’re after quickly. I find myself working within it’s idioms easily, not fighting them constantly with adapter patterns, dependency injection, and ORMs. I find that my tests flow naturally from the various testing tools I use in Ruby, and the code that makes those tests pass benefits from that.

So, to Bill’s point, maybe Ruby isn’t ready to have average devs write big, complex, “enterprise” systems in it. But, it is ready to support what you’re writing today. Right now. Why not give it a try?

Unless you’re afraid of learning…

5 comments:

Mike Busch said...

Nice post Tim. To defend my apples to oranges tweet, when I said "java" I was referring to Java web frameworks (Spring MVC, Struts 1/2, etc) - just didn't want to be pedantic and list them all out.

Andy Vulhop said...

Nice post Tim. I was an observer and minor contributor to that little debate. My counterpoint (weak as it is) to sprinkling in and introducing Ruby in your work is that sometimes that's hard to do in a corporate environment.

We can talk for hours about "change your company, or change your company" and agree completely. [I tried one, ended up resorting to the other.] However, sometimes as a cog in the machine or as a consultant swooping into an IT department, you don't have all that much control over the technical decisions. It's no excuse for not trying and learning on your own time, however. I just think it contributes to the notion that C# is the one that writes the checks, and RoR is for the starving artist. True or false as that may be, I think it's the impression a lot of people have.

Also, there is a small, vocal segment of the RoR community that thinks the best approach to getting adoption up amongst .NET dudes is to belittle and insult them personally/professionally for working with the Microsoft stack instead of ruby. I think a lot of are ALT.NET/NOT.NET people that have the spurned lover syndrome. It hurts one of the best things about Ruby (community) when that is out there.

Full disclosure: I can't write ruby to save my life... yet.

Tim said...

@Andy - paragraph 3 of the post: Don't compare RoR to C#. ;)

If you don't have a choice over your technical decisions, then you're in trouble. As a cog or a consultant "swooping in" (I like it!) then you need to have SOME say in what tools you're going to use. To steal directly from Brian Sherwin: When you call a plumber, do you say, "No need to bring your tools, I've already got a wrench that will work, I'm going to require you to use my wrench."

Also, the intent of my post isn't in the vocal segment, it's about your own critical analysis. I really don't care what the vocal segment thinks, on either side of the argument. If something helps me get the job done and add value to my client then I'm going to use it.

Andy Vulhop said...

@Tim I think we agree, but I'm sucking at communication. :)

Also, I probably should have said Ruby instead of RoR. Do a quick mental Ctrl+H on my post.

I was trying to explain that some people have these (likely false) impressions of either helplessness or of rubyists as elitists.
I felt like I had no say at my former place of employment. That's why it's former. That's how it should be, I think. If you aren't respected as a professional expert, then go where you are.

I look at the ruby community and see a lot of GREAT community involvement. However, the unfortunate thing that happens is when a well known (read: loud) .NET dude gets pissed at MS and switches, sometimes he gets really antagonistic toward people who still use .NET. I understand those are outliers in the community. Many people I talk to, however, do not. That's a really unfortunate thing that happens in lots of communities, though. Just look at .NET devs mocking Java or PHP programmers. It's the same thing. Every community has a few.

I don't care what the loudmouths on either side say. However, a lot of devs, I find, get very... defensive(?) if their skills are insulted. As such, they get pushed away from a tool that could get them a lot of productivity.

I like a lot of what I see from the ruby/RoR stack, and I fully intend to learn me some Ruby eventually. I have a lot of catching up to do in my .NET stack right now (I've only been in .NET for 2.5 years, and it was in kinda stagnant environments), but soon I intend to build with Rake, test with Cuke, and eventually do whole RoR projects.

Tim said...

@Andy

I get what you're saying, I do...but it's something outside the language itself. There are groups of jerks everywhere, in every language, and that will continue as long as there's more than one programming language in the world of software. I would suggest you read this post by Neal Ford: http://memeagora.blogspot.com/2009/08/suckrock-dichotomy.html

Remember...that which doesn't kill you, makes you stronger. :)