Skip to main content.

Book Information

  • Title: Extending and Embedding Perl
  • ISBN: 1930110820
  • Author/Editor: Tim Jenness, Simon Cozens
  • Publisher: Manning
  • Publishing date: 2002
  • Pages: 384
     Cover of the Book

Book Reviews

Review by Shlomo Yona, November 2002

I got a copy of this book in one of the Israel Perl Mongers meetings, to read and review it.
The topic is useful as this subject was considered as voodoo done by Perl hackers and "mappers of the Perl internals". I suppose you can say this claim is not true anymore, because this book collects the know-how from the perldocs, the newsgroups, the camel book (and other resources) and the personal experience of authors of the book.
Finally, you don't have to pick up small pieces of information about this subject in many places as people did prior to this book. What one would do, if one wanted to learn how to extend Perl or embed Perl before this book was available was doing one or more of the following:

I think reading one book, with common terminology and many examples, is better than doing one or more of the above.
The book starts with an introduction of C for Perl programmers. It is very short and in my opinion not so accurate (due to its shortness), but since this should be a short introduction - it lives up to the promise. You can write a lot more than a "hello world" program after reading this short chapter, and you get a bonus, how to compile on gcc (gcc is ANSI-C and is available for all platforms), which is a wise idea. Perl programmers might be a bit disappointed to discover how much code and how complicated code you need to write in C to produce something that does the same as any Perl oneliner. The third chapter about Advanced C is a very good continuation to this introduction, especially, becuase the authors can assume you know some Perl (although I'm not sure they do). As someone giving lectures in "introduction to Computer Science, C language", I was tempted to borrow several very nice examples and explenations from this chapter. And I might also do that :-)
The next chapter explains how C code can be incorporated into a Perl Module and more generally into a CPAN package of a Perl module. This is very useful. Many resources (including books), focus on writing C/Perl code, and they say nothing or next to nothing about packaging (what you should do in order to make sure others can use your code, what you can and can't assume about the target system, etc.)
The fourth chapter is a useful cover of Perl variable types. This is somehting you could find in the "camel book", you can also find this in the (rather old) "Advanced Perl Programming", and of course in perldocs - but having it in one place, in order with examples and explenations is a real joy. Now you can figure it our reading one thing, and if you feel you want more, go to the perldocs.
Explaining Perl API, XS and advanced XS, alternatives to XS explain how you can add to your Perl programs some code (or programs or libraries) in C. I, personally wanted to have a module in Perl that gives interface to a data structure. Since the implementation I had is in C and it is tested and verified, I wanted to have a Perl module which exports the functionality, and offers a perl-oriented interface, without needing to reimplement the data structure in Perl. These book chapters made all the difference, and with the knowlede in chapter 2, I can now finish this, and after doing my testing, put it on CPAN. Isn't that great?!
If you are interested in doing the opposite, write Perl in C code, you can learn it in chapter 8. And if theory does not meet practice, you can read chapter 9 (and also try it out yourself) which presents a case study. Pretty useful stuff.
For people who are taking their first steps, the material so far is more than enough. But once you go deeper you want to know more about how to do more complicated stuff, and how stuff actually works. Chapter 10 which introduces you to the Perl internals is just what you would be looking for. Chapter 11 will be the tour into the depts, teaching you some perl hacking, i.e. how to alter Perl's behaviour.
The indices are useful, though can be found (though, not in similar format) elsewhere.
To sum this review, I loved the book. I wish I could take more time to practice what I read there thoroughly. I will surely get a copy of this book to have it on my bookshelf, and when the need comes, on my desk.
Another review with some discussion can be found on Slashdot.

Review by Shlomi Fish, January 2004

This book is written relatively professionally, with many examples, an encompassing content. It is probably the definitive guide for people wishing to write extensions to the Perl language or to embed it in other applications.
However, I found that reading it from front cover to back coverm, it was most of the time very boring. Plus, sometimes code examples introduced various steps that need to be done relatively out of the blue, without a good motivation why. The style of the book in which examples have arrows that lead to remarks, and then bullets that are followed by end-notes, was also peculiar to me, but I suppose I got used to it.
I suppose that if you wish to write a Perl extension seriously, then buying this book would be a very good idea. Otherwise, you should probably not read it for fun.