Portal:Embedding and Extending Perl: Difference between revisions
(Created page with "== Introduction == One of Perls major strengths is the many options programmers have for extending Perl using C code and digging into the guts of the interpreter. This page is the dedicated portal for the vast and option rich subject.") |
No edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== Introduction == | == Introduction == | ||
[[File:51WB2JDyfqL.jpg|alt=Extending and Embedding Perl by Jenness and Cozens is seminal work on this topic.|thumb|[https://www.amazon.com/Extending-Embedding-Perl-Tim-Jenness/dp/1930110820 ''Extending and Embedding Perl''] by Jenness and Cozens is seminal work on this topic.]] | |||
One of Perls major strengths is the many options programmers have for extending Perl using C code and digging into the guts of the interpreter. This page is the dedicated portal for the vast and option rich subject. | One of Perls major strengths is the many options programmers have for extending Perl using C code and digging into the guts of the interpreter. This page is the dedicated portal for the vast and option rich subject. | ||
'''Note: This portal is in need of a domain expert(s) willing to participate at least in the "Discussion" tab, in the meantime it is a collection of links and other resources. [mailto:brett.estrade@gmail.com Email me] if you're interested.''' | |||
== Modern Resources == | |||
* [https://github.com/nrdvana/perl-XS-Tricks/blob/main/doc/perl-to-xs-cheatsheet.md XS Cheatsheet] by [https://github.com/nrdvana nrdvana] (github.org) | |||
== Recent Articles == | |||
[https://blogs.perl.org/users/nerdvana/2025/01/premium-xs-integration-pt-1.html Premium XS Integration Part 1] by [https://blogs.perl.org/users/nerdvana/ nerdvana] (blogs.perl.org) | |||
The author advocates for a balanced XS approach that exposes low-level C library functions while ensuring runtime safety to prevent crashes. The article critiques common patterns for binding C structs to Perl objects, pointing out issues like segfaults and improper object management. It recommends using Perl’s ''magic'' system to link C objects to Perl objects securely, preventing accidental errors. Typemaps are also highlighted as a way to simplify XS code by automating object validation and memory management, reducing boilerplate and improving error handling. Additionally, the article introduces the use of custom structs to manage multiple C pointers for complex libraries, further streamlining XS code. These techniques aim to create foolproof, efficient XS bindings, providing clear error messages and improving the overall developer experience. | |||
== Past == | |||
* [https://github.com/rurban/illguts/blob/db5d51138597724fa98f55591cb487ef81bae22c/illguts.pdf Perl Illguts] (0.49, Perl 5.20+) by [https://github.com/rurban Reini Urban], et al. (github.org) | |||
* [https://perlbin.sourceforge.net/perlcompiler/perl.internals.pdf Perl 5 Internals] by Simon Cozens (2001) (sourceforge.net) |
Latest revision as of 10:49, 29 January 2025
Introduction[edit | edit source]
One of Perls major strengths is the many options programmers have for extending Perl using C code and digging into the guts of the interpreter. This page is the dedicated portal for the vast and option rich subject.
Note: This portal is in need of a domain expert(s) willing to participate at least in the "Discussion" tab, in the meantime it is a collection of links and other resources. Email me if you're interested.
Modern Resources[edit | edit source]
- XS Cheatsheet by nrdvana (github.org)
Recent Articles[edit | edit source]
Premium XS Integration Part 1 by nerdvana (blogs.perl.org)
The author advocates for a balanced XS approach that exposes low-level C library functions while ensuring runtime safety to prevent crashes. The article critiques common patterns for binding C structs to Perl objects, pointing out issues like segfaults and improper object management. It recommends using Perl’s magic system to link C objects to Perl objects securely, preventing accidental errors. Typemaps are also highlighted as a way to simplify XS code by automating object validation and memory management, reducing boilerplate and improving error handling. Additionally, the article introduces the use of custom structs to manage multiple C pointers for complex libraries, further streamlining XS code. These techniques aim to create foolproof, efficient XS bindings, providing clear error messages and improving the overall developer experience.
Past[edit | edit source]
- Perl Illguts (0.49, Perl 5.20+) by Reini Urban, et al. (github.org)
- Perl 5 Internals by Simon Cozens (2001) (sourceforge.net)