Monthly Archives: October 2012

25 Years of Perl

A few days ago, I mentioned that I’m giving a talk at the London Perl Workshop called Twenty Five Years of Perl in Twenty Five (ish) Minutes.

I already have a good idea of how the talk will go. I’ve got a good structure to hang everything off. But I’m still working on the detail. I know I’m very old, but I haven’t been involved with Perl for the whole of its history. And even during the sixteen or do years I’ve been using Perl I’ve almost certainly missed some interesting things.

So I thought I’d crowd-source the talk a bit. What would you include in a history of Perl? What events do you think are important enough to be listed in a twenty minute talk?

Please leave your suggestions in a comment.

London Perl Workshop

Today, the initial list of talks for this year’s London Perl Workshop was announced. Looks like I’ll be giving three talks of various lengths. And of various levels of seriousness.

The rest of the announced talks sounds far more useful. Looks like the workshop will be as good as it always is. If you want to come along (and I highly recommend it), you can register on the web site.

 

DBIC vs DBI

Three times in the last few months I’ve had the “DBIC or raw DBI” discussion. People have told me that they don’t use DBIC because raw DBI is better. And each time, the person promoting DBI in the discussion has used an argument that boils down to “DBIC is probably useful for people who don’t know SQL very well”.

I find that argument really puzzling. Not least because I like to think that I know more than a little about SQL. SQL is a skill that that has run through my career for longer than Perl. I’ve been using SQL since I left college in 1988. I only started using Perl in about 1996. And yet, although I still consider myself a bit of an expert in SQL, I use DBIC for pretty much all of the database work I do these days – and have done for about five years.

I use DBIC not because I don’t understand SQL. I use it because it makes my life easier. I use it because it frees up some of the time I used to spend dealing with the minutia of database communication so that I can spend it working on other, more interesting, parts of my project.

When I’m running training courses that introduce DBIC I have slide that is entitled “SQL is Boring”. It’s a joke of course but, like all the best jokes, it gets a laugh because there’s more than a little truth in it. There are, of course, many interesting SQL problems. I’ve spent many an enjoyable (if slightly frustrating at the time) hour trying to coax the right data out of complex query with correlated subqueries, outer joins and aggregated functions. But that’s the exception rather than the rule.

The vast majority of the SQL I write for the applications I work on is incredibly boring. It’s  boring because it’s all so similar. You get the data to present a list of objects to the user. The user selects the object they’re interested in, so you select all the data about that object. You might select some data about related objects. The user changes some of that data, so you update that row in the database. On a good day, you might delete an object from the database. Or insert a new one. Most of the SQL you need is like that. It’s boring.

We have computers to do the boring work for us. So let the computer generate all that boring SQL. Free up your time to work on the gnarly and interesting problems.

But that’s not the only advantage of using DBIC (or some other ORM). Think about the data that you get back from the database. The data you get back from a DBI call is an array. Or perhaps a hash. Or maybe a multi-dimension data structure if you’re using one of DBI’x more complex fetch() methods. But it’s still a dumb variable. From DBIC, I get an object. An intelligent variable. A variable that knows how to react to various messages. A variable that will save any changes back to the database automatically without me having to worry about where it came from and making sure that I’m writing it back to the right place.

I’m not saying for a second that there’s no place for DBI any more. For a start, DBI underlies DBIC so it’s still a vital part of our toolkit. And of course I still use it for quick one-off scripts. But when those scripts are still hanging round being used and maintained three months later (as they always are) I’ll rewrite them to use DBIC.

If you want to write large applications that are going to be easy to maintain and extend, then you should really be using DBIC (or something similar). I don’t care how well you know SQL. DBIC will make your life easier.

I’ve just mentioned a couple of reasons why I think that DBIC makes my life easier. I’m sure I’ve missed important stuff. What do you think? Why do you use DBIC instead of DBI?

Perl School 2

Yesterday was the second Perl School course. Once again it was at Google Campus and once again it was on Modern Perl for Non-Perl Programmers. The big difference this time though was that people were paying £30 a time to attend.

And that did make a difference. While the previous (free) version sold out in less than a day, there were still tickets on sales for this one right up to the time it started. But I actually ended up teaching more people as far fewer people didn’t turn up (there were still four people who didn’t turn up though – guess some people don’t care about wasting £30).

I thought the course went well – but I’ll wait until the feedback forms come back before taking that for granted. It felt smoother than the first run and we finished on time.

One of the best things about these courses is the way that they draw in people who don’t usually get involved in  the Perl community. Of the twenty-five or so people in the room, I think there were three or four who I had met at Perl Mongers events or YAPCs in the past. As I finish with a section on where to go for more information and as that section includes a big plug for London.pm and the London Perl Workshop, hopefully we’ll see a few more people being drawn into the community.

So now it’s time to start looking ahead. The next Perl School is already planned. It will be on 8th December and will be about Moose. Running once every two months seems to be a pretty good rhythm, so I’m also starting to think about running one at the start of February. That will probably be about DBIx::Class.

As always, I’ll post something here when I have more details. But you can also watch the upcoming events page on the Perl School web site.

And if you have any ideas of other courses that I should be running as part of this series, then please let me know.