To: mjd-books@plover.com Subject: Contract signed for "Perl Program Repair Shop and Red Flags" Organization: Plover Systems Date: Sun, 04 Dec 2005 11:33:18 -0500 From: Mark Jason Dominus This is the mailing list for announcements about Mark Dominus's upcoming book and any other books he might write in the future. To unsubscribe, send a blank message to mjd-books-unsubscribe@plover.com. ---------------------------------------------------------------- WELCOME I am working on a new book, which is tentatively titled "Perl Program Repair Shop and Red Flags". As with the last book, I hope we can think of a better title by publication time. This is the first message to this mailing list, which I started just about a year ago. I really did expect to have something to say sooner than now. A recuring theme on my mailing lists seems to be "this took a lot longer than I expected". Sometimes it's my fault, sometimes not. This time it wasn't. WHAT WILL THE NEW BOOK BE ABOUT? I have read a lot of Perl code in the last ten years or so. The most important thing I have learned is this: Most programs are horribly overwritten. They have 50 to 100% more code than they need. If you can recognize this extra wasted junk and remove it, you are left with a program that does the same thing in the same way but what is easier to debug, easier to read, and easier to maintain. At this point in the explanation, about half the people I talk to say "oh, you just cut out all the comments!" Har har har. I am really tired of that joke. No. Everyone agrees that cutting out the comments is not a benefit. Neither is cutting out the white space. Maybe people make this joke because they don't believe that their programs contain as much as 50% unnecessary garbage. But a lot of programs do contain that much junk. And once you know the tricks, it is not hard to recognize the junk and it's not hard to remove it. I have identified perhaps 30 or 40 "red flags", which are easily-visible signs in the code that there might be an easy opportunity for a significant improvement. That is what the book is about. For example, one red flag is a family of related scalars like $x1, $x2, $x3, and so on. (I want to interject a long explanation here of *why* this is a red flag, but I'd better save it for the book.) If you see this, you should pause and ask what would happen if you were to replace this family with an array @x. Usually the answer is that the resulting code would be somewhat simpler, more straightforward, more concise. Not concise because the whitespace has been removed---which is not concision at all; it's just stupid---but because the new code is doing the same thing in a simpler and more straightforward way. After replacing $x1, $x2, $x3 with @x, you go on to the next thing. After you have corrected fifty of these little problems, and trimmed up the code by a line or two each time---and often there *are* fifty of these things to clean up---you find that the program is a hundred lines shorter than it was before, and a lot easier to understand. My last book, _Higher-Order Perl_, was all about being as clever as I possibly could. The new book is just the opposite. While it might be true that you have to be very clever to write great code, I think that writing _good_ code is within everyone's abilities. Everyone, including clever people, has off days. This book is about how to write good code even when you're hung over. Maybe the code that first comes out of your head on those days is pretty bad. But the point of the book is that you can make bad code better by fixing it up a little, and that it's not hard to learn to do that. I have a lot more to say on the subject (or else I wouldn't be writing a book about it) so I'd better stop here. STATUS REPORT The Red Flags book is about half finished. In fact, it has been half finished for more than a year. That's why this mailing list has been alive for a whole year. I wrote half the book, and then on 5 November 2004 (yes, 2004) I sent mail to Tim Cox, my editor at Morgan Kaufmann to tell him about it. I said: I swore I wasn't going to offer to write another book until I found out how much time I would have to do it...So I decided I wouldn't say anything about another book until I had it at least half written. But I think I have it about half written now. Yes, MK was interested. So I created the mailing list, fully expecting to send out this announcement a few weeks later. Then it MK them almost a year to finally cough up the contract for the book. (The difficult point, apparently, was that I wanted permission to put the new book on my web site.) In the meantime I left the new book to sit around and gather dust while I worked on other stuff. But as of today I have signed the contract for the new book. It's about time! The schedule for the book has me delivering the completed draft manuscript on 15 December 2006, and the final corrected manuscript on 15 February 2007. I hope that I will be able to finish it sooner than that. HOP took a lot longer than I thought it would. Partly this was because I was ill for long periods, but mostly it was because HOP was a very hard book to write. I had to learn a lot of new things and try out a lot of things I had never seen done before, some of which worked and some of which didn't. I had to do a lot of clever stuff, so that on days that I wasn't operating at peak cleverness, I couldn't make much progress. The Red Flags book is much easier. I have been writing articles on this topic for a long time, and I have been teaching classes about this for a long time (see http://perl.plover.com/classes/flags/) so I understand the topic very well and I already have a lot of material stockpiled. The Red Flags book is not about being clever; it's about what to do when you're *not* feeling clever. So I won't have to be so clever when I write it, and that is much easier. In fact it's easier to write this book on the days when I'm not feeling clever, because on the clever days I get all sorts of clever ideas and then I have to do extra work to make sure that the clever ideas stay out of the book. THE BOOK It will probably be two or three hundred pages long. It will be glossy, with many color illustations. It will be fun and easy to read. WHAT'S NEXT? I will need some help. I am almost at the end of the stockpiled material. I need some new material. I also need to find some audiences who are interested in listening to me talk about the new material. I'll ask you folks for help with that early next year. Thanks to all of your for your interest in my books, and please have a happy new year.