Search Results: "Matthew Palmer"

5 October 2008

Matthew Palmer: The Healing Power of Hate

They say that there's very little difference between love and hate. A good example of this is the Linux Hater's Blog. It's written by someone who obviously has a lot of experience with Linux and Open Source, and I get the feeling that the hate comes of frustration and pain. Certainly, I've seen plenty of similarly themed articles coming out of Planet Debian at one time or another. One of the best articles I've found yet is One bug report to rule them all, a humourous but altogether painfully accurate rendition of far too many bug reports I've seen and dealt with of the years.

12 June 2008

Matthew Palmer: Womble's Word of the Week: Retrofit!

In a perfect world, when we design some aspect of our infrastructure, we'd get it right the first time, and would never have to change our design once it had been deployed. Back in this world, however, we regularly have to change things as we expand our infrastructure. Sometimes we made a mistake originally, other times new requirements pop up. In either case we will end up doing things differently in the future than how it was done in the past. The danger here is that if you only create your new machines or services differently, you've got effectively two separate and different systems to maintain. This may not sound like much, until it happens again... and again... and again... and then suddenly you've got 18 different ways of setting up backups, depending on how long ago you set it up and (if you're really unlucky) who did it and what the phase of the moon was at the time. If you've been here before, you probably remember the pain of having some disaster happen and needing to fix it NOW NOW NOW, only to wade into the setup and realise that it's been done in a way that (you thought) died out six months ago -- and so you don't really remember how it works, and yeah, the documentation's been updated so many times since then that it doesn't mention the old way of doing things, and here comes your boss to ask how long it's going to be until it's all working again... If you haven't had this experience (yet?), you'll have to trust me when I say that it's no fun to hit an older, out-of-date system. It's especially painful because the most common reason you change things is because the old way sucked. So you turn up at a critical moment to fix something in a poorly documented and sub-optimally configured system. Fun, fun, funnity fun. There are only two ways to avoid this problem: never change the way you do anything, or else plan your changes so that retrofitting is part of the plan every time you're modifying an existing service. Assuming that never changing anything isn't an option, you need to plan to retrofit. When you're putting together the design for your system change (you do design your changes, right?) you need to audit what's out there, determine what's needed to bring it all up to date, and put together a plan to make that happen. It's like documentation and testing -- if you don't make an explicit effort to make it happen, it'll never get done. That sounds like a lot of work, and it is. Luckily, if you're already working in a well-maintained infrastructure you should only really have one existing config to upgrade, which shouldn't be too painful. However, if you've got a lot of machines to change there's no way around the fact that they've all got to be changed, and that can take time. If you accept that you don't want configuration skew, you can start to think about how to engineer your systems and processes to make it less of a hassle to keep everything up to date. Putting some extra thought into how you set things up in the first place so that it's easier to update is at the heart of this. Automating deployment is an easy way to take some of the pain away from rolling out new configs, but there's also plenty of smaller decisions that help with updating configs: putting everything in revision control, making extensive use of templating and pulling out common config fragments, and making sure that you've got good notes and records of what has been done where. The more you automate your deployment and maintenance, the less pain you feel when you need to retrofit. With something like Puppet, you can eliminate a lot of the pain because you're describing what you want done for all the relevant machines, and then the machines themselves work out what needs to be done to bring themselves up to date. With an advanced automation system in place, you can say "I want all my mail servers to have setting X turned on" and off they go and set the option. Or you might want to have some of your mail servers to have a different config setting, triggered based on a config setting or class of machine. Of course, you might not already have that config setting or class defined, so you'll need to add it. Don't forget to retrofit that new config setting or class to your existing machines. That might involve finding the config for all the existing machines and modifying them. Yep, no matter how much automation you've got you can't get away from the need to retrofit, but given the choice between editing a bunch of config files on my local machine (with all the power of my text editor to back me up) or logging into dozens of machines all over the globe to edit their configs and restart services (with all the risks of making a mistake) I know which one I'd choose...

5 May 2008

Matthew Palmer: Distributing Ruby Programs

Hell Yes, With Bells On. That is all.

3 May 2008

Matthew Palmer: Spam Filter Developers and Administrators: Dumber Than The Dumbest Person On The Internet

For the past couple of days, one of my e-mail addresses has been some spammer's choice for forged From: lines in their spew. So, as invalid addresses aren't high on a spammer's list of priorities, I get all the bounces. The fact that MTAs, in this day and age, don't have SMTP session recipient validation is unpleasant. However, with ISPs requiring all outgoing e-mail to go through their own servers, I can kinda see where that can break down. I still don't like it, but I'll live with it. In amongst all the bounces, though, there's a lot of other, really obnoxious, crap. So far, I've had five "please click this link / reply to this e-mail so it'll go through" (AKA "please filter my spam for me")[1]. I've also had a large number of e-mails saying that my e-mail was blocked or unwanted or whatever, from spam filtering programs themselves. What I haven't got any of, as far as I can determine, is any e-mail from enraged recipients saying "stop sending me this crap!" or anything of that nature. The only conclusion I can reasonably draw from this data is that users know that source addresses are forged and there's no point replying to them, but the people whose job it is to write, maintain, and run spam software don't. That's downright embarrassing. Not a single user was dumb enough to assume that I really sent the e-mail, but IT "professionals" who deal with spam for a living are. If you are in any way involved in the production, sale, or use of an anti-spam product that hasn't realised that the from addresses of spams are universally forged, please shoot yourself in the head. Really. I'm sick to death of people who should know better doing the most stunningly stupid things regardless. If you don't know that your software is spamming the rest of the world, then you're still on the hook. What other dumb shit is your system doing that you know nothing about? On the other hand, if you do know that your spam filter is contributing to the noise, you're even worse -- no spam has a real source address. If your software or system spews crap because some clueless manager told you to do it, then you need to grow some courage and ponder on the words of Napoleon:
A commander-in-chief cannot take as an excuse for his mistakes in warfare an order given by his sovereign or his minister, when the person giving the order is absent from the field of operations and is imperfectly aware or wholly unaware of the latest state of affairs. It follows that any commander-in-chief who undertakes to carry out a plan which he considers defective is at fault; he must put forward his reasons, insist on the plan being changed, and finally tender his resignation rather than be the instrument of his army's downfall.
In other words, if you did it and you know you shouldn't have, it's still your fault, regardless of why you did it. Take some responsibility for your actions, for fucks sake.
[1. Every single one of which I was more than happy to confirm -- if you want other people to do a job for you, you have to deal with the fact that some of them might not do it in quite the way you expect. I encourage anyone else who thinks that an anti-spam system that requires the rest of the world to filter your inbox is stupid (even disregarding the likely problems of infinite loops if everyone had a challenge-response inbox) to do the same.

1 May 2008

Matthew Palmer: Architecture Astronauts

I really don't think I have anything to add to Joel Spolsky's latest essay, on the horror of architecture astronauts. My favourite quote:
It sort of bothers me, intellectually, that there are these people running around acting like they're building the next great thing who keep serving us the same exact TV dinner that I didn't want on Sunday night, and I didn't want it when you tried to serve it again Monday night, and you crunched it up and mixed in some cheese and I didn't eat that Tuesday night, and here it is Wednesday and you've rebuilt the whole goddamn TV dinner industry from the ground up and you're giving me 1955 salisbury steak that I just DON'T WANT. What is it going to take for you to get the message that customers don't want the things that architecture astronauts just love to build.

16 April 2008

Matthew Palmer: When you think you're good...

It's stories like the following that make you realise just how puny your talents are... (Reposted from a place not to be named, by the legendary Al Viro)
Give them what I got yesterday. As in, box that got
        a) Linux kernel running.
        b) init and bash running.
        c) serial and floppy - built as modules. And not loaded.
        d) no sash.
        e) no ethernet.
        f) bloody large number-crunching that Should Not Be Aborted(tm).
        g) libc and ld-linux.so - unlinked (self-LART by owner).
Now, I could tell the guy to piss off, but... WTF? He had decent beer and
was properly scared. Oh, well... So we have no exec() for anything
dynamically
linked. And we have no chance to access any external stuff - insmod is
linked
dynamically, so no insmod floppy for you. Shutting the system down was not
an
option due to (f) (aside of dealing with fsck later - umount(8) is
dynamically
linked too). Now, I knew that both /lib/libc.so-2.1.2 and
/lib/ld-linux.so-2.1.2 were still alive - mmaped by init, for one. And
/proc/1/maps would even contain their inumbers. So the plan of attack was
to create a file in root and then cannibalize the entry (change inumber in
the directory). Alas - not enough. In-core inode got zero i_nlink and
if I would just create a link by hands it would not become positive. I.e.
still remove-upon-close. But. But if we will manage to call link() on the
hand-made link we will get i_nlink raised to 1 - iget() will find the same
in-core inode, so we are OK. We'll have to revert the phony link to avoid
PO'd fsck, but that's not a problem...
        So there we go: assuming that we got static ln
echo >foo
ln foo bar
flip inumber in foo entry to point to libc
ln foo /lib/libc.so-2.1.2
flip inumber.......................... bar
repeat for ld-linux.so
rm foo bar
begin recovering other damage (self-LART was a bit larger).
        But... we don't have this flip stuff and we don't have (aaarrgh)
static
ln. Oh, shit... OK, but all we really need is a couple of syscalls, right?
There we go:
        eax=__NR_link;
        ebx=s1;
        ecx=s2;
        int 0x80;
        eax=__NR_exit;
        ebx=0;
        int 0x80;
s1:     "foo"
s2:     "bar"
The next step was getting the syscall numbers. grep? We don't need no
stinkin'
grep.
# while read i; do case $i in *__NR_link*) echo $i;; esac;
done </usr/include/asm/unistd.h
#define __NR_link 9
# while read i; do case $i in *__NR_exit*) echo $i;; esac;
done </usr/include/asm/unistd.h
#define __NR_exit 1
#define __NR__exit __NR_exit
Now, scratching the head and recalling intel code...
start:  b8 09 00 00 00
        bb (address of s1)
        b9 (address of s2)
        cd 80
        b8 01 00 00 00
        bb 00 00 00 00
        cd 80
s1:     66 6f 6f 00
s2:     62 61 72 00
Fine, but... a.out support is compiled... you guessed it, as module and not
currently loaded. So we are in for crufting up an ELF binary. OK, we don't
actually need 100%-correct ELF, just something that will pass for the
exec(). Now, we don't have shell scripts, but . will work. So the next
step was rolling more(1) in shell and reading through the relevant code
(surprisingly small - binfmt_elf.c and two headers). After much swearing
the following abortion was created:
7f 45 4c 46 00 00 00 00 00 00 00 00 00 00 00 00
02 00 03 00 01 00 00 00 start______ 34 00 00 00
00 00 00 00 00 00 00 00 34 00 20 00 01 00 28 00
00 00 00 00 01 00 00 00 00 00 00 00 base_______
base_______ size_______ size_______ 05 00 00 00
00 10 00 00
start:
b8 09 00 00 00 bb start+1d___ b9 start+21___ cd
80 b8 01 00 00 00 bb 00 00 00 00 cd 80 66 6f 6f
00 62 61 72 00
OK, set base to something page-aligned, start=base+54, size=79. There we go:
7f 45 4c 46 00 00 00 00 00 00 00 00 00 00 00 00
02 00 03 00 01 00 00 00 54 00 00 80 34 00 00 00
00 00 00 00 00 00 00 00 34 00 20 00 01 00 28 00
00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 80
00 00 00 80 79 00 00 00 79 00 00 00 05 00 00 00
00 10 00 00 b8 09 00 00 00 bb 71 00 00 80 b9 75
00 00 80 cd 80 b8 01 00 00 00 bb 00 00 00 00 cd
80 66 6f 6f 00 62 61 72 00
well, while read l; do for i in  echo $l ; do echo -ne "\\$i"; done; done
made for oct2bin, overwriting /usr/bin/emacs with the output of that gave
us static equivalent of ln foo bar. And it worked. The rest was essentially
the same - the only tricky part was to find the location of directory entry.
Which was done with (lseek, read byte, exit(said_byte)) and shell wrapper
around that. So we had a way to read a block and dump it on the console.
The rest was obvious - start from relevant block in inode table and walk
through the references... Once we got that, it was an easy ride - trick
with inumber flipping brought libc and dynamic linker back and after that
we had 99% of system back into the working state. Amazing how little you
actually need to bring the system back to life...
Hot damn that's some deep hackery...

15 April 2008

Matthew Palmer: Blahsagne

Blahsagne, n.: A tasteless pile of pasta sheets and nominally tomato-based sauce, usually found in the cold store section of supermarkets.

4 March 2008

Matthew Palmer: Dear Web 2.0 Application Authors...

If you insist on having several levels of pulldown menu in your application, would you mind not having each one make an AJAX call back to the server to get the contents of the menu? The "click... wait... click... wait..." to navigate where I need to go gets particularly tedious when I have to do it in excess of 100 times today. Stabbity Stab, Matt

25 February 2008

Matthew Palmer: IEEE, Thou Art Clowns

Ever since I started University, I've been a member of the Institution of Electrical and Electronic Engineers. Although I don't really do what you would call "Engineering" any more, I like to read the IEEE Spectrum magazine and some of the Computer society journals are quite relevant to what I do. However, this year the IEEE have produced what is, without a doubt, one of the most shithouse online ordering systems I have ever had the misfortune of trying to use. To start with, if you happen to go to the account login screen with cookies disabled, you get a page that is utterly blank. I've seen a lot of ways to fail to handle cookies, but I think the completely blank page is a first for me. Once you work out what's going on and log in, you're presented with a long and painful journey through a series of "checkout" pages, mostly alike. I think I got presented with my list of journals about four times. After navigating that pest, it comes up with this little gem when you start the credit card processing step: To Back, or Not
  To Back Then, every time you input practically anything into the form, it does a Javascript submit and does things to the form. For example, when you enter your credit card number, you get a form back that has blanked out all but the last four digits of the card number. OK, a little dumb, but not spectacularly so. Although, when you're a quick typist and have filled in the next three fields while the web browser was playing footsie with the slow-as-molasses web server, only to have that data wiped out when the page refreshes, is a bit of a pest. Far more annoying is when you start entering your address "for verification purposes". Here, you get a form resubmit every time, presumably to update the form based on (for example) your selected country, but not a lot changes. Even though I picked Australia, I still got a pull-down with all of the the US states in it. You could short-circuit all this with the "choose existing address" option, except that (despite me being logged in) my existing addresses aren't in a select box, but in a separate pop-up window (which didn't actually display anything after all). In short, the IEEE's online renewal system is a disgrace, and is an embarrassment to what is purportedly a technical organisation.

20 February 2008

Matthew Palmer: Aaargh! Wikis!

You know you've got a bad wiki when you start pining for "the good old days" of MediaWiki. Yes, this wiki I need to use is that bad.

8 February 2008

Matthew Palmer: Part of the 73rd Barbecue Division...

... is Donna Benjamin and her army of mignons. I'm going to have the mental image of a large collection of steaks wrapped in bacon marching around a parade ground stuck in my head all day now.

4 February 2008

Matthew Palmer: What Time Is It There, Anyway?

As Internet-connected people, we tend to interact with a lot of people who aren't necessarily geographically co-located. Hence today's cool little program I found: gworldclock. You pick an arbitrary number of timezones to have in your list, and the current time in all of them is displayed in a neat list, quietly ticking away regularly. Small? Yes. Trivial? Getting close to it. Really Useful? You betcha. It also has a very tidy 'rendezvous' mode, where you choose a time, a timezone (from your list of selected timezones) and it shows the corresponding time in all of your other chosen timezones. Again, something that 20 minutes of coding will probably produce, but the whole point of this open source thing is not having to re-invent the wheel... The 'g' does indicate a GTK application, but there is a kworldclock for people who wouldn't be seen dead with a GTK application on their desktop, and a console-only version, tzclock, for anyone who lives the text-mode life.

27 January 2008

Matthew Palmer: Kudos to the Lazyweb

Wow, I think I got more "search results" than Google from yesterday's lazyweb search on HTML formatting. <grin> It turned out to be quite simple, as over 40 people were kind enough to point out to me -- in HTML, images are textual, "inline" elements, and so they get treated like text, in that if there's whitespace (any amount) between them, the browser treats them as separate "words" and puts some space in there. That also explains why they moved depending on the font size I chose -- the size of inter-word spacing is, of course, dependent on your font size. I'd like to thank everyone who responded and helped me out. In addition to getting the answer to my problem (which was simply "remove all whitespace between the image tags and butt them right up next to each other", like this: <img ... /><img ... /><img ... />) I got a couple of other useful related tips (like switching the images to display: block and then treating them like a div with floating and such). As much as it pains me to say it, though, I think I'll be following the tip given to me by one respondant: "just use tables". Yes, the gods of good web design shall smite me, but it is insanely difficult to get a really good, cross-browser layout happening using just CSS. It was fun to play the tweaking game the first couple of times (my blog layout is all CSS, for example, and my brigade's website, which I recently re-did, is all CSS), but each of those took me hours to get what are, at the end of the day, pretty basic and not particularly good looking sites. When all is said and done, it's just too damned hard.

26 January 2008

Matthew Palmer: Dear Lazyweb: Where Are Those Borders Coming From?

CSS is a lovely principle, but between browser bugs and an insanely complex standard in practice, it's not nearly so fun. Today's case in point: I want three images stuck right next to each other. I've got an example of the sort of thing I want to do -- in that example, I want the three coloured squares to be adjacent, not separated by several pixels of whitespace, and for there to be no white between the boxes and the bottom border. In order to make this happen, at the moment, I've got to set negative right and bottom margins, which to me is just completely screwed up -- negative margins, to me, means overlap, not adjacency. What makes it even worse is that different browsers need different pixel counts. So far I've tested on IE6 and Firefox 1.5. The thing that really does my head in, though, is that fact if I change the font size the gap changes. So somewhere inside of both IE6 and Firefox 1.5, there's some relative size getting in the way of just sticking pictures next to each other. Update: I've been given the solution. Thanks to the 50 or so people who responded; it's great to know there's so many helpful people out there.

Matthew Palmer: Looking Behind The Proprietary Curtain

It's interesting to compare the "marketing features" of proprietary version control systems and the FOSS equivalents. For example, I happened to stumble across SourceGear Vault, and I have to say that the feature list, as given, doesn't impress me particularly. When the most impressive features you can think to mention are things like "All repository data is stored in a SQL Server database" and "the checkin operation is atomic", I'm thinking you're probably not a serious competitor against some of the truly state-of-the-art systems that are commonly used in the open source world. Based on the advertised features, I'd say that Vault probably doesn't compare favourably to SVN, let alone bzr or darcs. Overall, I don't think we're doing so badly in the innovation stakes. <grin>

23 January 2008

Matthew Palmer: A Wheel With Corners

How often have you said to yourself "this programming language's if statement is too flexible, I need to make it more rigid, and with a syntax nobody else understands"? If you've ever said that to yourself, then take a look at this Rails plugin. From the brief description of the plugin:
Allows developers to execute or not execute given code block depending on a set of conditions, written in intuitive manner. Especially useful within view templates, where it can eliminate the need for multiple if ... else ... statements.
That screams "overkill" to me, but for the sake of my morbid curiousity (and on the very, very off chance that it's something not entirely ridiculous) I took a look at the detailed documentation. At least there is detailed documentation for this plugin. I didn't get any further than the first example, though. Take a look at this monster:
How often do you find yourself writing something like that in your views:
	  <% if current_user != :false && (current_user.administrator?   current_user == @profile.user) %>
	    <%= button_to('Big Red Button', destroy_everything_path) %>
	  <% else %>
	    <%= button_to('Hands off!!!', access_denied_path) %>
	   <% end %>
	
It works, but, you know, it's not what you would call beautiful, is it? What about something like that:
	  <% access.to_administrator.or_user_of(@profile) do %>
	    <%= button_to('Big Red Button', destroy_everything_path) %>
	  <% end.else do %>
	    <%= button_to('Hands off!!!', access_denied_path) %>
	  <% end %>
	
At least conditions are looking much better, aren't they?
Hopefully, most people out there answered a resounding "no" to that last question. A plugin which causes you to write just as many lines and very nearly as many characters, whilst using a completely different minilanguage to what every Ruby programmer already knows, does not sound "much better" to me. Ruby people tend to love little minilanguages to get things done, but this... I just don't have the words to properly describe it. I'm going to start a list of "poison plugins" -- ones that, if I see any of them in or around the code of a Rails project I'm looking at working on, immediately doubles the hourly rate and the time estimates. Stupidity is toxic, and working with hazardous substances is always more expensive. Other current candidates include the old-world auth generator I gutted while I was at Vquence, and annotate_models -- the former because it's shocking code, and the latter because anyone who uses it has some seriously scary ideas about what constitutes acceptable documentation and development practices.

17 January 2008

Matthew Palmer: Dear Software Authors...

I really appreciate that you've written tests for your software; it raises the chances that you're not a screaming moron by a few points. However, please understand that you may not be the last person on earth who may wish to benefit from the test suite, and DOCUMENT HOW TO RUN THE FUCKING TEST SUITE. I'm currently into my third hour of trying to work out what precise set of dependencies and incantations is required to make your test suite run. Bonus hate is available for that subset of these people who reject patches that don't come with suitable additions to the test suite.

31 December 2007

Matthew Palmer: Go Wide or Go Deep

This blog post, Wide vs. Deep, provides a different viewpoint on the same topic I was going on about a few weeks ago in Strategists and Tacticians. It's well worth a read if you found my post at all interesting.

Matthew Palmer: Cowboys

I am very saddened by the state of the IT industry. It seems like nearly everyone who works in or around IT is, to put it bluntly, a cowboy. There appears to be very little desire for actually helping people; instead all I see is a very large number of people circling around looking for the next person they can make a quick buck off. In short, most of the IT industry is composed of people who are little better than shysters and conmen. As a case in point, I recently had contact with someone who is trying to get an online store running. They've been trying, unsuccessfully so far, for several months. They've been screwed over by basically every IT-related person they've had contact with so far. Now, after all of their suffering, they've finally gotten in contact with me. Most of their money is gone, and they're deeply behind schedule. So I'm left trying to pull a miracle job in little time and with little money. Yes, I could shoo them away, because they're asking for more than they can afford, but there's a little spark of helpfulness left in me, and I'll try to get them going as best they can with what they've got. If they'd found someone competent right at the beginning, they'd have been fine. They started with sufficient cash and time to produce a good end result. But chancing upon someone decent doesn't have good odds in IT; it's a bit like winning the lottery. This story isn't unique in my personal experience, by any stretch. There seems to be a near-endless procession of non-technical people who come out of their encounters with the IT industry battered and bruised, whether it be on the web, in their business infrastructure, or their personal computing needs. While it's easy to blame the customer for not managing themselves and their computing properly, I don't think it's fair to lay the blame on them -- to me, that's like blaming the patient for dying on the operating table, when the responsibility must lie, prima facie, with the surgeon. It's the surgeon, after all, who is the (presumably) trained and experienced professional in the relationship, and it is his responsibility, primarily, to ensure that everything goes smoothly[1]. Depressingly, I don't see much of a way around this problem. The few IT people who did care could try and group together, build some sort of a rating or "membership implies quality" system, educate the consumer, and try and drive the cowboys out, but guilds and trade associations are frowned upon these days, smacking (as they do) of restraint of trade and collusion. Government regulation never seems to produce anywhere near the desired result, while hoping that the consumer will either rise up and demand quality, or will gain sufficient knowledge to be able to pick a cowboy is a complete non-starter, for the same reason as teaching everyone basic surgical techniques isn't going to improve the quality of hospitals.
There's an ad that used to be on Australian TV for a certain bank, where a guy is at a party and he's asked by another of the partygoers what he does for a living. As he replies, "I work in banking", the entire party goes silent and stares at him in horror. It's only when he says, "It's OK, I'm with $BANK_BEING_ADVERTISED" that everyone looks happy again and continues on with their party. Although I've never had that particular experience, I'm almost getting to the point where I'm not happy telling people what I do for a living. This is because in any non-trivial collection of people, there's almost certainly going to be at least one person who has had such a poor experience with the IT industry that they're either going to take it out on me, ask me interminable questions about computers, or will just hate me on principle. It's unfortunate that brothels don't have pianos any more; if I were to say "I play piano in a whorehouse" I'm pretty sure the response would be "lawyer or sysadmin?". As Edsger Dijkstra said back in 2001, "The average customer of the computing industry has been served so poorly that he expects his system to crash all the time, and we witness a massive worldwide distribution of bug-ridden software for which we should be deeply ashamed." Are you?
1. That isn't to say that the patient (or client) has no responsibility in ensuring a positive outcome -- if you go bungee jumping the day after open heart surgery, or never send your web developer any content, you're very unlikely to have a positive outcome. However, it seems to me as though the only customer consultation done by most IT "professionals" on taking on a project is a Homeresque "I only have two questions. 'How much?' and 'give it to me'".

16 December 2007

Matthew Palmer: Camping: CGIs on steroids

There's no way around it: I'm a bit of a Rails fanboy. While it's got it's glitches, it's certainly made the part of my life that involves writing web applications a hell of a lot easier, and introduced me to the wonder that is the Ruby programming language. However, there are plenty of times when Rails just isn't a good fit. It's not particularly simple to deploy, it's quite heavy, and it does have a definite learning curve. So, when I need to write something simple, I've just used Ruby's built-in CGI support. But I will do so no longer. For I have found Camping. The name doesn't make a whole lot of sense, and until you come to grips with Why The Lucky Stiff's weird sense of humour, the docs will probably make you think that acid trip you took several years ago has just kicked in again. However, the purpose of Camping is pretty easy to understand: it allows you to make simple (CGI level) web "applications" using Rails-like (or more properly, MVC) concepts, which are fairly easy to write and deploy. If you're familiar with Rails (or probably most of the other Rails-clones that have sprung up in other languages) then Camping will probably smell at least faintly familiar. You have routes, which map URLs to controller actions, which retrieve models and feed them to a view which sends results back as HTML. From that perspective, Camping is easy to learn -- it's core concepts can piggyback on existing knowledge, and you can get started very quickly. Using your Rails-fu, however, will only get you so far. For one thing, the API is similar-but-different enough that while your first couple of simple experiments will probably Just Work, getting more complex things done will either fall under the "different" or "difficult" headings. That isn't meant to be a slight on Camping, though -- if you want to do horribly complex things, then you're heading into territory best served by Rails anyway. But there is a bit of a middle ground where the utter simplicity of Camping is stretched a little, but it's still more appropriate to write a Camping app than a Rails app, and it's important to remember that you're not using full-blown framework when you thump up against something that's beyond-trivial in Rails, but is not quite so simple in Camping. Camping is a microframework -- it says so right there on the front page. Why's intention is that Camping will always be provided in less than 4kB of code. So you're never going to get, for instance, the broad range of HTML helpers that Rails' ActionView provides to make writing HTML templates so easy, or the Prototype JavaScript framework shipped with the main code. If you don't want to blow a steam pipe, then, when starting out with Camping, you need to think "this is a lot easier than hand-writing CGIs" instead of "this is a lot harder than writing a Rails app". There are a few things that are undeniably a pest in Camping, though. The docs are a little incomplete and hard to follow (even when you account for Why's "unique" style of writing), and some of the coding tricks that are employed in making the framework can make debugging a bit tricky. They're not showstoppers, but it's worth knowing about them in advance so you don't go nuts when you're first using the framework. If you're not the sort of person who needs small, self-contained web scripts, then I'd say you'll probably never get much benefit out of Camping. On the other hand, if you're still writing your CGIs against the "bare(ish) metal", then I would strongly encourage you to take a look at Camping, to make your life just that little bit more delightful.

Next.

Previous.