Date: 8 Mar 2004 06:04:54 -0000 Message-ID: <20040308060454.29935.qmail@plover.com> To: mjd-book@plover.com Subject: Mark Dominus book news: Manuscript is complete Organization: Plover Systems From: Mark Jason Dominus If you forgot what this list is about, or you don't know why you're getting this message, please see http://perl.plover.com/book/ To unsubscribe, send a blank message to mjd-book-unsubscribe@plover.com. ---------------------------------------------------------------- I finished the draft of Chapter XII today. It's quite likely that means that I'm finished with the draft manuscript. I may yet write something for Chapters X and XI, which presently don't exist, but I don't think they were ever very important, and I was planning to merge them into a single chapter anyway. If the book went to press with the nine chapters it has now, I would be very happy with it. The total manuscript is approximately 450 pages long, which I find astonishing. My original proposal guessed that the book would be about 400 pages long, but I don't think I ever really believed it would be. The chapter is about declarative programming, which is programming by entering specifications of the results you want instead of step-by-step descriptions of how to get it. Regexes are an excellent example of this. You put in a pattern that describes what you want the output to look like, and you let Perl figure out the best way to locate strings that match that output. The cause of the long delay on this chapter was that I wanted to end the book with a large, realistic example, and the program I decided to write was perhaps too ambitious. The example program is a constraint-driven drawing system called 'linogram'. It too a long time to write because it went through the complete life cycle of a software project. By that, I mean that when I started, I didn't know what I wanted it to do. Then after I figured out what I wanted it to do, I still didn't know how to do it. After I figured out how to do what I wanted, I had to implement it. Then there were several cycles during the implementation in which I realized that I didn't understand as well as I thought I did what I wanted to do or how I would do it, so I went back to step 1 several times. Once the software was working, writing the text went very quickly. 'linogram' is finally done, and I am pretty happy with it. It is about 900 lines of code, not counting whitespace, comments, curly braces, etc., and not counting the parsing system. It is reasonably fast, and I may even start using it in preference to 'pic' for diagrams, which I have been using (and swearing at) for years. It probably needs a few more features first. It has no splines, and I miss the splines. But you can define boxes and lines and things, and put them together, and it will figure out where everything needs to go, and then draw the diagram you asked for. Some examples of the input language: define square extends box { constraints { ht = wd } } define circle { number r, d; point c, nw, n, ne, e, se, s, sw, w; constraints { d = 2*r; n = c - (0, r); s = c + (0, r); e = c + (r, 0); w = c - (r, 0); se = c + ( r, r)/1.4142; sw = c + (-r, r)/1.4142; ne = c + ( r,-r)/1.4142; nw = c + (-r,-r)/1.4142; } draw { &draw_circle; } } define diamond extends box { line nw_side(start=n, end=w), sw_side(start=s, end=w), ne_side(start=n, end=e), se_side(start=s, end=e); draw { nw_side; sw_side; ne_side; se_side; } } To draw a diagram, you just name a bunch of these figures and describe how they are connected, and 'linogram' will draw them. For example: box F; diamond G; hline h; constraints { F.e = h.start; h.end = G.w; h.length = 1; F.wd = 2; G.wd = 1; } One delightful thing about this project is that I got to use almost every important programming technique that appeared in the previous chapters of the book. It depends heavily on the parser systems of Chapter IX to translate the input into object definitions. Dispatch tables and interesting recursions are everywhere. The chapter is finished not quite in the nick of time. The previous chapters have already gone off to the reviewers for the final review. This chapter will go off to them immediately, and when I get the reviews back I will start the final revisions. The book should be published by August. It's really unfortunate that this is too late for the big summer Perl conference, but I guess that's the way it goes. Please buy the book anyway and help repay Morgan Kaufmann for their long-suffering patience. The draft of Chapter XII is available on my web site at [ Sorry, advance chapters are available only to mailing list subscribers. Send mail to mjd-book-subscribe@plover.com to subscribe. ] I would be delighted to receive comments and suggestions. You mailing list readers have been tremendously helpful in the past, and I'm sure you will continue to be so. As always, it is very important that you not distribute these files to anyone else. There are several reasons for this. Most important is that the chapter is still a draft, and I would be very unhappy and embarrassed if my crappy old drafts were circulating on the Internet after the finished manuscript was published. Once something like that gets out, it's really hard to expunge it again. And it will bug me for years, I will constantly be writing letters to teenagers in Russia who are hosting copies of it, and trying to get them to take it down again. So please don't make me miserable by spreading it around. Also, because I want the draft chapters to be gifts for you mailing list people, please do not send the URLs to anyone else. Instead, please advertise the mailing list. People who subscribe between now and the publication date will receive the Chapter XII draft URL in email when they subscribe. To subscribe, send email to mjd-book-subscribe@plover.com or visit the subscription form at http://perl.plover.com/book/#mlist As usual, previous chapters are no longer available. But I'd like to remind everyone that when the book is published, which my editor tells me will be in August, the complete text will be available on my web site at http://perl.plover.com/book/. So if you missed the earlier samples, you don't have long to wait. Thanks for subscribing. The end is near!