Just before Christmas I was working late on one of the few excuses I have for using Perl in a project-related capacity, when I noticed something about the way I write Perl, and how it differs from how I write other languages.
I was hacking away at what was once a a simplistic, quick-and-dirty text munger but which has, over the months, got completely out of hand and turned into an gargantuan online documentation and batch file generator with a distinct hint of the diabolic in the depths of its code. It is, in short, a crawling horror.
This fact doesn't bother me much; in about a fortnight it will become unnecessary and be retired to a dark corner of the development server, where it can devise its foul machinations in peace.
The bolt from the blue, however, was realising just how different its evolution had been from practically every other program I've written. I've had a fairly conventional training in classical software design and usually when I start a project it seems perfectly natural to go through an analysis, design, prototype, analysis, re-design, code, test, maintain cycle. So natural, in fact, that I don't even have to think about it. With Perl, though, it's always been different.
Looking at the contents of my hard drive, there are three different methods represented. Firstly, the quick-and-dirty one-liners and almost-one-liners that I write half-a-dozen of every day, use once and then append to 1linegraveyard.txt in case I ever need them again. The second kind are the quick-and-dirty one-liners that grew while I wasn't looking, like the above example.
The final variety, the kind that interest me most of all, came about as a result of knowing that I was going to want to use the thing more than once. But instead of analysing the problem, as I would do prior to cutting even a single line of code in another language, I've always got straight down to the prototyping stage, improving my understanding of the problem seemingly with nothing more than an intuitive feeling for what the answer might look like, then refining it into its final form.
Once I actually realised what I was doing, I paid attention to it. I sometimes get through three or four generations of prototypes in a day. The nice thing is, this way is a lot more enjoyable (what would you rather do? twiddle with diagrams or write code?) and doesn't seem to result in worse code, and thanks to pod it's a lot better documented than most of the stuff I do.
The question is (yes, I have got a point to make here), why does this way of working seem natural in Perl, yet unnatural in any other language? I tried it with a small Visual Basic app I had to write and came unstuck in no time at all.
Has anyone else had a similar experience? Is it just that Perl is a good fit with hackerly intuition? Do most people here stick by the traditional methods, or is a more flexible (ad-hoc?), go-with-what-works approach more popular?
--
Tom Waddington
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(jeffa) Re: How formal are Iyour/I methods?
by jeffa (Bishop) on Feb 07, 2001 at 02:34 UTC | |
|
Re: How formal are Iyour/I methods?
by McD (Chaplain) on Feb 07, 2001 at 03:09 UTC | |
|
(jcwren) Re: How formal are Iyour/I methods?
by jcwren (Prior) on Feb 07, 2001 at 02:53 UTC | |
|
Lack of dress code in Perl
by gryng (Hermit) on Feb 07, 2001 at 03:41 UTC | |
|
Re: How formal are Iyour/I methods?
by mikfire (Deacon) on Feb 07, 2001 at 02:54 UTC | |
by jcwren (Prior) on Feb 07, 2001 at 04:49 UTC | |
by chorg (Monk) on Feb 07, 2001 at 04:42 UTC | |
|
Re: How formal are Iyour/I methods?
by clemburg (Curate) on Feb 07, 2001 at 13:55 UTC | |
|
Re: How formal are Iyour/I methods?
by mothra (Hermit) on Feb 07, 2001 at 04:43 UTC | |
|
Re: How formal are Iyour/I methods?
by ColonelPanic (Friar) on Feb 07, 2001 at 04:56 UTC | |
|
Re: How formal are Iyour/I methods?
by readey (Sexton) on Feb 08, 2001 at 19:51 UTC |