SlideShare a Scribd company logo
1 of 22
Download to read offline
XS Fun

Sawyer X ( @PerlSawyer)
XS is...
A glue layer between Perl and C/C++
Sections, macros, functions
Requires knowledge with C, Perl API, XS, typemaps
Written by our very best
Complex, difficult, strenuous, laborious, painful, formidable
(additional words can be found in thesaurus.com )
An impediment to Modern Perl
XS is
misunderstood
No need to be an expert
Basic Perl API is simple
XS is not too difficult
Lots of options
All documented
Except...
... except those that aren't documented
... except that the official tutorial sucks
... except that there's no better (or any other full) tutorial
(at least not one I could find)
I guess I'll write one then!
XS Fun
A tutorial making XS fun
Starts easy, progresses slowly
Split to chapters, each taking a small task
A lot of explanations for beginners
All examples work
Features
Already on Github
A few chapters already covered
Functions (XS, C)
Constructor
Simple methods
Missing
Complex methods
Converting objects with typemaps
Advanced XS
Quick glossary
SV = Scalar Value
Of:
IV = Integer Value (m $ = - 0
y i
3)
UV = Unsigned Integer Value (m $ = 3 0 . .
y u
00.)
NV = Double Value (m $ = 3 . 7 )
y d
071
PV = String Value (m $ = ' e l w r d )
y s
hlo ol'
SV = (another) Scalar Value
AH = Array Value (m @ = q < e l w r d )
y a
whlo ol>
HV = Hash Value (m % = ( h l o = ' o l ' )
y h
el > wrd )
RV = Reference Value (m $ a h e =  h
y hsrf
%)
That's it for now
Examples
XSFun.pm
pcaeXFn
akg Su;
uesrc;
s tit
uewrig;
s anns
ueEpre;
s xotr
ueXLae;
s Sodr
uebs 'xotr;
s ae Epre'
or$ESO
u VRIN
='.0'
001;
or%XOTTG =('l'= [wgtvrin])
u EPR_AS
al > q<e_eso> ;
or@XOTO
u EPR_K =(@ $XOTTG{al}})
{ EPR_AS'l'
;
XLae:la('Su' $ESO )
Sodr:od XFn, VRIN ;
1
;
XSFun.xs
#nld "XENh
icue ETR."
#nld "elh
icue pr."
#nld "SBh
icue XU."
#nld "poth
icue ppr."
MDL =XFn
OUE
Su

PCAE=XFn
AKG
Su

dul
obe
adnmesdul a dul b
d_ubr(obe , obe )
CD:
OE
RTA =a+b
EVL
;
OTU:
UPT
RTA
EVL
S *
V
adnmespr(V*,S *)
d_ubr_elS a V b
CD:
OE
{
cntdul sm=SN()+SN()
os obe u
vVa
vVb;
RTA =nwVvsm;
EVL
eSn(u)
}
OTU:RTA
UPT EVL
XSFun.xs (more)
#nld <hoarn.>
icue crmpith
/ i tecd scin*
* n h oe eto /
cntca *
os hr
gtvrin)
e_eso(
CD:
OE
RTA =crmpitgtvrin)
EVL
hoarn_e_eso(;
OTU:RTA
UPT EVL
#i vrint
n eso.:
ueXFn'al;
s Su :l'
i(gtvrin) '..' 'hoarn vrini 600 )
s e_eso(, 600, crmpit eso s ..' ;
tvrint. o
/eso. . k
Altssscesu.
l et ucsfl
Fls1 Tss1 0wlcoksc (00 ur 00 ss+ 00 cs
ie=, et=,
allc es
.3 s
.1 y
.2 ur
00 cy = 00 CU
.0 ss
.6 P)
Rsl:PS
eut AS
Audio::Chromaprint
Interface to Chromaprint library
Audio/Chromaprint.pm
pcaeAdo:hoarn;
akg ui:Crmpit
uesrc;
s tit
uewrig;
s anns
ueXLae;
s Sodr
or$ESO ='.0'
u VRIN
001;
XLae:la('ui:Crmpit,$ESO )
Sodr:od Ado:hoarn' VRIN ;
1
;
Chromaprint.xs
#nld "XENh
icue ETR."
#nld "elh
icue pr."
#nld "SBh
icue XU."
#nld "poth
icue ppr."
#nld <hoarn.>
icue crmpith
MDL =Ado:hoarn
OUE
ui:Crmpit

PCAE=Ado:hoarn
AKG
ui:Crmpit
Chromaprint.xs
cntca *
os hr
vrinS *ef
eso(V sl)
CD:
OE
RTA =crmpitgtvrin)
EVL
hoarn_e_eso(;
OTU:RTA
UPT EVL
Constructor
#I Pr:
n el
sbnw{bes{,sit}
u e
ls } hf
#o..
r.
sbnw{
u e
m $ls =sit #o $[]
y cas
hf;
r _0
m %ah =(;
y hs
)
m $ef =hs;
y sl
%ah
rtr bes$ef $ls;
eun ls sl, cas
}
#Pr-el
uePr
sbnw{
u e
m $ls =sit #o $[]
y cas
hf;
r _0
m %ah =(;
y hs
)
m $ef =hs;
y sl
%ah
rtr bes$ef $ls;
eun ls sl, cas
}
/ i X *
* n S /
S *
V
nw cntca *ls )
e( os hr cas
CD:
OE
/ Cet ahs *
* rae
ah /
H*hs =nwV)
V ah
eH(;
/ Cet arfrnet tehs *
* rae
eeec o h ah /
S*cntsl =nwVnic (V*hs )
V os ef
eR_on( S )ah ;
/ besit tepoe pcae*
* ls no h rpr akg /
RTA =s_ls(sl,g_tsp(cas 0))
EVL
vbes ef vsahv ls,
;
OTU:RTA
UPT EVL
Conclusions
XS is not that complex
XS can be fun
You can do it!
Thank you
Homework:
github.com/xsawyerx/xs-fun
perldoc perlguts
perldoc perlapi
perldoc perlxs

More Related Content

Similar to XS Fun

What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)Pavlo Baron
 
Java 8 - project lambda
Java 8 - project lambdaJava 8 - project lambda
Java 8 - project lambdaIvar Østhus
 
Compiler Construction | Lecture 5 | Transformation by Term Rewriting
Compiler Construction | Lecture 5 | Transformation by Term RewritingCompiler Construction | Lecture 5 | Transformation by Term Rewriting
Compiler Construction | Lecture 5 | Transformation by Term RewritingEelco Visser
 
Build a custom (micro)framework with ZF2 Components (as building blocks)
Build a custom (micro)framework with ZF2 Components (as building blocks)Build a custom (micro)framework with ZF2 Components (as building blocks)
Build a custom (micro)framework with ZF2 Components (as building blocks)Corley S.r.l.
 
Building modern web apps with html5, javascript, and java
Building modern web apps with html5, javascript, and javaBuilding modern web apps with html5, javascript, and java
Building modern web apps with html5, javascript, and javaAlexander Gyoshev
 
CS4200 2019 | Lecture 5 | Transformation by Term Rewriting
CS4200 2019 | Lecture 5 | Transformation by Term RewritingCS4200 2019 | Lecture 5 | Transformation by Term Rewriting
CS4200 2019 | Lecture 5 | Transformation by Term RewritingEelco Visser
 
Kotlin Language Features - A Java comparison
Kotlin Language Features - A Java comparisonKotlin Language Features - A Java comparison
Kotlin Language Features - A Java comparisonEd Austin
 
Beginner workshop to angularjs presentation at Google
Beginner workshop to angularjs presentation at GoogleBeginner workshop to angularjs presentation at Google
Beginner workshop to angularjs presentation at GoogleAri Lerner
 
Compilation of COSMO for GPU using LLVM
Compilation of COSMO for GPU using LLVMCompilation of COSMO for GPU using LLVM
Compilation of COSMO for GPU using LLVMLinaro
 
2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices
2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices
2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best PracticesJohannes Hoppe
 
What I learned from Seven Languages in Seven Weeks (IPRUG)
What I learned from Seven Languages in Seven Weeks (IPRUG)What I learned from Seven Languages in Seven Weeks (IPRUG)
What I learned from Seven Languages in Seven Weeks (IPRUG)Kerry Buckley
 

Similar to XS Fun (20)

Javascript: The Important Bits
Javascript: The Important BitsJavascript: The Important Bits
Javascript: The Important Bits
 
What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)
 
C to perl binding
C to perl bindingC to perl binding
C to perl binding
 
Java 8 - project lambda
Java 8 - project lambdaJava 8 - project lambda
Java 8 - project lambda
 
Compiler Construction | Lecture 5 | Transformation by Term Rewriting
Compiler Construction | Lecture 5 | Transformation by Term RewritingCompiler Construction | Lecture 5 | Transformation by Term Rewriting
Compiler Construction | Lecture 5 | Transformation by Term Rewriting
 
Ff to-fp
Ff to-fpFf to-fp
Ff to-fp
 
Build a custom (micro)framework with ZF2 Components (as building blocks)
Build a custom (micro)framework with ZF2 Components (as building blocks)Build a custom (micro)framework with ZF2 Components (as building blocks)
Build a custom (micro)framework with ZF2 Components (as building blocks)
 
Building modern web apps with html5, javascript, and java
Building modern web apps with html5, javascript, and javaBuilding modern web apps with html5, javascript, and java
Building modern web apps with html5, javascript, and java
 
CS4200 2019 | Lecture 5 | Transformation by Term Rewriting
CS4200 2019 | Lecture 5 | Transformation by Term RewritingCS4200 2019 | Lecture 5 | Transformation by Term Rewriting
CS4200 2019 | Lecture 5 | Transformation by Term Rewriting
 
OOP in Rust
OOP in RustOOP in Rust
OOP in Rust
 
JavaFX, because you're worth it
JavaFX, because you're worth itJavaFX, because you're worth it
JavaFX, because you're worth it
 
Kotlin Language Features - A Java comparison
Kotlin Language Features - A Java comparisonKotlin Language Features - A Java comparison
Kotlin Language Features - A Java comparison
 
Beginner workshop to angularjs presentation at Google
Beginner workshop to angularjs presentation at GoogleBeginner workshop to angularjs presentation at Google
Beginner workshop to angularjs presentation at Google
 
Elixir cheatsheet
Elixir cheatsheetElixir cheatsheet
Elixir cheatsheet
 
Compilation of COSMO for GPU using LLVM
Compilation of COSMO for GPU using LLVMCompilation of COSMO for GPU using LLVM
Compilation of COSMO for GPU using LLVM
 
2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices
2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices
2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices
 
Scala - brief intro
Scala - brief introScala - brief intro
Scala - brief intro
 
JavaScript pitfalls
JavaScript pitfallsJavaScript pitfalls
JavaScript pitfalls
 
What I learned from Seven Languages in Seven Weeks (IPRUG)
What I learned from Seven Languages in Seven Weeks (IPRUG)What I learned from Seven Languages in Seven Weeks (IPRUG)
What I learned from Seven Languages in Seven Weeks (IPRUG)
 
Rust_Threads.pdf
Rust_Threads.pdfRust_Threads.pdf
Rust_Threads.pdf
 

More from xSawyer

Asynchronous Programming FTW! 2 (with AnyEvent)
Asynchronous Programming FTW! 2 (with AnyEvent)Asynchronous Programming FTW! 2 (with AnyEvent)
Asynchronous Programming FTW! 2 (with AnyEvent)xSawyer
 
Moose - YAPC::NA 2012
Moose - YAPC::NA 2012Moose - YAPC::NA 2012
Moose - YAPC::NA 2012xSawyer
 
Our local state, my, my - Understanding Perl variables
Our local state, my, my - Understanding Perl variablesOur local state, my, my - Understanding Perl variables
Our local state, my, my - Understanding Perl variablesxSawyer
 
Your first website in under a minute with Dancer
Your first website in under a minute with DancerYour first website in under a minute with Dancer
Your first website in under a minute with DancerxSawyer
 
Moose talk at FOSDEM 2011 (Perl devroom)
Moose talk at FOSDEM 2011 (Perl devroom)Moose talk at FOSDEM 2011 (Perl devroom)
Moose talk at FOSDEM 2011 (Perl devroom)xSawyer
 
PerlDancer for Perlers (FOSDEM 2011)
PerlDancer for Perlers (FOSDEM 2011)PerlDancer for Perlers (FOSDEM 2011)
PerlDancer for Perlers (FOSDEM 2011)xSawyer
 
Perl Dancer for Python programmers
Perl Dancer for Python programmersPerl Dancer for Python programmers
Perl Dancer for Python programmersxSawyer
 
When Perl Met Android (YAPC::EU 2010)
When Perl Met Android (YAPC::EU 2010)When Perl Met Android (YAPC::EU 2010)
When Perl Met Android (YAPC::EU 2010)xSawyer
 
Perl Dancer on Android (first attempt)
Perl Dancer on Android (first attempt)Perl Dancer on Android (first attempt)
Perl Dancer on Android (first attempt)xSawyer
 
Source Code Management systems
Source Code Management systemsSource Code Management systems
Source Code Management systemsxSawyer
 
Moose (Perl 5)
Moose (Perl 5)Moose (Perl 5)
Moose (Perl 5)xSawyer
 
Red Flags in Programming
Red Flags in ProgrammingRed Flags in Programming
Red Flags in ProgrammingxSawyer
 

More from xSawyer (12)

Asynchronous Programming FTW! 2 (with AnyEvent)
Asynchronous Programming FTW! 2 (with AnyEvent)Asynchronous Programming FTW! 2 (with AnyEvent)
Asynchronous Programming FTW! 2 (with AnyEvent)
 
Moose - YAPC::NA 2012
Moose - YAPC::NA 2012Moose - YAPC::NA 2012
Moose - YAPC::NA 2012
 
Our local state, my, my - Understanding Perl variables
Our local state, my, my - Understanding Perl variablesOur local state, my, my - Understanding Perl variables
Our local state, my, my - Understanding Perl variables
 
Your first website in under a minute with Dancer
Your first website in under a minute with DancerYour first website in under a minute with Dancer
Your first website in under a minute with Dancer
 
Moose talk at FOSDEM 2011 (Perl devroom)
Moose talk at FOSDEM 2011 (Perl devroom)Moose talk at FOSDEM 2011 (Perl devroom)
Moose talk at FOSDEM 2011 (Perl devroom)
 
PerlDancer for Perlers (FOSDEM 2011)
PerlDancer for Perlers (FOSDEM 2011)PerlDancer for Perlers (FOSDEM 2011)
PerlDancer for Perlers (FOSDEM 2011)
 
Perl Dancer for Python programmers
Perl Dancer for Python programmersPerl Dancer for Python programmers
Perl Dancer for Python programmers
 
When Perl Met Android (YAPC::EU 2010)
When Perl Met Android (YAPC::EU 2010)When Perl Met Android (YAPC::EU 2010)
When Perl Met Android (YAPC::EU 2010)
 
Perl Dancer on Android (first attempt)
Perl Dancer on Android (first attempt)Perl Dancer on Android (first attempt)
Perl Dancer on Android (first attempt)
 
Source Code Management systems
Source Code Management systemsSource Code Management systems
Source Code Management systems
 
Moose (Perl 5)
Moose (Perl 5)Moose (Perl 5)
Moose (Perl 5)
 
Red Flags in Programming
Red Flags in ProgrammingRed Flags in Programming
Red Flags in Programming
 

Recently uploaded

Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 

Recently uploaded (20)

DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 

XS Fun

  • 1. XS Fun Sawyer X ( @PerlSawyer)
  • 2. XS is... A glue layer between Perl and C/C++ Sections, macros, functions Requires knowledge with C, Perl API, XS, typemaps Written by our very best Complex, difficult, strenuous, laborious, painful, formidable (additional words can be found in thesaurus.com ) An impediment to Modern Perl
  • 3.
  • 4. XS is misunderstood No need to be an expert Basic Perl API is simple XS is not too difficult Lots of options All documented
  • 5. Except... ... except those that aren't documented ... except that the official tutorial sucks ... except that there's no better (or any other full) tutorial (at least not one I could find)
  • 6. I guess I'll write one then!
  • 7. XS Fun A tutorial making XS fun Starts easy, progresses slowly Split to chapters, each taking a small task A lot of explanations for beginners All examples work
  • 8. Features Already on Github A few chapters already covered Functions (XS, C) Constructor Simple methods
  • 9. Missing Complex methods Converting objects with typemaps Advanced XS
  • 10. Quick glossary SV = Scalar Value Of: IV = Integer Value (m $ = - 0 y i 3) UV = Unsigned Integer Value (m $ = 3 0 . . y u 00.) NV = Double Value (m $ = 3 . 7 ) y d 071 PV = String Value (m $ = ' e l w r d ) y s hlo ol' SV = (another) Scalar Value AH = Array Value (m @ = q < e l w r d ) y a whlo ol> HV = Hash Value (m % = ( h l o = ' o l ' ) y h el > wrd ) RV = Reference Value (m $ a h e = h y hsrf %) That's it for now
  • 12. XSFun.pm pcaeXFn akg Su; uesrc; s tit uewrig; s anns ueEpre; s xotr ueXLae; s Sodr uebs 'xotr; s ae Epre' or$ESO u VRIN ='.0' 001; or%XOTTG =('l'= [wgtvrin]) u EPR_AS al > q<e_eso> ; or@XOTO u EPR_K =(@ $XOTTG{al}}) { EPR_AS'l' ; XLae:la('Su' $ESO ) Sodr:od XFn, VRIN ; 1 ;
  • 13. XSFun.xs #nld "XENh icue ETR." #nld "elh icue pr." #nld "SBh icue XU." #nld "poth icue ppr." MDL =XFn OUE Su PCAE=XFn AKG Su dul obe adnmesdul a dul b d_ubr(obe , obe ) CD: OE RTA =a+b EVL ; OTU: UPT RTA EVL S * V adnmespr(V*,S *) d_ubr_elS a V b CD: OE { cntdul sm=SN()+SN() os obe u vVa vVb; RTA =nwVvsm; EVL eSn(u) } OTU:RTA UPT EVL
  • 14. XSFun.xs (more) #nld <hoarn.> icue crmpith / i tecd scin* * n h oe eto / cntca * os hr gtvrin) e_eso( CD: OE RTA =crmpitgtvrin) EVL hoarn_e_eso(; OTU:RTA UPT EVL #i vrint n eso.: ueXFn'al; s Su :l' i(gtvrin) '..' 'hoarn vrini 600 ) s e_eso(, 600, crmpit eso s ..' ; tvrint. o /eso. . k Altssscesu. l et ucsfl Fls1 Tss1 0wlcoksc (00 ur 00 ss+ 00 cs ie=, et=, allc es .3 s .1 y .2 ur 00 cy = 00 CU .0 ss .6 P) Rsl:PS eut AS
  • 16. Audio/Chromaprint.pm pcaeAdo:hoarn; akg ui:Crmpit uesrc; s tit uewrig; s anns ueXLae; s Sodr or$ESO ='.0' u VRIN 001; XLae:la('ui:Crmpit,$ESO ) Sodr:od Ado:hoarn' VRIN ; 1 ;
  • 17. Chromaprint.xs #nld "XENh icue ETR." #nld "elh icue pr." #nld "SBh icue XU." #nld "poth icue ppr." #nld <hoarn.> icue crmpith MDL =Ado:hoarn OUE ui:Crmpit PCAE=Ado:hoarn AKG ui:Crmpit
  • 18. Chromaprint.xs cntca * os hr vrinS *ef eso(V sl) CD: OE RTA =crmpitgtvrin) EVL hoarn_e_eso(; OTU:RTA UPT EVL
  • 19. Constructor #I Pr: n el sbnw{bes{,sit} u e ls } hf #o.. r. sbnw{ u e m $ls =sit #o $[] y cas hf; r _0 m %ah =(; y hs ) m $ef =hs; y sl %ah rtr bes$ef $ls; eun ls sl, cas }
  • 20. #Pr-el uePr sbnw{ u e m $ls =sit #o $[] y cas hf; r _0 m %ah =(; y hs ) m $ef =hs; y sl %ah rtr bes$ef $ls; eun ls sl, cas } / i X * * n S / S * V nw cntca *ls ) e( os hr cas CD: OE / Cet ahs * * rae ah / H*hs =nwV) V ah eH(; / Cet arfrnet tehs * * rae eeec o h ah / S*cntsl =nwVnic (V*hs ) V os ef eR_on( S )ah ; / besit tepoe pcae* * ls no h rpr akg / RTA =s_ls(sl,g_tsp(cas 0)) EVL vbes ef vsahv ls, ; OTU:RTA UPT EVL
  • 21. Conclusions XS is not that complex XS can be fun You can do it!