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.
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.
Anyway, here you go.
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
Like I said, I'm new here so I'm not really familiar with your protocols, but votes sounds good :-)
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
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!
Do yourself a favor: don't.
Most of them consist of newish users arguing, often quite strenuously, that their (sometimes rather harebrained) ideas for how to improve the XP system should be implemented, and the people who have been around for a while explaining why it either isn't practical or wouldn't be that much of an improvement. (Occasionally a good idea is suggested, in which case sometimes it is implemented (usually by tye), and sometimes not.)
Most of the rest of the XP threads consist of people (presumably people whose nodes got downvoted) complaining that everyone should not downvote them, but reply or /msg them instead. If I never see that particular complaint again, I shall consider the PM reputation system to be a success.
There's also the occasional interesting analysis of the psychology of the voting system itself, which usually gets mistaken for a complaint about downvotes and, as a result, gets downvoted mercilessly. Those are pretty rare, though.
|
- apotheon
CopyWrite Chad Perrin |
--hsm
"Never try to teach a pig to sing...it wastes your time and it annoys the pig."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.
|
- apotheon
CopyWrite Chad Perrin |
--hsm
"Never try to teach a pig to sing...it wastes your time and it annoys the pig."I somehow thought my enthusiasms for esoterics like language implementation were shared by very few people :-)
Give me a few days to collect my thoughts and I'll get back to you on that.
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
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...
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).
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:
Then displaying a sub is just:
Also when I want to refer to a line I say:
ReadEvalPrint() onis the central control routine of the whole interpreter. It takes an input file handle and an output file handle as arguments. Starting on it defaults the output file handle to STDOUT , ...
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.
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?
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.
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.
Point taken, but a Perl implementation has an advantage over C for understanding an implementation because it's much higher level, and over Scheme because there's no incestuous metacircular evaluation to confuse things.
Secondly, yes, you hit the nail on the head about syntax because the Parsing section would use the existing evaluator as a target with new, alternative and interesting syntax, certainly better than those "Pratt parsers" that I've seen. Syntax aesthetics is often ignored in hard CS texts.
Finally the third section on compilation would generate Parrot, making the use of Perl in the other sections doubly relevant, but I said that already.
Finally the third section on compilation would generate Parrot...
There are a couple of attempts in progress to port Scheme (or something Scheme-like) to Parrot. Pheme, for example, is far enough along to have exposed a few bugs in Parrot.
perlmonks.org content © perlmonks.org and apotheon, astroboy, billh, chromatic, educated_foo, hsmyers, jonadab, Marza, roboticus, spiritway, wazoox, wolv
prlmnks.org © 2006 edmund von der burg (eccles & toad)
v 0.03