Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

RFC: Almost a Book

by billh (Pilgrim)
on Apr 15, 2006 at 17:46 UTC ( [id://543564]=perlmeditation: print w/replies, xml ) Need Help??

Hi,

I'm new here, but some of the London PerlMongers know me.

To cut to the point, I started writing a book about implementing other languages in Perl. Then the publisher went quiet. So I continued anyway. Then I got despondant, and what I have so far is here.

It's really Section 1 of 3, "Interpreters", the other two sections would be "Parsing" and "Compilation". It's unfinished, insofar as the OO extension code is done but I'm not happy with it yet, and the continuation passing interpreter is conceptual only (trampoline implementation probably).

I'm not sure if I'll finish it, but it seems such a waste to throw it all away so feel free to read, comment etc.

Replies are listed 'Best First'.
Re: RFC: Almost a Book
by roboticus (Chancellor) on Apr 15, 2006 at 19:42 UTC
    BillH:

    Update: I ran out of votes already. I'll remember to come back tomorrow morning and give you the first one, then!</Update>

    Cool--I just read the first four sections, and I must say that I like it so far. You get my last ++ of the day! I think your pedagogy is spot on.

    Now I'll have to slot out some time tomorrow to finish it off

    --roboticus

      Thanks!

      Like I said, I'm new here so I'm not really familiar with your protocols, but votes sounds good :-)

        BillH:

        Update: I've just been informed that linking by [id:######] is better than by title, so I made the appropriate adjustment...</Update>

        I'm relatively new here, myself, having just joined about 6 weeks ago. And I have learned that votes are good. In fact, a few of us were just chatting about PerlMonk's experience point system in the thread A Cautionary tale for Newbies “Monks don’t bite”. (I haven't done a Super Search on it, but I suspect that there are just short of a few billion threads about the XP system. One day, when I get bored, I may look 'em up!)

        I don't know how long I've been on Slashdot, but I've only done 5 posts in the last 5 years. Here, the voting/XP system makes interaction a lot more fun, and eminently worthwhile. With contributions like the PScheme stuff, you'll do quite well!

        --roboticus

Re: RFC: Almost a Book
by Marza (Vicar) on Apr 15, 2006 at 19:30 UTC

    Scheme? Now that's a name I haven't heard in awhile. Got a PDF? I am not a great fan of major reading on screen.

      sorry, you caught me on the hop a little there. I'm writing it in xml, with transforms to html and LaTeX, but the LaTeX transform had fallen a bit behind so I had to patch it up to make a current pdf.

      Anyway, here you go.

Re: RFC: Almost a Book
by wazoox (Prior) on Apr 15, 2006 at 21:07 UTC
    It's very interesting indeed. I hope you'll be able to finish and publish it anyway !
Re: RFC: Almost a Book
by hsmyers (Canon) on Apr 16, 2006 at 18:06 UTC
    Like others, I don't post very often so perhaps that fact will add weight to what I say (or not!) To paraphrase; Finish it and they will come... publishers that is. And for that matter make sure that you keep us all updated as I don't particularly like to wait...

    --hsm

    "Never try to teach a pig to sing...it wastes your time and it annoys the pig."
      My personal Field of Dreams would cost me a lot of time and effort, of course that's the whole point isn't it, I guess I realised that I had committed to something when I first posted.

      I will endeavour to finish it, in fact the luxury of writing without a publisher has a lot of benefits, However I'm much happier with the code (which only took me a weekend to write) than with the prose (which I've laboured over for months) and i'm desparate for some constructive criticism to help me improve it. That's the main reason for my aforementioned despondancy: I felt like I was writing in a vacuum - do all writers feel like that?

        "do all writers feel like that?"
        Yes, I think we do.

        Lately, I've been doing a lot of short article writing for publication, and I have a personal editor past whom I run everything before submitting it for publication, so I'm not suffering under that particular burden at the moment, but I have four novels in various states of completion that are languishing on back burners in part because of that "writing in a vacuum" feeling.

        print substr("Just another Perl hacker", 0, -2);
        - apotheon
        CopyWrite Chad Perrin

        If pressed, I will admit to having been an editor. Further if it means earlly access I'd be happy to volunteer my services such as they are.

        --hsm

        "Never try to teach a pig to sing...it wastes your time and it annoys the pig."
Re: RFC: Almost a Book
by astroboy (Chaplain) on Apr 18, 2006 at 05:32 UTC

    I know some people aren't into self-publishing - you lose the benefit of an editor, etc, but I'm a big fan of it in principle - I've just never had cause to practise it. To my mind, self publishing gives power to the indiviudal in the same way that blogging does.

    If you haven't looked at it already, may I suggest you have a gander at Lulu. It allows you to print on demand (POD) - so everytime someone purchases a book it gets printed and sent to them. I think this is a bit more expensive per item than traditional printing, but you don't have to worry about the cost of an initial print run. There are other POD providers, but I don't whther they are beter or worse than Lulu.

    And as for editorial input, I'm sure that members here at Perlmonks would only be too happy to provide helpful feedback - especially since your book would intrigue a good number of them

      One idea I'm toying with is to turn it into a collaborative effort, or at least make the online book a CGI a la the MySQL documentation, where readers can post inline comments and questions. Then I could incorporate all that iteratively.
Re: RFC: Almost a Book
by spiritway (Vicar) on Apr 19, 2006 at 04:36 UTC

    I say, go for it. It's not a waste, even if you don't fint a publisher. For one thing, the mere act of writing forces you to organize your thinking, which helps you to clarify what you're doing. For another, you've got a very interesting idea going. I'd love to see how it turns out. I'm sure many others agree. I think what would be a waste is to give up after already investing so much effort into this.

    If you get that book published, I'll buy a copy. So that's one sale already...

Re: RFC: Almost a Book
by wolv (Pilgrim) on Apr 19, 2006 at 06:21 UTC
    Looks very nice. Something that caugh my eye: did you create the UML diagrams automatically, and if so, with what tools?

    I have a basic Perl5 structural grapher, implemented with the help of PPI and some not-so-evil introspection, but I haven't been able to find a good automatic layouter for class structures (although Graph::Easy does okay at times).

      No, the diagrams are manually drawn (OmniGraffle on a mac)

      There is a lot of support code for the listings however. I use PPI to transform the perl source into XML, with line number and "changed since last version" (delta="Y/N") attributes, then use XML::LibXML to search the listings with XPath. I pre-cache references to subroutines like this:

      <cache-sub key="rep0" src="PScm-0.0.0/lib/PScm.xml" pkg="PScm" sub="ReadEvalPrint" />

      Then displaying a sub is just:

      <subsample key="rep0"/>
      Also when I want to refer to a line I say:

      <pl>ReadEvalPrint()</pl> on <lineno-of-sub key="rep0"/> is the central control routine of the whole interpreter. It takes an input file handle and an output file handle as arguments. Starting on <lineno-of-var key="rep0" var="*STDOUT"/> it defaults the output file handle to <pl>STDOUT</pl>, ...

      Also the delta attributes allow the text that changed from the previous version to be hilighted.

      The upshot of all of this is that the book is pulling the code listings directly out of a working application under CVS, I don't have to cut'n'paste anything, and changes to the codebase are immediately reflected in the book. I was quite pleased about that.

        Thank you for the information. I wish I had a Mac. :)
Re: RFC: Almost a Book
by educated_foo (Vicar) on Apr 19, 2006 at 15:34 UTC
    This is definitely an interesting project, as writing an interpreter teaches you a lot about how languages work. However, it seems almost like it's going in the wrong direction. Scheme is a pile of planks and nails, and to get any use of it you have to pound them into a language. Perl, on the other hand, is all sorts of nifty wooden doohickeys designed for common tasks. So your book is doing something like showing how to make boards out of furniture.

    It would probably be more useful to write an interpreter or translator that started with all of the built-ins that Perl already has, and added something more. Two examples that come to mind are MJD's Linogram for line drawings, and PDL's PDL::PP, for fast matrix operations. Learning how to extend Perl into other domains and integrate these extensions into the language would both supply interpreter-fu and be extremely useful.

    But anyways, I'm just sittin' in the peanut gallery, so who am I to say?

      I think you're misunderstanding the primary motivation, which is not to produce something which is useful but something which is comprehensible, in as small a piece of code as possible. I'm perfectly happy with your assertion that scheme is not the most practical of languages for doing real work, but the real attraction of Scheme is that it is internally a thing of great beauty, like a piece of clockwork, and something that with a little effort can be grasped in its entirity.

      A second reason for chosing Scheme was that the proposed "Part II" of the book, on parsing, would make a very clear distinction between the various external syntaxes of languages and a far more conservative core of internal forms, and would point out that in the case of scheme there is little or no difference between the external and the internal form (which is why it's so easy to parse).

      Choosing Perl as the Implementation language was a no-brainer for me because I use it all day every day in any case; and the "Part III" on compilation could justifiably target Parrot, which would be an additional selling point.

        Okay, but my take is that there are already a number of well-done "write your own mini-Scheme" books out there (e.g. SICP, Lisp in Small Pieces), and countless homebrew minischeme projects on SourceForge, etc. With a built-in "read" and list-manipulating functions, it's at least as easy to parse and interpret Scheme in Scheme itself as to do it in Perl. Why recapitulate these books in Perl?

        If part 2 supplied an interesting non-scheme-like language with a translation down to part 1's scheme-like one, the book might stand out more. I dunno. I'm not really the target audience for this, so maybe I don't have a good feel for what would be interesting.

        Oh, and another reason for choosing perl, of course, Is precisely because it has all of those wonderful dohickeys that let me get on with the job in hand and don't get in the way of the explaination.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://543564]
Approved by blokhead
Front-paged by blokhead
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-25 19:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found