Monday, July 14, 2008

From Java to Rails


For the past few months, I've been ramping up my Ruby skills to play a larger role in the development of our site. I've been a Java coder most of my life and was a bit hesitant to jump back into the coding game (after business school, after a 4 year absence from coding, and compounded with the move to a new development language). But it's where we need the most help, so alas, I decided to give it a whirl.

I'd been hearing a great deal about Ruby and people professing it's advantages. I've also heard the downside. The troubles that sites like Twitter have with scaling. Though most of the Twitter issues seem to deal with their architecture and not with the Ruby language itself. In the end, I was excited we were developing in Ruby because I was one of its supporters (from the little I knew). From all I heard about how easy it is to develop web applications - I was a bit surprised when it took me a while to understand its syntax. Even the ruby site claims it's easy - though obviously they would:

"It has an elegant syntax that is natural to read and easy to write"

I'd assumed it would look a bit like java, which itself is written like C. I mean, most languages use similar conventions.

Well, I was wrong. For me, the ramp up time learning Ruby was steep. It was certainly NOT natural. The syntax looks nothing like any C based language. While it was very difficult for me to pickup the intricacies of the Ruby language at first - it's become a heck of a lot easier to code as you learn it. Why? Because Ruby doesn't require you to do too much. Lots of its syntax makes things much easier to write than any other language I've used. You can get a prototype of a website up in no time (though making it do what you want is another story).

The main differences I've seen between Ruby and Java:

Ruby: parentheses optional, everything is an object, no type declarations, nil not null (that one was easy), no compilation, no interfaces, no type casting, etc. But the single most important thing that was difficult for me when looking at example code - Ruby allows a lot of things to be left out. It can make an incredible amount of assumptions based on what you've written. While quite efficient, it made learning for me a bit challenging. I just read a great simile. A term paper is to txt messaging as Java is to Ruby. Once you learn to txt it's a helluva lot quicker. But before that, it can be confusing.

3 comments:

Randal L. Schwartz said...

Since you're still just starting out, have you looked at Seaside, the up-and-coming web-continuation framework written in portable Smalltalk? Smalltalk is even simpler to learn, and has powerful IDEs, and (for now) is faster, and implemented by more vendors and open source solutions. Check it out.

Anonymous said...

It's good to see you making progress Marc. -JM

Lefty said...

Randal - I'll take a look, but we're far enough along not to switch our technology. We're pretty happy with Rails at this point.