My dark confession: I'm writing a book. On Perl.

scrottie on 2004-03-28T11:57:57

I've got a book contract and I owe everyone an apology. And an explanation. My friends know me to be quite peevish. When someone tells me they're starting a MUD, I snap, "Why? The net is littered with neglected, half dead MUDs". When someone tells me they're buying a car, I remind them of a statistic published in 1970 that there are enough cars in the junk yard to reach to the moon and back. When someone tells me they're having a baby, I retort with the obvious, "Why? There are too many people in the world". A few grinning miscreants have told me that they're writting a book. With a deep sigh, I exasperate, "Oh, good, another bad book about [insert subject that has too many bad books in it already such as Perl]".

My first official act as a signed author was to read tchrist's old reviews from back when the world was transitioning from Perl 4 to Perl 5 and authors weren't. I redeveloped the stomach ulcer I had when I was 9 as my second official act. Quite painful, thank you.

You see, this book is about Perl 6, kind of. It is about doing Perl 6-like stuff with Perl 5. That makes it fit alarmingly well with the profile of the Perl-4-going-on-5 era books that couldn't do anything but try to translate Perl 4 syntax to Perl 5 while completely missing the point and butchering the spirit. Except I'm doing this slightly backwards. Still, I want to convey the spirit of Perl 6 and give a bright outlook for the future for people to be happy about. I do not want to perpertuate stagnation. Nor do I want to downplay the changes as merely with the old "not that different, *this* syntax still works, see?" gag.

So, this diary entry is really about how I'm trying to avoid pitfalls, being new to a profession. Tom's reviews service just as much as advice to aspiring authors as they do to would-be book purchasers. The shoehorning Perl 4 onto Perl 5 was one pattern these authors exhibited. Operating in a closed loop, sans feedback, was another.

After I had a few chapters under my belt I started mailing people. The book mostly showcases modules (many of them non-obvious but very Perl 6-ish anyway, I hope). I wanted people to atleast know I was writing about them, and have the chance to comment on what I've said, or even add a quick comment. I'm not really trying to offload work from myself, just breathe some life into it. This was my third official act. I've also mailed O'Reilly, who I am not writing for as it happens, and they were nice enough to send me some review materials. They're also now aware of the exact subject matter of mine.

I'm trying to run it as openly as possible given its commercial nature. It is POD in CVS and numerous people have access to it, though few people are active. A few people, who I will take time later to give proper praise, are making a world of difference.

I'm writing it in POD, as I mentioned, and using vi. I'm sure there will be annoying errors in the book, but too many times I've read technical books and fonts covered most of a word, cutting off 2 or 3 letters before the end, and scratched my head and imagined some tired author trying to operate a mouse in the wee hours of the morning with their eyes red and watering and their wrists numb and not quite making it to the end of the word. Word processors offer the ability to do certain things with the mouse, but anything done frequently with the mouse should have a keyboard shortcut and you should use that shortcut, and I can't for the life of me find the "run this code in perl" short cut in any Word Processor I've tried. With constant example tweaking, such a feature is critical and alone is worth using vi or Emacs. Tom criticized books production but only as a minor nit.

Technical accuracy on the other hand was Tom's largest and most frequent gripe, other than perhaps plagerism. Technical accuracy is hard. Not plagerising is a crime. I'm amoured of the open book movement and publishes such as GNU Press and Green Tea Press. I'd love to have started with a Perl 5 book and heavily reworked it. Rewriting something, be it software or a manual, is not only a huge amount of work but is also work that isn't easy to justify. Not that this text is a virtual clone of another book - far from it. Still, a certain amount of background and explanation must be included even to weigh in as a fast paced, no-nonsense guide for experienced programmers. Six times now I have emailed requests for permission to quote a small example from POD documentation or such and six times I've not heard back. I'm tempted to advocate a copyright regime where if you ask for permission according to the published channel and don't hear back, it is granted by default rather than denied. But I guess that's what Eldred's proposal is, except non-silly =)

There there is me. Me is always my biggest struggle. I've come out of no-where, essentially. For many of you, my bozo bit is set. The Phoenix Perl Mongers know me - I'm one of 2.5 "default presenters" that will present when no one else is so that we can hold a meeting. I don't know about your experiences, but we get a lot better turn outs when some topic is being presented. I do some work for the NetBSD project now and then when I have time, and maintain their projects server. I have several modules on CPAN but nothing popular, or else they've been Warnocked. I've made numerous forayes into writing open source software but nothing ever cought on. SourceForge and FreshMeat have done wonders for exposing and indexing open source projects, but I've never quite gotten around to putting my old stuff up there. TinyWiki, a quick hack, inexplicably became the most popular thing I've written. I learned Perl after Motorola hired me after I told them I knew Perl. I lasted a month. Not because of my lack of Perl, mind you. Then the little I knew managed to get me contracting job after contracting job. I've been living that life since. As a consultant, you don't get your head above water very often. To this day, most of my programmer experience comes from the 14 years I've spent on MUD. I'd be lieing if I said it wasn't a large part of my identity and my primary education. Before that, it was writing games in BASIC and 6502 assembler on my Atari 8 bit. That was essentially my childhood. Games are still in my blood. But that's another project >=)

I won't say working on this book has has been easy either. Perl 6 is a moving target. I'm having flash backs to Japanese class in college - the language just won't stick in my head and I keep making the same mistakes over and over. I can't seem to let go of a chapter but want to revise it indefinately. The modules I'm documenting are all a little bit out of date, or have a bug that stops my show, or would be a lot easier for me to document if they just worked a little bit differently, so I'm spending a lot of time trying to fix bugs and sending in patches. I can't hack XS and I'm now wishing I'd learned before. As I write this, I'm over the hump, though, and I'm starting to see the light at the end of the tunnel, to mix metaphores.



So, I write this not to gloat, not to justify, but merely to confess. And to share.



-scott


Word Processor

cbrandtbuffalo on 2004-03-29T17:41:36

I've had the same problems settling on a word processor that I can be fully comfortable with for writing. I still don't have an answer, but one possibility on the Mac is Nisus Writer. It's a stripped down word processor that also has full perl scripting capabilities. Seems it might be possible to script something to run through a document, pull out the perl code, and run it. But it's only on Mac.



Details: http://www.nisus-soft.com/

Test::Inline to the rescue!

schwern on 2004-03-30T03:55:10

I'm writing it in POD... and I can't for the life of me find the "run this code in perl" short cut in any Word Processor I've tried.

Since you're writing it in POD, use Test::Inline.

Syntax check your code.

           =for example begin

           use LWP::Simple;
           getprint "http://www.goats.com";

           =for example end

And even write tests for your examples.

           =for example begin

             my $result = 2 + 2;

           =for example end

           =for example_testing
             is( $result, 4,         'addition works' );