Friday 24 November 2006

Sometimes...

So... last night, one of the job agencies I fed my CV to, who knows I've actually accepted a position elsewhere, scattershot a plea for a 6 month PHP contract to a large list of people.

I dropped back a mostly polite note pointing out that this wasn't perhaps very smart. The reply:

"Unfortunatly you are included in the same file as PHP, along with every other perl developer."

Houston, we have a perception problem.

Thursday 23 November 2006

"OO Perl"

A couple of people on the use Perl; version of this blog picked up on my use of 'OO Perl' as a term, and were less than complimentary about the language's OO features. I'm not here to defend that: however, it set me thinking about why I used that term, and whether it was what I actually meant.

It was, at least in part, prompted by my job search (more on that later, I promise). Look down jobs.perl.org, and you'll find that most of the well-paying jobs mention, in some roundabout way, LAMP or a variant thereof, and stipulate 'OO Perl'. The fact that I had 'OO Perl' (and legitimately so) on my CV (resumé for you transPondials) was welcomed with open arms by several recruiters who absolutely couldn't wait to get my details to their clients.

I think, in the end, this goes back to some of the comments I made about the Swiss Army Chainsaw, specifically, the distinction between Perl scripters and Perl programmers. How do you tell if someone's the latter, if their CV just says 'Perl'?

I don't think 'OO Perl' necessarily has to mean, literally, Perl in the Perl5 "bless {};" way. What the recruiters are trying to say, I'm pretty sure, is 'someone who treats Perl like a high-level programming language'. 'OO Perl' is, if you like, a shibboleth, to find the programmers amid the scripters, since a scripter's response will be either 'huh?' or 'no, that's scary'. (Joking a little, but you get the point.) It isn't, by any means, a perfect test, but it seems to me that if someone both uses OO Perl, and consciously self-identifies as doing so, they fall on the 'programmer' side of the divide.

And of course the problem, both for the recruiters and for our definition of LAMP++, is that Perl the language doesn't mandate it. Any more, actually, than Java the language does. You can quite happily write little Java ten-liners to do some mundane task that mangles a file, and never consciously touch an OO feature of the language. You can write really bad Java just as much as you can really bad Perl.

But... and here's the kicker... The frameworks that most Java enterprise projects are written in pretty much do mandate an OO approach, and what my Uni lecturers would call 'good software engineering principles'. And that means that folks raised in that environment have it as a similar shibboleth to 'OO Perl' to prove their credentials in the Java world. Now sure, once you start using Class::DBI, Rose::DB or DBIx::Class for your DBI abstraction layer, or a goodly number of the popular CPAN modules, you're at least required to talk to them in an OO way. But there's nothing to stop your actual application code being a Big Ball Of Mud, a God Object, or any number of other anti-pattern horrors.

Which reminds me. I should talk about Design Patterns.

Wednesday 22 November 2006

So, what IS 'enterprise'?

Time to bite the bullet, I guess. What do we mean by 'enterprise'?

Consulting the Oracle, more formally known as Wikipedia, we find, in the Enterprise software entry:

Enterprise application software is application software that performs business functions such as accounting, production scheduling, customer information tracking, bank account maintenance, and the like. It is almost always hosted on servers, and is used by multiple employees of the same organisation. It can also be any software application hosted on a server which simultaneously provides services to a large number of users, typically over a computer network. This definition contrasts the more common single-user software applications which run on the user's own local computer, and serve only one user at a time.

Actually, y'know? That's not bad. The first half is the 'traditional' definition of 'enterprise', perhaps, but I want to zoom in on the bolded sentence: "It can be any software application hosted on a server which simultaneously provides services to a large number of users, typically over a computer network.". The main reason I'm aiming for that is that it then covers not only internal CMS's, publishing applications and the like, but also end-user facing systems (such as, for example, Amazon or Flickr).

Let's take that second sentence as our prototype definition, and dissect it to see what it implies. I'm very aware that I'm reaching, just a touch, with some of this, but it's a very good jumping off point to allow us to reach a definition of 'enterprise'.


"...software application..."

It may seem odd to pick this one out, but bear with me. Implicit in this is the concept that it's something you can point at and say "this was built to do X". In and of itself, that's perhaps not much, but what follows on from this is: its functionality is well defined, and from there, it's a very short leap to saying it is designed using good software engineering principles.

"... hosted on a server..."

Instantly this implies it has a client/server architecture of some sort. Maybe its true that most of such applications will have a web browser as their client, but let's not assume that: a mail server is just as clearly an enterprise application.

"...simultaneously provides services... "

I dunno about you, but to me that screams a requirement that the software is thread and transaction safe - no one user's changes should be able to overwrite another's.

"... to a large number of users..."

Following on from thread and transaction safety, that adds to our requirements the obvious one that it must be scalable.

"... over a computer network..."

Again, a little bit of a stretch, but that phrase should ring alarm bells in any sysadmin's head. It should be secure against unauthorised use.



How's that?

Monday 20 November 2006

LAMP++?

Writing the previous post raised a number of thoughts while traversing the London Underground, which will keep me going in blog entries for a while, I think.

So... LAMP.

Linux, Apache, MySQL, and Perl (or PHP, but I kind of promised myself this blog would be mostly PHP-free. :) ). As characterised by O'Reilly's excellent OnLAMP section, in fact, which is recommended reading, and a champion of the cause.

Is this Enterprise Perl?

Interesting question. I think the answer is, sort of: it's its skeleton. It's the bones on which you can build an enterprise-level application in Perl. (Which reminds me - we still need to define exactly what we mean by that troublesome term 'enterprise', don't we?) But it doesn't actually define anything. A single CGI that uses the HTML generation methods and talks raw DBI to MySQL is as much LAMP as a fully OO MVC-style web application written in TT2 and DBIx::Class.

It clearly can work, though: Yahoo's internal CMS is written in Perl, so's IMDB, Amazon's publishing system, the entirety of CricInfo (trust me, I designed it - it's a TT2 fronted MVC web app, or at least it was when I left)... all these can be pointed at as examples of LAMP-done-well, and cover four of the biggest sites on the web (even CricInfo - a quarter of a billion page views a month on a single sport site). OK, so the 'L' occasionally stands for FreeBSD, but we'll draw a view over that - the spirit of the 'L' is 'Unix or Unix-alike on x86 commodity hardware', and we can let Yahoo off, just as we can excuse the folks who use Postgres. But there's really more to these than LAMP, or at least, we hope there is.

What we're looking at, from an enterprise point of view, is something I'm going to call LAMP++. I'm sure, with a bit of work, we might be able to come up with a better acronym, but by analogy with C++, LAMP++ is actually not that far off the mark. The '++' means we're talking adding, or rather mandating, an OO approach to Perl (including an OO DBI abstraction layer), some form of templating, be it TT2, Mason or whatever, and some form of Apache-embedded Perl interpreter (mod_perl). We're looking for Perl programmers, not scripters, and we'd probably really like test-driven development, too. We're taking as our bible not the Llama and the Camel, but Perl Best Practices and Intermediate Perl, and to guide our philosophy we keep handy Perl Testing: A Developer's Notebook, and Perl Design Patterns.

LAMP++. It's got legs, I reckon. More anon.

jobs.perl.org

So, here I am, with an uncomfortable sense of 'are my skills becoming obsolete?'.

$CurrentEmployer is, as I noted, predominantly a Java shop, and I have, in the past week, rolled out what's going to be the last piece of Perl development they need (modulo some differences of opinion between RedHat and Debian's default module setups, which means I'll be doing it all again today!). Which leaves me, pretty much, with the choices of: learn Java, or find a new job. Perl advocates the world over are no doubt cheering the fact that I made the second of those two choices. Let's face it, there wouldn't be much point in this blog otherwise: you'd be reading something called "A Perl Programmer's first steps in Java" instead.

Why? Well - two reasons, really.

First off, with what amounts to entry level Java skills plus (fortunately) a sound grasp of programming in and of itself, I'd be very much a junior developer, and while the idea of getting my teeth into a new language has a certain appeal, coming in well down the ladder, and spending most of my evenings drowning in J2EE acronym hell and a pile of "Learn $JavaThing in 30 Days" textbooks isn't my idea of fun.

And secondly? It's not Perl. For all this may not be clear in some of the previous postings, I love Perl, for its power and simplicity, for the fact that it /is/ a Swiss Army chainsaw, that I can do everything, from a one-liner to fix Apache2 module paths when porting from Debian to RedHat, to a complete CMS or banner ad serving engine, in the same language. And quite frankly? Java leaves me cold.

And it's jobs.perl.org to the rescue!

I'll admit, I was pleasantly surprised. There's a raft of Perl jobs up at the moment within commuting distance of where I live, mostly in London, and a surprising number that pay noticeably better than I'm currently earning (and are a good half an hour closer to home). In the context of this blog, they make interesting reading. A surprisingly large number mention 'OO Perl' as a requirement, and an equally, and almost correspondingly large, number mention LAMP, either by name or by implication.

By contrast, it's amusing searching the likes of Jobserve or Jobsite for jobs that mention Perl - what tends to come up is a lot of Java, .NET or sysadmin jobs with a little 'oh, and Perl scripting would be handy' coda tacked on the end. In fact, /all/ the jobs I've applied for this past week have come from jobs.perl.org.

So, gentle reader, you're probably wondering where that leaves our hero? Actually, not too badly off. But, more of that in a later post.

Wednesday 15 November 2006

The downside of the Swiss Army Chainsaw

One of the accusations often levelled at Perl is that it looks like line noise. My standard defence against this is to pull out a piece of my code, which tends to be written in a clear, OO-style borrowing heavily from Perl Best Practices, with, god forbid, comments, as a counter example, which does tend to shut people up, usually with some grudging remark about 'yeah, OK, but it doesn't all look like that'.

And sadly, that's true. It doesn't. Even some of my code doesn't - if I throw together a one or two liner to do some sysadmin task, odds are it'll make copious use of $_, m// and temporary hashes with single character names, and look like one of my cats jumped on the keyboard at an inopportune moment.

Why?

Because Perl lends itself to both styles. It is, in truth, the Swiss Army chainsaw of programming languages, capable of emulating sed, awk, grep and a host of Unix command line tools, as well as C++ and Java, a place where the Perl 3-ish language constructs and innumerable clever command line flags meet the Perl 5 OO syntactic sugar that'll evolve into Perl 6 (of which more in a later post).

Some of the problem, at least, lies in its accessibility. It doesn't take much to learn the basics, and I've seen some pretty ghastly things done in the name of Perl by folks who don't know any better. At one of my former jobs, my most common complaint about some of our new hires was that they were great Perl scripters, but very few of them knew the first thing about being Perl programmers. To quote an article in the Links section of this blog, there are too many people out there still writing Perl 3, treating the language like awk-with-added-cool.

If you go a-hunting for Perl resources on the net, you'll find a disturbing number of things like guestbook and article management scripts written by well-meaning people, in a very Perl 3-ish style, some of whom may even, if you're lucky, have heard of CGI.pm, but almost certainly haven't come across CPAN. Now, admittedly, you could make the case that a lot of these are targetted at folks who have a hosting account with no support for extra Perl modules. It is, though, a sizeable part of the problem - the whole perception issue of Perl being a grubby little language for doing dirty little jobs dirt cheap in a dark alley.

I put it to you, in fact, that the very title of the Camel book, "Programming Perl", is a lie. It doesn't teach you to program. It teaches you to write better Perl scripts.

TMTOWTDI

It's clear from watching $CurrentEmployer's recruitment, that if you're in search of Java Enterprise developers, it's not only easy to find a whole boatload from which to pick, but a trained monkey can go play buzzword bingo on their CVs to reduce it down to the half dozen key acronyms that get you what you want: Java, J2EE, EJB, Tomcat, JSP, JSTL. For a bonus, add on Eclipse, Hibernate, XML and its children, UML and the like, and you can pretty much come up with a short list of candidates who you know will have the skills you need to develop in a Java Enterprise environment. And more to the point, it'll be very similar to the environment they came from and are used to. And the list won't actually be that short.

Switch to Perl, and... well. For Java read Perl. Easy enough. For J2EE read... Um. Let's skip that one. For EJB... uh, moving right along. For Tomcat, we have mod_perl + Apache: that's fair enough. For JSP? Template Toolkit, or Mason, or Embperl, or... a whole list. For Eclipse...? How many people actually use an IDE with Perl? For Hibernate, we have Class::DBI, or DBIx::Class, or several other layers of varying depths of abstraction.

And there's one of the problems: that great virtue of Perl, that There's More Than One Way To Do It, comes and bites us - not everyone who holds their hand up and claims to have developed using Perl-in-the-Enterprise has anything like the same set of core knowledges. Going back to J2EE - there's that 400 page document that defines it, and the big driving force that's behind it, Sun, centralising the definition of what is and isn't part of J2EE.

We don't have that in Perl: take a look at the rich diversity of CPAN, the archive that almost defines 'TMTOWDTI'. It's great - given a task you can pretty much bet the project that you'll be able to find a module to do it. Except... to take an entirely random example simply because it cropped up today: I wanted to populate our user DB with GUIDs. It seems likely that there should be a module in CPAN to do it, right? So let's look.

Hallelujah! There is!

Without looking at all hard, in fact, there are three. One's dependant on another, and the third seems to be completely standalone.

And nowhere is there a standard, a definition, a set of guidelines, that says "use this one, 'cause it's the best" or even "use this one because we know what we're talking about and we say so."

To be fair, there are now a bunch of modules that ship with the core Perl distribution that are the approved way to do various basic Perl tasks, and without which Perl pretty much won't do anything useful. There are also modules that have reached the status of being the de facto standard for a task: CGI and LWP::UserAgent are two obvious candidates.

But there are also cases where there are many, many modules: consider the Date:: sprawl for one, the vast array of things with Template in the name, the various DBI abstraction layers, the countless bean-like Class::* modules... And there's no finger pointing at us to say 'this one'. Sure, we can define a corporate standard that says we're going to use Date::Simple, Class::DBI and TT2, and that's fine for us. But the next guy may decide to use Date::Manip, DBIx::Class and Mason, and architect his app a completely different way. There is no standard.

Of course, the obvious question is 'does this matter?' And I'm going to leave that for a later post.

Tuesday 14 November 2006

What IS 'Enterprise'?

After a particularly brain-numbing hour attempting to persuade a development build of our main web site's Perl back end (on Debian) to actually run on a co-located RedHat Enterprise License server, I wondered aloud, with a degree of frustration, "So what the heck does 'Enterprise' mean, anyway?"

Our sysadmin, who is prone, like all of his ilk, to disparage any and all instances of rampant abuse of buzzwords, offered that it meant, among other things, 'very very slow, uses XML unecessarily, and comes with a default configuration that's no use to man nor beast'.

Mischievously (for reasons perhaps to be explained in a later blog entry), I suggested that that could be summed up in the four letters 'J2EE'.

One of my Java-savvy colleagues (in fact, all my colleagues here are Java-savvy) opined that that wasn't exactly fair, and that 'J2EE' wasn't really anything more than shorthand for 'go read this 400 page document on The Right Way To Do Things'.

Interesting.

I'm in the minority here at $CurrentEmployer, since I /am/ the token Perl developer. But this, and a whole load of other things, have got me wondering. Why isn't there a 'Perl Enterprise Edition'? Maybe there is, and I'm missing it? What would it be, anyway? Perhaps the question is, where's that mysterious 400 page document that tells us what it is?