Modern Perl and I

I’m working on several projects.  Lately, my language of choice has been Perl because it lets me get things done quickly and because I can usually depend on the CPAN to have tools to make it easier and more correct.

Along the way, I’ve tripped over some really smart people doing some amazing work to make Perl more modern and more usable.  They seem to be people with great ideas who didn’t want to wait for Perl 6 and went and did something.  That’ been great to find and I’m learning a ton of things.

Maybe it’s interesting to hear how a competent Perl programmer found these new things, and that’s what I’ll start with today.

One of my projects has been a long time coming, at least partly because it was a lower priority than my day job.  It was also the first big web site I tried to build on my own, and I’ve had a lot to learn.

The original version, circa 2002, ran on HTML::Template, DBI, and an open source database called Firebird.  I’d wound up writing my own framework, much of it to get HTML::Template to behave the way I wanted, and to manage and cache database connections.

The first thing to go was actually DBI.  I started looking for an ORM after I tried Rails.  I knew I didn’t like Rails (too rigid for me!) but I wanted to stop writing interface functions for every SQL query I ever wanted to run.  I found DBIx::Class, and converted right over.  I was able to throw away a huge amount of dull code, and replace it with nice classes.  I didn’t ferret out all the SQL, but got most of it.

The next thing to go was Firebird.  The DBD::Firebird couldn’t handle some things I needed.  I ran in to similar (but worse!) issues with Firebird and Rails.  (DBD::Firebird couldn’t handle multiple concurrent queries, in certain cases.  Ruby’s Firebird database driver would core dump ruby!)  Because I was using almost entirely DBIx::Class, this really wasn’t too hard.  Postgres was the replacement, and it has been working very well.

The last thing to go was my own framework.  I really didn’t want to lose it, because it was clear to me, simple and straightforward.  However, there were things I was running in to that were not easy to solve with it, and I scratched my head and looked around for how other people had solved those problems.

I found Catalyst.

After much consideration, I took the plunge, and started a new project with Catalyst, and began moving my data over.  Wow, was I lost for a long time!

I still spend some time lost, in fact.  The scary part is that there’s two other people working on this with me, and I’m suddenly the Catalyst expert they’re talking to.

The hardest part of the migration has actually been the changes I wanted to make in the first place.  One of the things my old framework was not handling well was Single Sign On (SSO), and Catalyst hasn’t got that out of the box either.  Catalyst is closer, though.

HTML::Template went away when I moved to Catalyst.  I decided I was going to try and do things the Catalyst way, and that seemed to be Template::Toolkit.  A big glass of kool-aid later, we have new templates.  And they’re really nice, and I’m glad I switched.

The last raw SQL got tripped over and ripped out as well.  Everything is DBIx::Class now, even things which are easy in SQL and wind up being a little ugly in DBIx::Class.

I learned a ton about Catalyst’s Authentication system by figuring out how to get Catalyst::Authentication::AuthTkt to allow you to be signed out and see parts of the site.

I’ve also untangled a bunch of things my old framework put together that should really be separted in to the model and the view.  The model is getting richer and more complete, and all the logic for how things must interact is going there.  The view really just facilitates getting the right stuff in the right place for the templates.

Better design!  It’s one of the reasons I liked Catalyst, because it had that division, and mine was too weak.  It’s taking a while to move the code over, though.

I see that Catalyst has moved to Moose.  I’m reading about Moose.  There are parts I think are great, and parts I don’t get yet.  They’ll come, I suspect.

In reading about Moose, I’ve found a whole bunch of people writing about Modern Perl.  It’s a great phrase, and a great idea.  I may not be at the forefront of it, but I’m trying to follow along, to read the blogs, find the articles, learn the new techniques.

I’m trying to write more too, and to figure out how to contribute and be more a part of this community of really smart people.  One thing I discovered years ago is that if I spend time around smart people, I become smarter myself.  That’s always a good goal.

Matt Trout posted a link on his blog saying for Modern Perl to be a success, it needs to come out of the Perl Echo Chamber and in to the blogosphere.  Well, that’s the essence of what he said.  I can try to help.  I may not be famous, or known world-wide, but I’m using the tools every day, and I can put words on the screen about it.

I may use the blog as a way to reply to some of the others, who I haven’t found good ways to reply to.

So, here goes.  Blogging For Perl.  Away we go!

Tags: ,

Leave a Reply