SlideShare uma empresa Scribd logo
1 de 22
Baixar para ler 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 Fun
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

Mais conteúdo relacionado

Semelhante a 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
 

Semelhante a 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
 

Mais de 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
 

Mais de 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
 

Último

IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IES VE
 
Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintMahmoud Rabie
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxUdaiappa Ramachandran
 
UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8DianaGray10
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdfPedro Manuel
 
OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureEric D. Schabell
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaborationbruanjhuli
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6DianaGray10
 
Comparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioComparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioChristian Posta
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfDianaGray10
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfinfogdgmi
 
Machine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfMachine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfAijun Zhang
 
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfJamie (Taka) Wang
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.YounusS2
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesMd Hossain Ali
 
NIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopNIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopBachir Benyammi
 
Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsSeth Reyes
 
20230202 - Introduction to tis-py
20230202 - Introduction to tis-py20230202 - Introduction to tis-py
20230202 - Introduction to tis-pyJamie (Taka) Wang
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024SkyPlanner
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Commit University
 

Último (20)

IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
 
Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership Blueprint
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptx
 
UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdf
 
OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability Adventure
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6
 
Comparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioComparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and Istio
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdf
 
Machine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfMachine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdf
 
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
 
NIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopNIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 Workshop
 
Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and Hazards
 
20230202 - Introduction to tis-py
20230202 - Introduction to tis-py20230202 - Introduction to tis-py
20230202 - Introduction to tis-py
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)
 

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
  • 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!