Monday 31 March 2008

Ruby on Rails, IDE's and autocompletion

Over the last month I've been tinkering with a web development framework called Ruby on Rails. Its a relatively new framework (only a few years old), quite popular and very different to ASP.NET. My progress with Rails so far has been pitifully slow, for a few different reasons: I've managed to make things harder for myself by trying to learn the newest version (released Dec 2007) which limits the availability of appropriate tutorials and textbooks, I don't have much of an attention span at home and so I'm doing various other things at the same time, and there is one other reason that I'll discuss in a moment. My original plan was to play with Rails from within Heroku, a Rails web host currently in beta that offers a browser based integrated development environment, but I soon realised that it was not appropriate for a newbie learning the ropes. I already had Ubuntu running on my laptop so I went through the process of installing it but then there was still the matter of which IDE to use. Its funny - as a .NET developer I never really had to worry about IDE's. Visual Studio is fantastic and there is little in the way of realistic alternatives. I've never wished for a radically different IDE, just enhancements to VS. But step outside of the world of Microsoft based development and suddenly there are many alternatives and little in the way of consensus of what is 'best'. The majority of Rail's tutorial videos are done on a Macintosh using TextMate, but that is not option for me. When it comes to Rails development on Linux, there are several options and for now I've settled on RadRails, a plugin for Aptana Studio, which seems to be some sort of fork of Eclipse. Ok so why all this harping on about IDE's? Well it turns out that the biggest lesson I've learned so far isn't about web development, but about how I learn frameworks/api's in general:

AUTOCOMPLETION
Known as Intellisense in the Microsoft world, autocompletion is my bread and butter. I will use the documentation to find the necessary namespace and then explore it with autocompletion. Only now am I truly aware of how much I rely on it. If you asked most developers about autocompletion, they'd say "oh yeah, its great, it saves heaps of typing". This is certainly true, but saved key strokes is not where the real benefit lies for me: its a discovery mechanism. I found it difficult learning Ruby without autocompletion (and still do) . Its an unfortunate fact that autocompletion is harder to implement and in general less useful for dynamically typed languages. Autocompletion for Rails would be particularly difficult to implement because so much of Rails is metaprogramming magic. I expect to talk about this in more detail in some future posts. For me, Ruby's impressive support for metaprogramming is its most exciting feature. Much of what makes Rails worthwhile relies on this. But it is this very feature that makes meaningful autocompletion so difficult to achieve, which makes it a double edged sword. Its obvious to me that I need to learn to get by without my crutch. And learn I shall, because while RadRails claims to support autocompletion, I've been hitting a whole lot of ctrl+space and so far I'm not impressed.

Monday 17 March 2008

The Pragmatic Programmer

I just finished reading The Pragmatic Programmer: from journeyman to master by Andrew Hunt and David Thomas. I'll be straight with you: I bought it because it is listed in Steve Yegge's list of great books. Okay, that's not the only reason; there are plenty of other bloggers that also have great things to say about it. I hoped that it might be particularly relevant to me because sometimes I am too much of a purist/perfectionist and not pragmatic enough. In this regard I misunderstood the title - I expected the subject matter would touch on the tension between perfection and pragmatism, but this is not the case. Calling the book "The Smart Programmer" would be more exact, though probably not as marketable. All programmers think they are smart, so who would buy a book with a title like that? This book is a bit odd. It reads more like a series of blog posts about good software development practice than a textbook. Part of the reason I say this is the sections are quite short and diverse - it never goes into a great deal of depth. Topics covered include error handling, debugging, testing, refactoring, gathering requirements, development environments, algorithms, prototyping and many more. But through all these topics, I can't really point out anything the book discussed that I wasn't already familiar with. Hence my previous comment about the title. Its about being a better and faster programmer - I don't equate this with pragmatism. The reason The Pragmatic Programmer had so little to offer me is that I've already read so many blogs and articles that touch on the same subject matter. Good software developers analyze their own actions and constantly seek to improve their processes and expand their knowledge. If you've already been doing this for a few years, then this book probably won't offer you much beyond some reinforcement. I can't help but wonder whether I will be saying the same thing about Code Complete by Steve McConnell once I finally get around to reading it. Its an extremely popular book, often listed as the number one mandatory read for developers. Apparently much of the book is 'common sense' and that rings very true of The Pragmatic Programmer also. Next book on my list is Domain Driven Design by Eric Evans. I was told to read this years ago but I was stupid and ignored the advice and now I'm worser for it. But, its never too late to set things straight - I'm a few chapters in and its proving to be excellent.

Monday 10 March 2008

Google analytics and accidently generating yourself some traffic

Google Analytics is this great service that gives you all sorts of stats on your website. Its easy to set up - all I had to do was paste a bit of javascript into my template. Here's an example screenshot I took a couple of weeks ago when I was first considering writing a post on Analytics: It shows me getting a couple of visits a day, with most coming from Australia. A few days ago, something new happened. I got some random comments on my post about gmail addresses (I say random because they weren't from people that know me). This is what was waiting for me when I checked analytics: Hmmm.. what the hell? Where did all these people come from? Well, Analytics is more than happy to tell me: That referring page was the original post (on the official gmail blog) I linked to about the gmail addresses. It turns out that at the bottom of the post, there is a list of links, and my blog post is listed. All automatic of course, but phew, what a way to generate yourself some traffic!

Friday 7 March 2008

A minor correction

Yesterday I proposed signing up to stuff that might spam me using the email address paul.batum.spam@gmail.com so that I could use a gmail filter to label it easily. That was supposed to be paul.batum+spam@gmail.com. Whoops There's something else I didn't think of: I'm not sure if the + symbol is generally accepted when validating email addresses.

Thursday 6 March 2008

My way cooler email addresses

So it turns out I have an extremely large number of cool email addresses that I didn't even know about. Here is an email I just sent: And wheeee, here it is! For the full details go read the post on the official gmail blog. While coming up with crazy variants on your email address and giving them to people is funny, the linked post points out the real advantage of this behaviour: you can set up filters to label and process your email based on the address it was sent to. I often end up setting filters to hide or simply label certain email that isn't ACTUALLY spam - but now instead of having multiple filters I can just use paul.batum+spam@gmail.com to register for stuff and use a single filter. So what are you waiting for, send me an email at paul.batum+gmail=happy.geek@gmail.com to celebrate this discovery!

Wednesday 5 March 2008

Two months

Its been two months since I started writing this blog and in general I'm pretty happy with the way its going. I have successfully made a significant change to how my free time is spent - I'm playing less games, reading more and programming more. The act of maintaining this blog is sustaining this significant change by making me feel accountable. Basically, the plan is working. That said, I was pretty slack over the last two weeks and didn't post much. I'm annoyed that I let that happen - somehow I was telling myself that I didn't have anything to post about but that was just a pack of lies and an attempt to justify a spell of minor lazyness. The interesting fact is that I find much of what I'm trying to learn challenging but writing blog posts of a satisfying (for me - I make no promises about them being satisfying for you) quality is probably the hardest task of the lot. This tiny set of paragraphs has taken me literally hours to write and it is this very fact that makes it so important I keep posting consistently. If it takes me hours to write a few hundred words about nothing at all then imagine how long it will take me to write blog posts where I actually have a point to make! Hopefully by the time I start having ideas of communicable merit my writing will be sufficiently practiced that I can count the hours I need to write about the idea on one hand. Wow, that previous sentence took me like 5 minutes and it still doesn't make any sense. Those of you that are reading this do so because you know me (if somehow I'm wrong and you are random visitor, stop wasting time here and go read something of value - don't worry, I'll still be here when you come back in a year or two, and hopefully by then I will also have something valuable to offer). Hopefully I am proving to be at least mildly entertaining / interesting / motivating for you guys but I am painfully aware of just how much I'm relying on the whole its-worth-reading-because-its-someone-I-know factor. Ohwell, practice makes perfect.