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.
Will write "embracing and extending PEARL". Boy! I can't WAIT for that one to come out!
ie ownz u
After which you'll probably understand very well references to nethack's 'You are in a maze of twisty little passages all alike.'
Funny, I remember that exact phrase from Zork.
I'm out of my mind right now, but feel free to leave a message.....
- TROLL-KORE FOREVER /|||||\ IRC.FREENODE.NET /\O | /8S8S8\
- I hate you, I hate your country, and I hate your face!
___
/ | \
|_____| #TROLLKORE
| o
| UUUUU |
\_____/
| | LOOK AT MY SHINY BELL,
| | AND MY HUMPED BACK!
| 8 | - Prince of Knobstradamus
|S S|
|8S8S8S8|
|S8S8S8S|
\__/__/
Doth you not know your own heritage?
The Grand Inquisitor would be most unhappy.
Next Post!! :-D
Did I make it?
Does anyone else confuse CPAN with CSPAN?
I cannot be the only one
...my penis in Nicole Kidman.
misread that title at first glance, was dreading to see what microsoft had done to perl :)
- TROLL-KORE FOREVER
/|||||\ IRC.FREENODE.NET /\O |
/8S8S8\
- I hate you, I hate your country, and I hate your face!
___
/ | \
|_____| #TROLLKORE
| o
| UUUUU |
\_____/
| | LOOK AT MY SHINY BELL,
| | AND MY HUMPED BACK!
| 8 | - Prince of Knobstradamus
|S S|
|8S8S8S8|
|S8S8S8S|
\__/__/
Cmdr. Taco sucks your knob!1!
LARRY WALL CAN BITE A FART.
,jadisfu ;kljweu ;ijiou ;kuu
--[morelame.pl]
a;sdf juiu aks;dlf uiu wer zsd
adf iup k;lasd uip ajsk;duf pjzklsdv uip ajk;sd
asdfa iu
"Trollkore" is lame. Lamelamelamelamelame. So lame it hurts.
w00t w00t! That's what I call a ZIPPY SOMNETHING! BECAUSE YOU FAILED IT AND SO DID I!! If there is one thing I can say about SuSE Linux, it's that they know how to put together a desktop distro. This has been evident for quite some time, and nothing has changed. Their new Office Desktop release is built upon the solid foundation that is SuSE's desktop expertise.
I gave her a Perl Necklace.
I'm so infantile.
Trolling is a art,
Nice try at the submitter trying to be a dork though.
FIRST PERSON
I don't really want to get that close to perl, thank you very much.
I'm sure perl's a nice language and all, and I've even used it on a few occasions. However, the syntax and the shortcuts, while being somewhat useful, and somewhat faster, do NOT tickle my fancy. I prefer to code in languages where I can look at the code after nine months, and still have a vague idea of what's going on.
Perl's great for quick one-off scripts (and slashdot jokes), but suitable for complex projects it ain't.
s/perl/crap/ig
To extend/embed Perl you apparently need a book. For the same task with Python, simply look up the fine documentation on their web page, and you're ready do go in less than an hour.
Let the flames come...
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.
>Things like NULL being used throughout chapter 3, only to finally be defined later in a footnote in chapter 4.
... of course I tend to immediately not listen to anything they say anymore, but some have produced code that does work. I hate to imagine what else they don't know... especially about other important stuff like security and database efficiency.
You said yourself that this book is intended for experienced programmers. If you don't know what a NULL is as well as the implications, and are a programmer, you are in deep doo doo. You definitely cannot be considered to be an advanced programmer. I am suprised this book even defines NULL.
However, I have seen a lot of programmers that have trouble and bugs related to NULL values
l8,
AC
If you think evolutionists have all the answers, try a few of the following questions on 'em!
Creation Science Evangelism -
The test of any theory is whether or not it provides answers to basic questions? Some well-meaning but misguided people think evolution is a reasonable theory to explain mans questions about the universe. Evolution is not a good theory it is just a pagan religion masquerading as science.
1. Where did the space for the universe come from?
2. Where did matter come from?
3. Where did the laws of the universe come from (gravity, inertia, etc.)?
4. How did matter get so perfectly organized?
5. Where did the energy come from to do all the organizing?
6. When, where, why, and how did life come from dead matter?
7. When, where, why, and how did life learn to reproduce itself?
8. With what did the first cell capable of sexual reproduction reproduce?
9. Why would any plant or animal want to reproduce more of its kind since this would only make more mouths to feed and decrease the chances of survival? (Does the individual have a drive to survive, or the species? How do you explain this?)
10. How can mutations (recombining of the genetic code) create any new, improved varieties? (Recombining English letters will never produce Chinese books.)
11. Is it possible that similarities in design between different animals prove a common Creator instead of a common ancestor?
12. Natural selection only works with the genetic information available and tends only to keep a species stable. How would you explain the increasing complexity in the genetic code that must have occurred if evolution were true?
13. When, where, why, and how did
a. Single-celled plants become multi-celled? (Where are the two and three-celled intermediates?)
b. Single-celled animals evolve?
c. Fish change to amphibians?
d. Amphibians change to reptiles?
e. Reptiles change to birds? (The lungs, bones, eyes, reproductive organs, heart, method of locomotion, body covering, etc., are all very different!)
f. How did the intermediate forms live?
14. When, where, why, how, and from what did:
a. Whales evolve?
b. Sea horses evolve?
c. Bats evolve?
d. Eyes evolve?
e. Ears evolve?
f. Hair, skin, feathers, scales, nails, claws, etc., evolve?
15. Which evolved first (how, and how long, did it work without the others)?
a. The digestive system, the food to be digested, the appetite, the ability to find and eat the food, the digestive juices, or the bodys resistance to its own digestive juice (stomach, intestines, etc.)?
b. The drive to reproduce or the ability to reproduce?
c. The lungs, the mucus lining to protect them, the throat, or the perfect mixture of gases to be breathed into the lungs?
d. DNA or RNA to carry the DNA message to cell parts?
e. The termite or the flagella in its intestines that actually digest the cellulose?
f. The plants or the insects that live on and pollinate the plants?
g. The bones, ligaments, tendons, blood supply, or muscles to move the bones?
h. The nervous system, repair system, or hormone system?
i. The immune system or the need for it?
16. There are many thousands of examples of symbiosis that defy an evolutionary explanation. Why must we teach students that evolution is the only explanation for these relationships?
17. How would evolution explain mimicry? Did the plants and animals develop mimicry by chance, by their intelligent choice, or by design?
18. When, where, why, and how did man evolve feelings? Love, mercy, guilt, etc. would never evolve in the theory of evolution.
19. How did photosynthesis evolve?
20.How did thought evolve?
21. How did flowering plants evolve, and from what?
22. What kind of evolutionist are you? Why are you not one of the other eight or ten kinds?
23. What would you have said fifty years ago if I told you I had a living coelacanth in my aquarium?
24. Is there one clear predictio
(Negative moderation will be considered religious persecution.)
Python is the name of the game.
Perl is in deep financial troubles, due to the end of the funding. Even the perl developers should at some point start to realize that other routes exist from point A to point B.
I do hope they can get the parrot thing right, though.
Sweet, sweet, sweeeeeeeeet, cock...
God, I love it! Cock in my ass, cock in my mouth, a cock rubbing against my belly, a cock in each hand!!!! And don't get me started on cum......oh goddddddddd!!!!
Apache rocks!
Gnu's Not Unix, but it sure feels great in my ass!!!
Perl sucks. go away. AWK FOREVER!
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?
Note to self: get smarter troll to guard door.
I thought he changed his name to "Chemical Ali".
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.
I am in no way embedding Perl, I don't even like her that way. All rumours of me extending anything towards her are purely fictitious.
I consider myself a competant programmer, but years of experience have never taught me what it means to 'assign magic to a variable' or deterime the 'taintedness' of a string I found to be magical. Problems of global scope of the loaded programs alone merit a book, or at least a chapter.
The documention behind it is some of the most befuddled I've ever had this displeasure of witnessing, so nearly all my learning came from studying other programs who managed to do it, along with a brief and ill-advised stint into the garbage collection routines of the interpreter source.
Merely by existing and being written in English, this is already the best reference on the planet. Hell, it could be written in Klingon and still be more understandable than half the API documents.
/syle
Embedded. Please no, not that word again!
- IP
of one that appeared a month or two ago
... to handle an arbitrary number of arguments
PHP:
function MyFunctionWith2Args($line1, $line2)
{
print $line1 . "\n" . $line2;
}
function MyFunctionWith3Args($line1, $line2, $line3)
{
print $line1 . "\n" . $line2 . "\n" . $line3;
}
function MyFunctionWith4Args($line1, $line2, $line3, $line4)
{
print $line1 . "\n" . $line2 . "\n" . $line3 . "\n" . $line4;
}
You get the picture...
Perl:
sub MyFunction {
print join( "\n", @_ );
}
this works for any number of arguments. Perl's argument passing semantics are inherently varardic. I prefer this rather than having to define n number of functions for n possibilities of argument passing.
In the course of every project, it will become necessary to shoot the scientists and begin production.
This book has been a long time in waiting. I've used PerlXS to preserve legacy code written in C with more than satisfactory results. I had to do this on a win32 platform, where the man pages (usually written for *NIX environments) don't always 100% translate to a win32 environment.
I'll probably get the book.
Perl Sucks. AWK Rules. Stop wasting everyone's time with silly perl tricks.
languages that are self-obfuscating, are full of 'shortcuts', are needfully open to change, difficult to extend, and allow for maximum unreadability should be shifted off the programming coil. Perl is one of these. Its for people who like to say "Guess what this does!" and have other programmers respond, "I have no clue.".
This book will probably be useless in a few days, might as well give it a speed read and throw it away unless you plan on using perl 5.x.x for a while.
=begin comment
Sometimes I like to write big long descriptions of any moderately-complex procedures being stored in a file.
I really don't like having to put a hash in front of each line.
It gets rather cumbersone and ugly after a while.
L.
=end
XS really isn't as horrible as some people make it out to be.
Posting anonymously from work, someone mod me up, okay?
I used to play it on a teletype my dad had in our shed. I forget what it was dialing into. Nice thing about the teletype was that you then had a printed record that you could go through offline and create a map from.
I did change their code to use strncpy instead of strcpy for copying string return values to a char array in C. Can't believe that was in there... :(
(This is for embedding Perl interpreter into your C program, but the book also covers visa-versa too)
Two sample chapters from the book are available in PDF format from the publisher's website, here.
Tcl was designed from the ground up to be 'embedded and extended', and it shows. The core C code is well documented and easy to read, and there are man pages for all the functions in the public API. It's very easy to create little extensions without using any wierd half perl, half c languages. Tcl exposes a huge portion of its internals at the C level, which lets you do all kinds of cool stuff in your C code. It's very easy to create code where all the performance critical sections are coded in C, and then tied together with Tcl.
Python's C API is also pretty good.
http://www.welton.it/davidw/
There was another review of this book on Slashdot last October.
Find free books.
Larry Wall loves to dismiss awk, and emphasize how brillant he thinks he is, but the fact is he should bow down to awk. Oh, so he ran into a stumbling block with awk and wet his pants and so decided to build a better scripting language. So what. Do you know anyone who can sit through the Camel book? huh? No. Someone said it was a great example of technical writing. There is so much in that book, yet its missing almost everything. Thats where all the other gigantic Perl books come from. If he knew how to write he could have fitted all the info into one book. But instead, you get him blabbing about how he is a hacker and this and that. BOW!
coding too much Parrot makes you crazy?
Or rather, what became Zork.
Originally written on MIT-DM during 1977-1979, later distributed with BSD Unix (as a patched, sourceless RT-11 FORTRAN binary) The FORTRAN source was later rewritten for portability and released to Usenet under the name "Dungeon". Both FORTRAN "Dungeon" and translated C versions are available at many FTP sites.
APP is a _very_ brief skim of the material. EaEP goes into far more detail.
In fact, APP only skims all the topics it covers. It appears to mostly be an introduction to various topics that one can then further explore elsewhere.
These days, you're better off purchasing the TPJ books if you want the sort of thing APP gave.
For mixing C and Perl, EaEP is excellent.
-- koschei
Thanks. Beings that I am just getting into this myself, I'm more than a bit interested. Can never have too much good information!