Sell Back Your Copy
For a $1.76 Gift Card
Trade in
Have one to sell? Sell yours here
Extending and Embedding Perl
 
See larger image
 
Tell the Publisher!
I'd like to read this book on Kindle

Don't have a Kindle? Get your Kindle here, or download a FREE Kindle Reading App.

Extending and Embedding Perl [Paperback]

Tim Jenness (Author), Simon Cozens (Author)
4.7 out of 5 stars  See all reviews (9 customer reviews)


Available from these sellers.



Book Description

August 2002
An explanation of how to expand the functionality and usefulness of the Perl programming language, this guide delves into the complex issues of using real code examples from the Perl source. Detailed is how to use Perl from C programs, such as writing interfaces to C libraries, implementing Perl callbacks for C libraries, and passing Perl hashes and arrays between Perl and C. Additionally, developers are provided with an API reference for the internal C interface to Perl and a reference on the typemap system.

Customers Who Bought This Item Also Bought


Editorial Reviews

Review

"A masterpiece that will keep its value for years." -- The Perl Journal

"Everything related to Perl internals is found here . . . organized well, and is fine as a reference work." -- The Perl Review

"Great for learning and great for reference, which is a combination other books often fail to achieve." -- Perlmonks

"Indispensable in gaining a good foothold on using Perl in, from, and around C." -- Slashdot.org

About the Author

Simon Cozens is an Open Source programmer and author. He has released over a hundred Perl modules including Email::Simple, Mail::Audit, Maypole, Plucene, and B::Generate. He's the co-author of Beginning Perl (Wrox) and Extending and Embedding Perl (Manning) and was the managing editor of Perl.com from 2001 to 2004. A graduate in Japanese from Oxford University, he now lives in Wales and enjoys Japanese and Greek food, bizarre music and fine typography.


Product Details

  • Paperback: 384 pages
  • Publisher: Manning Publications (August 2002)
  • Language: English
  • ISBN-10: 1930110820
  • ISBN-13: 978-1930110823
  • Product Dimensions: 9.1 x 7.4 x 0.7 inches
  • Shipping Weight: 1.4 pounds
  • Average Customer Review: 4.7 out of 5 stars  See all reviews (9 customer reviews)
  • Amazon Best Sellers Rank: #964,686 in Books (See Top 100 in Books)

More About the Authors

Discover books, learn about writers, read author blogs, and more.

Customer Reviews

Most Helpful Customer Reviews
15 of 15 people found the following review helpful
Finally - all in one place November 20, 2002
Format:Paperback
I got a copy of this book in one of the Israel Perl Mongers meetings (www.perl.org.il), 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:

* Read relevant small parts of the Camel book (preferably the recent edition rather than the 1st or 2nd) and "Advanced Perl Programming" (which is rather old, and only touches this matters).
This would give you some idea about Perl internals and perhaps some clues about XS, but that's about it.
* browse through newsgroups, mail archives and mailing lists to look for clues, and ask expert users, which usually, are not polite to answer newbies questions about such matters.
* figure out some cryptic (though, personally, I like them) incomplete (examples-wise) perldocs such as:
perlembed, perldebguts, perlxstut, perlxs,
perlclib, perlguts, perlcall, perlapi,
perlintern, perliol, perlapio, perlhack
* locate and dig into available CPAN module using this technology.

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.

Comment | 
Was this review helpful to you?
14 of 15 people found the following review helpful
Format:Paperback
The Short Review: This is a marvellous book, and if you want to learn about how to embed or extend C with Perl, then this is the book. Go buy. The Long Review: I used to be a commercial C programmer more years ago than I care to remember, but I never ever really "got" all those asterisks, and ampersands and all that other funny stuff. I was still really a LISP programmer at heart, and in 1991 when I first started learning C, I wondered why anyone would want to learn all those hieroglyphics when wonderful languages like LISP were around. Of course, the answers are speed, efficiency and power. But when I discovered Perl a few years later, which had all of this in buckets, it was with a very great relief that I threw off the millstone of C. But as I've got more into Perl, eventually even coming to teach and occasionally write about it, there have been many times when I've needed to drill down back into the demon of C. This has mainly been to increase the efficiency and speed of database code I've written for various companies. Alas, all those perlguts and perlembed manual documents were more cryptic and painful, to my mind, than the economic theories of the Keynesians; I got there in the end, but usually in a battered, bruised and bloodied state. But then I had the good fortune to go to a Damian Conway talk on Perl6, where I had the great privilege of meeting Hugo van der Sanden, who revealed the future appearance of Inline C in Perl 5.10. The beast would be outed, and I decided to try to master it. But how to figure it all out? Fortunately, a kind clever person at the bar afterwards pointed me towards this book, and all has since become clear. Well, clearer! :-) The dreaded malloc word appears on p.64, and the ... phrase "linked lists" appears on p.83, but somehow I survived. This book is well written, concise, and an absolute must for all those, such as myself, who need to work with C and Perl, but who've been putting off the ... day. With this superb book, we cowards no longer have any excuses. Magic! :-)
Comment | 
Was this review helpful to you?
9 of 11 people found the following review helpful
There and Back Again March 23, 2003
Format:Paperback
Extending and Embedding Perl is as it boldly states on the cover: "The definitive guide to XS, embedding, and the Perl internals". This book is well organized and information dense. One could spend days sifting through the available perlapi, perlcall, perlembed, perlguts perlxs, perlxstut, and h2xs documentation. After which you'll probably understand very well references to nethack's "You are in a maze of twisty little passages all alike". Or you could get yourself a copy of this book and find your way out of the maze.

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 interface 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 rephase 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, 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.

Comment | 
Was this review helpful to you?
Most Recent Customer Reviews
Search Customer Reviews
Only search this product's reviews

Tags Customers Associate with This Product

 (What's this?)
Click on a tag to find related items, discussions, and people.
 
(5)

Your tags: Add your first tag
 

Sell a Digital Version of This Book in the Kindle Store

If you are a publisher or author and hold the digital rights to a book, you can sell a digital version of it in our Kindle Store. Learn more

Customer Discussions

This product's forum
Discussion Replies Latest Post
No discussions yet

Ask questions, Share opinions, Gain insight
Start a new discussion
Topic:
First post:
Prompts for sign-in
 


Active discussions in related forums
Search Customer Discussions
Search all Amazon discussions
   
Related forums


Listmania!


So You'd Like to...


Create a guide


Look for Similar Items by Category


Look for Similar Items by Subject