Extending and Embedding Perl
Most of the available documentation on extending and embedding perl is written from the prospective of the core perl developers for core perl developers. This book is written for advanced Perl programmers who for whatever reason need or wish to peer into that netherworld between Perl, C, and the glue that interfaces Perl with other languages. It is a deliberate thorough guide led by authors that are both extremely knowledgeable and also capable of communicating that knowledge.
While it would greatly reduce the learning curve, no prior knowledge of C is required to read this book. This is a surprising claim and while it won't be easy, this reader is proof that someone with little true knowledge of C can in fact read and for the most part comprehend what the authors wish to convey.
There are clearly areas for improvement. Things like NULL being used throughout chapter 3, only to finally be defined later in a footnote in chapter 4. And other cases of terms being used before they are explained. Things that leave the reader juggling unnecessarily until the information is provided that lets understanding fall into place. But for the most part, if you are a competent juggler and are patient your questions will eventually be answered. You won't walk away a C programmer, but you will learn enough to solve the problems which led you to consider reading this book in the first place.
One thing I liked very much about the layout of the book is how it switches back between presenting sections on C programming and Perl. The authors revisit C each time it is necessary to understand the next Perl internals topic. Those that are learning C or need the review receive the relevant information just before it is required.
Over the course of the book, you'll learn about interfacing from Perl to C and C back to Perl. For those that must plug references to Tolkien in things Perl... you can go back and rephrase that into an appropriate reference to Bilbo's book "There and Back Again". You'll also learn the perl api, data structures for core variable types, and how to work with scalars, arrays, hashes, strings, regular expressions, file handles, typeglobs, typemaps, objects, callbacks and PDL with C and C++. And there is even mention of working with Fortran, Java, and more esoteric alternatives.
The book finishes with an in depth look at Perl internals: the parser, tokenizer, op code trees, execution, and compiler. And closes with a discussion of the Perl development process: How it may be monitored and participated in.
What's missing? Detailed coverage of the I/O subsystem and the regular expression engine. I.e., topics which might themselves make for a good book. There was also light coverage on things like scratchpads. There were times while reading when I didn't know whether the issue being discussed was fully covered or curtailed. But you will certainly find better coverage of the issues in this book than elsewhere. This is an impressive book. I hope it will greatly influence the way Perl6 internals are documented.
You can purchase Extending and Embedding Perl from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
Investing in this book and this knowledge at this point is practically a dead-end, as most of the annoying kludges will end with Perl 5.
Only invest in this book and this knowledge if there is a project you are working on that requires embedding or exteninding perl now. Otherwise wait for the sane cleaned-up world of Perl 6.
It's not from Zork. It's from the Original Adventure (Colossal Cave). If it's in Zork, it's as a homage to the Original Adventure.
- For the complete works of Shakespeare: cat
Or does the book cover easier ways to embed C into Perl, such as SWIG.
SWIG rocks. SWIG is your friend. I'll agree that extending Perl by embedding C is hell and the documentation sucks, but SWIG makes it all (relatively) easy. With SWIG all you have to do is be careful about data types. (Mainly, you can't directly pass a Perl array to C code, you have to convert it into a C array first. How to handle situations like this with SWIG is well documented.)
I spent five days trying to figure out how to embed some C functions into Perl. Then I discovered SWIG and was up and running in 3-4 hours.
retrorocket.o not found, launch anyway?
Anyway, ActiveState produces Komodo, a perl IDE, and they also sell a perl environment for Visual Studio .NET.
I still write perl in vim, but I do use ddd for debugging my code.
XS really isn't as horrible as some people make it out to be.
Posting anonymously from work, someone mod me up, okay?
Greetings,
Well... To get this right would take a while, and is massively off-topic, but IIRC, the original Colossal Caves (Adventure, by Crowther and Woods) was written in Fortran, and had a twisty maze of passages, which was also used in Dungeon/Zork, which was very heavily influenced by Adventure.
The commercial (Infocom) Zork series is a splitting up of the Dungeon/Zork program, which was not originally written in Fortran, it was in fact originally written in MDL by Marc Blank and Dave Lebling, and translated to Fortran by a 'somewhat paranoid DEC engineer who prefers to remain anonymous'.
Zork took the Dungeon world, split it up into three worlds, and then added a bunch more stuff to each part of it, although most additions were to Zork II and III, IIRC. Zork I was mostly identical to the early part of Dungeon.
The Adventure versions are are also known by their point values (330, 551, etc.). There are modified versions of Adventure which add large amounts of other areas, and up the points to as many as 1000 points. I've played Adventure on machines ranging from my PalmPilot to PC's of all shades, to Vaxen and even a Prime mini/mainframe which had the largest and highest point version I'd ever seen. (>1000 points, iirc).
The names Zork and Dungeon have been completely intermingled. I was under the impression it was originally named Dungeon, and then later named Zork, but many of the history pages have it the other way around.
The original Dungeon/Zork had 'GDT', a 'Grand (Game?) Debugging Tool', that let you examine objects, and rooms, in the world. Getting to it required knowing some magic way of translating a key that was printed when you typed in 'GDT'. In my case, it meant teaching myself VAX assembly language, so I could debug and patch the binary, so whatever I typed was accepted...
Some more information is available here (Colossal Caves), and here (Dungeon/Zork), and you can find out more about Interactive Fiction's history as well.
I'm a terribly long-standing fan of IF, even before it had that moniker, having learned a lot about programming by writing text adventure games, parsers, and all the database-like coding needed to make a good text adventure game.
I can still lose myself in the games, just like I can lose myself in a really good book. It's a different world, and a lot of fun as long as you're okay letting your imagination provide all the graphics.
-- CyberFOX!
(a) use pod (q.v. perldoc perlpod )
(b) get a better editor. sane editors (vim, emacs, presumably others) are able to comment regions, or automatically insert comment leaders as you type, or both.
(c) Acme::Comment
-- koschei