Your SlideShare is downloading. ×
0
An alternative to XS‎ Leon Timmermans
XS <ul><ul><li>Preprocessor </li></ul></ul><ul><ul><ul><li>XS to C </li></ul></ul></ul><ul><ul><ul><li>C to Binary </li></...
Templates <ul><li>A compile-time feature of C++ </li></ul><ul><li>Turns meta code into code </li></ul><ul><li>Turing compl...
Example <ul><li>#! /usr/bin/perl </li></ul><ul><li>use Modern::Perl; </li></ul><ul><li>use Extend qw/hello/; </li></ul><ul...
Example <ul><li>package Extend; </li></ul><ul><li>use Modern::Perl </li></ul><ul><li>use Exporter 5.57 qw/import/; </li></...
Example <ul><li>#include <perl++/perl++.h> </li></ul><ul><li>#include <perl++/extend.h> </li></ul><ul><li>using namespace ...
Example 2 <ul><li>#include <perl++/perl++.h> </li></ul><ul><li>#include <perl++/extend.h> </li></ul><ul><li>using namespac...
Thank you <ul><li>Code at http://github.com/Leont/libperl-- </li></ul><ul><ul><li>CPAN will follow soon </li></ul></ul><ul...
Upcoming SlideShare
Loading in...5
×

An alternative to xs

420

Published on

XS has been the way to extend perl with C or C++ code for the past decade and a half. It has become a powerful but hard to tame beast.

In this lightning talk, I'm exploring an entirely new approach to extending perl, based on C++ metaprogramming instead of preprocessing. One that doesn't require a programmer familiar with both to learn yet another language.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
420
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "An alternative to xs"

  1. 1. An alternative to XS‎ Leon Timmermans
  2. 2. XS <ul><ul><li>Preprocessor </li></ul></ul><ul><ul><ul><li>XS to C </li></ul></ul></ul><ul><ul><ul><li>C to Binary </li></ul></ul></ul><ul><ul><li>Pros </li></ul></ul><ul><ul><ul><li>Flexible </li></ul></ul></ul><ul><ul><ul><li>Mature </li></ul></ul></ul><ul><ul><li>Cons </li></ul></ul><ul><ul><ul><li>Yet another languages to learn </li></ul></ul></ul><ul><ul><ul><li>… that isn't even a language </li></ul></ul></ul><ul><ul><ul><li>Requires some understanding of the interpreter </li></ul></ul></ul><ul><ul><ul><li>Limited C++ support </li></ul></ul></ul>
  3. 3. Templates <ul><li>A compile-time feature of C++ </li></ul><ul><li>Turns meta code into code </li></ul><ul><li>Turing complete, purely functional </li></ul>
  4. 4. Example <ul><li>#! /usr/bin/perl </li></ul><ul><li>use Modern::Perl; </li></ul><ul><li>use Extend qw/hello/; </li></ul><ul><li>hello('world'); </li></ul>
  5. 5. Example <ul><li>package Extend; </li></ul><ul><li>use Modern::Perl </li></ul><ul><li>use Exporter 5.57 qw/import/; </li></ul><ul><li>our @EXPORT_OK = qw/hello/; </li></ul><ul><li>use Perlpp::Extend; </li></ul><ul><li>1; </li></ul>
  6. 6. Example <ul><li>#include <perl++/perl++.h> </li></ul><ul><li>#include <perl++/extend.h> </li></ul><ul><li>using namespace perl; </li></ul><ul><li>static void hello(const char* world) { </li></ul><ul><li>printf(&quot;Hello %s &quot;, world); </li></ul><ul><li>} </li></ul><ul><li>static void exporter(Package& extend) { </li></ul><ul><li>extend.add(&quot;hello&quot;, hello); </li></ul><ul><li>} </li></ul><ul><li>EXPORTER(exporter); </li></ul>
  7. 7. Example 2 <ul><li>#include <perl++/perl++.h> </li></ul><ul><li>#include <perl++/extend.h> </li></ul><ul><li>using namespace perl; </li></ul><ul><li>struct foo { </li></ul><ul><li>foo(const std::string&); </li></ul><ul><li>void bar(int barista); </li></ul><ul><li>std::string buz; </li></ul><ul><li>}; </li></ul><ul><li>static void exporter(Class<foo>& extend) { </li></ul><ul><li>extend.add(init<std::string>()); </li></ul><ul><li>extend.add(&quot;bar&quot;, &foo::bar); </li></ul><ul><li>extend.add(&quot;buz&quot;, &foo::buz); </li></ul><ul><li>} </li></ul><ul><li>EXPORTER(exporter); </li></ul>
  8. 8. Thank you <ul><li>Code at http://github.com/Leont/libperl-- </li></ul><ul><ul><li>CPAN will follow soon </li></ul></ul><ul><li>Thanks for listening </li></ul><ul><li>Thanks EPO for sending me here </li></ul><ul><ul><li>I'm the send-a-newbe </li></ul></ul>
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×