Rails


07
Mar

Copycat frameworks

(Update: it appears that I misjudged Grails here. The author of Grails has advised me that it is built on mature, tried and tested Java technologies such as Hibernate, Spring, and so on, and it seems that Groovy is not just another random programming language but an extension of Java itself to incorporate language features such as closures, dynamic typing and operator overloading. Unfortunately I won’t be able to attend the lecture myself, but it may well be worth checking out if you are a Sussex based Java developer. More details are in the comments.)

I was asked today if I’m interested in going to a lecture at Sussex University on a new web framework called Grails, which is written in a language called Groovy that runs on the Java platform.

Not really.

One glance tells me it’s Yet Another Rails Copycat. It seems that everyone and his dog are writing them these days, and most of them are completely unnecessary. If I really wanted to do something Rails-ish on the Java platform I’d use Rails with JRuby.

The fact of the matter is that while it’s worth knowing two or three different web frameworks, some of them are just too niche to bother with. Groovy is currently at number 32 in Tiobe’s Top Fifty, just above PL/I, Smalltalk and Haskell, with half the popularity of Fortran and a third of the popularity of Scheme. And nobody except Paul Graham writes web applications in Scheme.

03
Mar

Derailed

This evening, I decided to have another go at Ruby on Rails. I’ve dipped my toe in the water a couple of times but I’ve never managed to spend more than an evening or two on it so far, and I thought it was about time I learned it properly. So I get out my copy of Agile Web Development with Rails and start to work my way through it.

Only to find that putting scaffold :model in your controller — one of the biggest selling points of Rails, and one of the first things that all the tutorials teach you — no longer works in version 2.0. Turns out that it has been relegated to a plugin, which doesn’t work without a second plugin, which I couldn’t get to install.

The new scaffolding doesn’t do what I want it to either. I just wanted to scaffold a new controller and associated views that would work on an existing model. The new approach only allows you to create your scaffolding in tandem with a new model, which is not what I wanted.

This does not inspire confidence. If the upgrade to 2.0 breaks one of the very first things that Rails n00bs like me have to learn, I shudder to think what it does to more advanced functionality.

Can somebody please explain to me why Rails is supposed to be so cool?

04
Oct

Is there a future for Rails?

It seems that interest in Ruby on Rails has plateaued somewhat in recent months. A year ago there was quite a buzz surrounding it, particularly among .NET developers, for whom it has been a rather popular sideline. However, I can’t help getting the impression that the buzz has subsided somewhat recently. Rails may take a lot of pain out of web development, but it has not taken the world by storm.

Why should this be? I think there are several reasons.

First, the business case for Rails always seemed somewhat limited to me. Developers love Rails, but managers tend to be less convinced. The enterprise world is entrenched in Java and .NET, and shows little incentive to change other than a gradual drift from the former to the latter. Successful open source web apps are mostly written in PHP; it seems that several of the most promising looking open source Rails applications, for example Mephisto and Collaboa, are to all intents and purposes dead. The area where Rails seems to be enjoying the most success is in the heady bubble of Web 2.0 startups and venture capitalists, but even then it still has to compete with .NET, PHP and Python.

The second reason is that some copycat MVC frameworks in other languages, such as Cake for PHP and Castle Monorail for .NET, have come on the scene in recent months, stealing a lot of Rails’s thunder. These play much better with people’s existing skills and save a lot of time that it would take to learn a new programming language. They also fit more convincingly into the world of web hosting, which is deeply entrenched in PHP and .NET. And therein lies the third problem: not many web hosts offer Rails as an option, especially on entry level packages, and this tends to be something of a hindrance to the success of open source applications.

Despite all this, I still think it is a good idea to learn Rails, as it will help you to become a better developer. Ruby is a nice language which does very well in terms of elegance, simplicity and extensibility, and Rails teaches you good programming practices from the word go, as well as giving you a solid understanding of the concepts of O/R mapping, active records, the Model-View-Controller pattern and test driven development. And although the market for Rails may not be all that impressive, it is by no means non-existent. It is just that supply is somewhat higher in relation to demand than, say, Sharepoint.

So yes it is worth learning, but I don’t think it is something to spend too much time on. Rails can make a good compliment to your .NET skills, but I don’t think it should replace them.

21
May

.NET by day, Rails by night

Here are a couple of interesting blogs for anyone who falls into the “.NET by day, Rails by night” category. Softies on Rails is a blog about Rails especially geared towards Microsoft coders by a couple of developers in Chicago, and A Fresh Cup is Mike Gunderloy’s new blog chronicling his reinvention of his career. (Gunderloy, for those of my readers who don’t keep up with who’s who in the world of software development, is a fairly well known author in the Microsoft world.) Back at the start of the year, he announced that he had had it with the Borg and was jumping ship. It looks like Rails is his framework of choice in Life After Microsoft.

Personally I’m not a great one for language wars. I tend to adopt a fairly pragmatic approach to the whole issue, which is why I do both .NET and PHP, as well as anything else that I am required to get my teeth into. Most of my development experience over the past six years has been in .NET, and I don’t see that changing too drastically in my day job, but I do think it’s a good idea to have some experience of other languages and platforms as well. A lot of developers only learn the bare minimum needed to do their jobs, and the result is often www.worsethanfailure.com.

Rails is a particularly good platform to learn as it teaches you all the latest best practices in web development: Model-View-Controllers, O/R mapping and the like, and important concepts such as “Once and only once” are drummed into you right from the word go. The Ruby language also contains a lot of advanced features such as closures and other functional paradigms, which can make for some pretty nice looking code. Plus, of course, there’s all the Ajax whizziness that can help you write really cool apps very easily.

12
Feb

Learning Rails

Historically, I have often adopted something of an ad-hoc approach to learning new programming languages. I tend to sit down with a specific project in mind, thrash around the documentation till I find what I’m looking for, and take it from there. It tends to be pretty tough going at first, but I tend to find I can pick up the basics of the language pretty quickly that way.

The only problem with this approach is that you end up with a patchy knowledge of the capabilities of the language and platform. I noticed this to quite a striking effect when I took my certification exam in ASP.NET. I discovered that there were facets of the framework, such as data binding, that I had previously completely overlooked, as well as a raft of best practices and principles to tap into. It’s also easy when you adopt an ad-hoc approach to learning a framework to miss out on some of the gotchas and pitfalls of a platform, as anyone who has encountered and attempted to eliminate the side effects of PHP\\\\\\\\’s notorious magic quotes will testify.

With Rails I’m trying a different, much more systematic approach. I bought myself a copy of Agile Web Development with Rails, which is more or less the official Rails manual (some people reckon the online documentation is a bit obtuse precisely to help sell the book) and I’m working my way through it. My intention is to work my way right through it before writing any serious code, by which time I should know what the framework has to offer and what it doesn’t, as well as what I need to look out for.

Developing Rails applications with Eclipse using RadRails

I’ve recently taken to using Eclipse for my work in languages other than .net (for which I still use Visual Studio). If you’ve never heard of it before, Eclipse is an open source integrated development environment written in Java. I’d never made a lot of use of it before — I always thought of it as a purely Java thing, and as I haven’t done a great deal of Java in the past, I never fully explored its capabilities. However, when I stumbled on a PHP plugin for Eclipse last week, it roused my curiosity, so I looked around to see what else was available. Sure enough, there are plugins for a whole raft of other programming languages such as Python, Scheme, Fortran or even OCaml (does anyone other than academics actually use OCaml?), and, as you would expect, Ruby on Rails.

The Rails plugins for Eclipse (there are two that you need to install) are the Ruby Development Tools and RadRails. It seems it’s the way to go for Rails development: you can start and stop your WEBrick servers, and access and run all your generators and Rake tasks from within the IDE without having to launch a separate command line window. And of course, it has all the other features you’d expect of an integrated development environment: syntax highlighting, source folding, document outlining, breakpoints and stepping through your code, and Subclipse to allow you to integrate it with your Subversion repository. Some of the Eclipse terminology took a little bit of getting used to at first, and getting RadRails up and running took a little bit of tweaking to get the settings right, but once you get it sorted out, it’s fairly straightforward.

10
Feb

On the rails

Ruby on RailsI’ve finally decided to take the plunge and get into Ruby on Rails properly.

I must admit there have been a couple of things about Rails that put me off a bit. One of these was the amount of hype surrounding it. I have always been very wary of hype, for the simple reason that it can cloud your judgment and lead you into making rash decisions that you later regret. Another thing that put me off learning Rails was the lack of decent, downloadable documentation — though this is less of an issue now that we have broadband at home. A third thing is that the business case for Rails is still fairly embryonic at present: there are fewer Rails jobs knocking around than .net jobs or PHP jobs, for instance. And on top of that, Joel Spolsky doesn’t like it.

Having said that, Rails is rapidly becoming mainstream. Tiobe Software noted that it was the programming language with the fastest growing community in 2006 (seems it took a massive leap round about November). Besides, the off-the-chart-smart people at ThoughtWorks have thrown their weight behind Rails, and you need to bear in mind that these are some of the people at the cutting edge of research into software development and design patterns, so it must be worth serious consideration. And on top of this, the chief technical architect for one of our most important clients is seriously into Rails, so it looks like it could come in pretty useful.

And what of Joel’s railing against it? Personally, I can’t help but get the impression that it cost him a lot of credibility. (David Heinemeier Hansson described it as “one of the purest forms of FUD I’ve ever seen”.) And when he ended his article by saying that he has his own in-house programming language called Wasabi, a lot of people thought that he had gone off the rails in more ways than one — or at the very least, that he was joking. Unfortunately, he wasn’t.

So I took delivery of the book from Amazon.com yesterday and I’ll be working my way through it over the next couple of weeks or so. Stay tuned.

29
Mar

Will Ruby on Rails kill .net and Java?

Ruby on Rails 1.1 has been released.

Dion Hinchcliffe has posted a blog entry at the end of which he asks the question, will it be a nail in the coffin for .net and Java?

Rails certainly looks beautiful. It is fully object oriented, with built in O/R mapping, powerful AJAX support, an elegant syntax, a proper implementation of the Model-View-Controller design pattern, and even a Ruby to Javascript converter which lets you write client side web code in Ruby.

However, I don’t think it’s the end of the line for C# and Java by a long shot. Even if it does draw a lot of fire, there is a heck of a lot of code knocking around in these languages, and there likely still will be for a very long time to come. Even throwaway code and hacked together interim solutions have a habit of living a lot longer than anyone ever expects. Look at how much code is still out there in Fortran, COBOL and Lisp, for instance.

Like most scripting languages such as Perl, Python, PHP and so on, Ruby is still a dynamically typed language. For this reason it will be slower than statically typed languages such as C#, C++ and Java. So it won’t be used so much in places where you need lots of raw power. However, most web applications don’t need such raw power in the business layer. The main bottleneck in web development is database access and network latency in communicating with the browser, so using C# rather than Rails would have only a very minor impact on performance. But some of them do, and in such cases the solutions often have different parts of the application written in different languages and even running on different servers. One of the solutions that we have developed, for instance, has a web front end in PHP running on a Linux box, with a back end application server running a combination of Python and C++ on a Windows server.

Rails certainly knocks the spots off PHP though…