SlideShare a Scribd company logo
1 of 20
Download to read offline
Code Generation in Perl
Presentation by Ian Kluft
for Silicon Valley Perl
September 7, 2017
Santa Clara, California
What is Code Generation?
●
Programs that write programs
●
There are many ways to approach this
●
Advantage: lets the coder work at a higher level
●
Disadvantage: someone still has to write program
The simplest example
●
A program hard-coded to print another program
●
Even the simple example has non-trivial quoting
#!/usr/bin/perl
use strict;
use warnings;
print qq(#!/usr/bin/perln);
print qq(use strict;n);
print qq(print "hello worldn";n);
Other approaches
●
Templates – fill in the blanks
●
Translators – parse, analyze and re-generate
●
Compilers – parse high level, generate lower level
●
SQL schemas & queries – generate SQL code
●
XML parsing – generate programs from XML data
●
UML tools – draw diagrams, generate code
CPAN Modules
which generate code
●
At a low level it’s widespread
– Many modules & scripts generate code for eval()
●
Perl build tools
●
SQL generation for queries and schemas
●
Perl application frameworks
– Easier to get started with tools that generate examples
●
Compilers
CPAN Modules
Perl build tools
●
CPAN Modules which generate code
– Dist::Zilla
– ExtUtils::MakeMaker
– Module::Build
●
These generate build scripts from module
configuration data
CPAN Modules
SQL code generation
●
DBIx::Class – object relational mapper
●
Fey – SQL schema and query generator
●
…CPAN is huge - the list goes on and on...
●
Many examples – which do you like?
CPAN Modules
XML & data code generators
●
Data::Dumper – dumps data as Perl code
●
Faker – extensible fake data generator
●
Not as much code generation from XML on CPAN
– Obvious category for ad hoc tools
– Any XML parser can be used to generate code
●
Writing HTML is not technically writing code
– But it also has similarities
CPAN Modules
Compilers
●
B::* - access to Perl compiler
●
Compiler generation tools
– Parse::Yapp/Parse::Eyapp – compiler parser generator
●
Similar to Unix “yacc” but generates Perl code
– Parse::RecDescent – generate recursive descent
compiler
– Parse::Lex – generate lexical analyzer for compiler
●
A lot of CPAN modules claiming to “compile”
actually “translate”
How Compilers Work
●
High level view of a compiler
Preprocessor
Scanner/
Tokenizer
Parser Semantics
●
Preprocessor – macros & text manipulation
●
Scanner – generates stream of tokens
– Removes comments
●
Parser – recognizes language structures
●
Semantics – generate code
– Some compilers like Perl make intermediate code for interpretation
Using Parser Generator Tools
●
Have you noticed that language compilers do things that
are way above the capabilities of regular expressions?
– RegEx’es are ideal for tokenizers/scanners
– There’s another level of language parsing above that
●
One example is to grab a yacc grammar and translate it
to Parse::Yapp or Parse::Eyapp
– I did that once for a Perl script that parsed /etc/sudoers files for
automated security audits
●
Language definitions in Backus-Naur Form (BNF) can be
converted to language parser defintions
UML
Unified Modeling Language
●
XML format representing standard diagrams
– Parts of a program or system design
– Analysis of code can generate UML for documentation
– Active research into ways to generate code from UML
●
Code generation can be done
●
But diagramming is far more tedious than typing code
●
You can experiment with this on your own projects
●
Idea is to use UML as design/documentation & generate code
UML – Unified Modeling Language
types of diagrams
Diagram
Class
Diagram
Component
Diagram
Object
Diagram
Activity
Diagram
Use Case
Diagram
Profile
Diagram
Composite
Structure
Diagram
Deployment
Diagram
Package
Diagram
Interaction
Diagram
State
Machine
Diagram
Sequence
Diagram
Communication
Diagram
Interaction
Overview
Diagram
Timing
Diagram Notation: UML
Behaviour
Diagram
Structure
Diagram
UML diagram types – as a class diagram (from Wikipedia)
UML – Unified Modeling Language
example class: Pizza
UML code generation makes class
source code starter templates for
●
Pizza
●
CrustEnum
●
ToppingList
●
ToppingEnum
●
SizeEnum
How would you go from here to write the code for the classes in UML?
Good ways to do that are still open to suggestion.
UML – Unified Modeling Language
Tools for Code Generation from UML
●
Open source “umbrello”
from KDE generated
previous slide’s graphic
●
Eclipse IDE has UML
generation tools
●
CPAN has many UML
modules, mostly for
generating UML from Perl for
analysis
●
Many other examples...
Setting expectations
What a non-engineer
manager wants…
This one doesn’t grasp
the current limitations.
He isn’t alone.
What people want is
often a hint where
research should push
the limits for the future.
Setting expectations
”Artificial Intelligence”
●
Artificial Intelligence has a broken promise built right into
its name
●
It has always been advanced algorithms
– It’s always non-trivial
– Not all uses of the term AI are as sophisticated as claimed
●
Its results usually appear clever
●
It can do lots of things people don’t do well
●
But it still can’t think
●
It isn’t real or artificial intelligence… yet
Science Fiction examples
Code generation and AI
●
One early SciFi story: “The Adolescence of P1” by
Thomas J Ryan, 1977
●
Based on modem-connected IBM 360 mainframes
●
Program to break OS “supervisor”
– Needed decision trees, code generator, threat analysis
– When told to shut down it played dead, kept running
– AI evolved organically
– Installed itself like a worm, broke OS like a virus
●
Few SciFi AI’s attempted such depth
Code Generation
Setting expectations back to reality
●
SciFi myths need to be debunked
●
Code generation just adds a level of abstraction
●
Someone still has to write the code
●
Short of an actual artificial intelligence, programs won’t
be writing programs any time soon
●
Maybe during 21st Century?
– 20th Century showed how much advancement can happen
– But AI is a fundamentally difficult computing challenge
– Don’t count on it
Code Generation
Q & A

More Related Content

What's hot

Zoo of domain-specific languages
Zoo of domain-specific languagesZoo of domain-specific languages
Zoo of domain-specific languagesMikhail Barash
 
Programming assignment-help at myassignmenthelp.net
Programming assignment-help at myassignmenthelp.netProgramming assignment-help at myassignmenthelp.net
Programming assignment-help at myassignmenthelp.netwww.myassignmenthelp.net
 
EMPEX LA 2018 - Inclusion Starts with Docs
EMPEX LA 2018 - Inclusion Starts with DocsEMPEX LA 2018 - Inclusion Starts with Docs
EMPEX LA 2018 - Inclusion Starts with DocsPete Gamache
 
Learning programming by: Ysa & Faye
Learning programming by: Ysa & FayeLearning programming by: Ysa & Faye
Learning programming by: Ysa & FayeTuanDanaIm
 
Learning programming
Learning programmingLearning programming
Learning programmingTuanDanaIm
 
Programming language
Programming languageProgramming language
Programming languageDhani Ahmad
 
Dion computerprogramming
Dion computerprogrammingDion computerprogramming
Dion computerprogramminglittlecricket07
 
Programming Methodology
Programming MethodologyProgramming Methodology
Programming Methodologyarchikabhatia
 
Error hanadling in c programming presentation
Error hanadling in c programming presentationError hanadling in c programming presentation
Error hanadling in c programming presentationPranaliPatil76
 
ALPHA Script - Presentation
ALPHA Script - PresentationALPHA Script - Presentation
ALPHA Script - PresentationPROBOTEK
 
APU RoR Workshop Series #1 - Introduction to Programming
APU RoR Workshop Series #1 - Introduction to ProgrammingAPU RoR Workshop Series #1 - Introduction to Programming
APU RoR Workshop Series #1 - Introduction to ProgrammingJimmy Ngu
 
ALPHA Script - Development Steps
ALPHA Script - Development StepsALPHA Script - Development Steps
ALPHA Script - Development StepsPROBOTEK
 
1 introduction to compiler
1 introduction to compiler1 introduction to compiler
1 introduction to compilerBarwarBadradin
 

What's hot (20)

Zoo of domain-specific languages
Zoo of domain-specific languagesZoo of domain-specific languages
Zoo of domain-specific languages
 
Programming assignment-help at myassignmenthelp.net
Programming assignment-help at myassignmenthelp.netProgramming assignment-help at myassignmenthelp.net
Programming assignment-help at myassignmenthelp.net
 
sitHH - No comment?
sitHH - No comment?sitHH - No comment?
sitHH - No comment?
 
Programming Paradigms
Programming ParadigmsProgramming Paradigms
Programming Paradigms
 
EMPEX LA 2018 - Inclusion Starts with Docs
EMPEX LA 2018 - Inclusion Starts with DocsEMPEX LA 2018 - Inclusion Starts with Docs
EMPEX LA 2018 - Inclusion Starts with Docs
 
Learning programming by: Ysa & Faye
Learning programming by: Ysa & FayeLearning programming by: Ysa & Faye
Learning programming by: Ysa & Faye
 
Learning programming
Learning programmingLearning programming
Learning programming
 
Lecture 21
Lecture 21Lecture 21
Lecture 21
 
SitFRA - No Comment?
SitFRA - No Comment?SitFRA - No Comment?
SitFRA - No Comment?
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
Programming language
Programming languageProgramming language
Programming language
 
Dion computerprogramming
Dion computerprogrammingDion computerprogramming
Dion computerprogramming
 
Programming Methodology
Programming MethodologyProgramming Methodology
Programming Methodology
 
Programming Language
Programming LanguageProgramming Language
Programming Language
 
Error hanadling in c programming presentation
Error hanadling in c programming presentationError hanadling in c programming presentation
Error hanadling in c programming presentation
 
ALPHA Script - Presentation
ALPHA Script - PresentationALPHA Script - Presentation
ALPHA Script - Presentation
 
Lecture 23 p1
Lecture 23 p1Lecture 23 p1
Lecture 23 p1
 
APU RoR Workshop Series #1 - Introduction to Programming
APU RoR Workshop Series #1 - Introduction to ProgrammingAPU RoR Workshop Series #1 - Introduction to Programming
APU RoR Workshop Series #1 - Introduction to Programming
 
ALPHA Script - Development Steps
ALPHA Script - Development StepsALPHA Script - Development Steps
ALPHA Script - Development Steps
 
1 introduction to compiler
1 introduction to compiler1 introduction to compiler
1 introduction to compiler
 

Viewers also liked

The Astonishing Resurrection of AI (A Primer on Artificial Intelligence)
The Astonishing Resurrection of AI (A Primer on Artificial Intelligence)The Astonishing Resurrection of AI (A Primer on Artificial Intelligence)
The Astonishing Resurrection of AI (A Primer on Artificial Intelligence)Matt Turck
 
artificial intelligence in power plants.
artificial intelligence in power plants.artificial intelligence in power plants.
artificial intelligence in power plants.8105268008
 
Machine Intelligence: Promises and Challenges
Machine Intelligence: Promises and ChallengesMachine Intelligence: Promises and Challenges
Machine Intelligence: Promises and ChallengesAlaa Khamis, PhD, SMIEEE
 
Py paris2017 / promises and perils in artificial intelligence, by Andreas Muller
Py paris2017 / promises and perils in artificial intelligence, by Andreas MullerPy paris2017 / promises and perils in artificial intelligence, by Andreas Muller
Py paris2017 / promises and perils in artificial intelligence, by Andreas MullerPôle Systematic Paris-Region
 
Social Machines: The coming collision of Artificial Intelligence, Social Netw...
Social Machines: The coming collision of Artificial Intelligence, Social Netw...Social Machines: The coming collision of Artificial Intelligence, Social Netw...
Social Machines: The coming collision of Artificial Intelligence, Social Netw...James Hendler
 
Issues on Artificial Intelligence and Future (Standards Perspective)
Issues on Artificial Intelligence  and Future (Standards Perspective)Issues on Artificial Intelligence  and Future (Standards Perspective)
Issues on Artificial Intelligence and Future (Standards Perspective)Seungyun Lee
 
artificial intelligence
artificial intelligenceartificial intelligence
artificial intelligencevallibhargavi
 
Artificial Intelligence
Artificial IntelligenceArtificial Intelligence
Artificial IntelligenceGirish Naik
 
Hype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerHype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerLuminary Labs
 
Deep Learning - The Past, Present and Future of Artificial Intelligence
Deep Learning - The Past, Present and Future of Artificial IntelligenceDeep Learning - The Past, Present and Future of Artificial Intelligence
Deep Learning - The Past, Present and Future of Artificial IntelligenceLukas Masuch
 
Artificial Intelligence
Artificial IntelligenceArtificial Intelligence
Artificial Intelligenceu053675
 
What is Artificial Intelligence | Artificial Intelligence Tutorial For Beginn...
What is Artificial Intelligence | Artificial Intelligence Tutorial For Beginn...What is Artificial Intelligence | Artificial Intelligence Tutorial For Beginn...
What is Artificial Intelligence | Artificial Intelligence Tutorial For Beginn...Edureka!
 
AI and Machine Learning Demystified by Carol Smith at Midwest UX 2017
AI and Machine Learning Demystified by Carol Smith at Midwest UX 2017AI and Machine Learning Demystified by Carol Smith at Midwest UX 2017
AI and Machine Learning Demystified by Carol Smith at Midwest UX 2017Carol Smith
 

Viewers also liked (13)

The Astonishing Resurrection of AI (A Primer on Artificial Intelligence)
The Astonishing Resurrection of AI (A Primer on Artificial Intelligence)The Astonishing Resurrection of AI (A Primer on Artificial Intelligence)
The Astonishing Resurrection of AI (A Primer on Artificial Intelligence)
 
artificial intelligence in power plants.
artificial intelligence in power plants.artificial intelligence in power plants.
artificial intelligence in power plants.
 
Machine Intelligence: Promises and Challenges
Machine Intelligence: Promises and ChallengesMachine Intelligence: Promises and Challenges
Machine Intelligence: Promises and Challenges
 
Py paris2017 / promises and perils in artificial intelligence, by Andreas Muller
Py paris2017 / promises and perils in artificial intelligence, by Andreas MullerPy paris2017 / promises and perils in artificial intelligence, by Andreas Muller
Py paris2017 / promises and perils in artificial intelligence, by Andreas Muller
 
Social Machines: The coming collision of Artificial Intelligence, Social Netw...
Social Machines: The coming collision of Artificial Intelligence, Social Netw...Social Machines: The coming collision of Artificial Intelligence, Social Netw...
Social Machines: The coming collision of Artificial Intelligence, Social Netw...
 
Issues on Artificial Intelligence and Future (Standards Perspective)
Issues on Artificial Intelligence  and Future (Standards Perspective)Issues on Artificial Intelligence  and Future (Standards Perspective)
Issues on Artificial Intelligence and Future (Standards Perspective)
 
artificial intelligence
artificial intelligenceartificial intelligence
artificial intelligence
 
Artificial Intelligence
Artificial IntelligenceArtificial Intelligence
Artificial Intelligence
 
Hype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerHype vs. Reality: The AI Explainer
Hype vs. Reality: The AI Explainer
 
Deep Learning - The Past, Present and Future of Artificial Intelligence
Deep Learning - The Past, Present and Future of Artificial IntelligenceDeep Learning - The Past, Present and Future of Artificial Intelligence
Deep Learning - The Past, Present and Future of Artificial Intelligence
 
Artificial Intelligence
Artificial IntelligenceArtificial Intelligence
Artificial Intelligence
 
What is Artificial Intelligence | Artificial Intelligence Tutorial For Beginn...
What is Artificial Intelligence | Artificial Intelligence Tutorial For Beginn...What is Artificial Intelligence | Artificial Intelligence Tutorial For Beginn...
What is Artificial Intelligence | Artificial Intelligence Tutorial For Beginn...
 
AI and Machine Learning Demystified by Carol Smith at Midwest UX 2017
AI and Machine Learning Demystified by Carol Smith at Midwest UX 2017AI and Machine Learning Demystified by Carol Smith at Midwest UX 2017
AI and Machine Learning Demystified by Carol Smith at Midwest UX 2017
 

Similar to Code Generation in Perl

Node & Express as Workflow Tools
Node & Express as Workflow ToolsNode & Express as Workflow Tools
Node & Express as Workflow ToolsFITC
 
Programming Paradigm & Languages
Programming Paradigm & LanguagesProgramming Paradigm & Languages
Programming Paradigm & LanguagesGaditek
 
Programming Paradigm & Languages
Programming Paradigm & LanguagesProgramming Paradigm & Languages
Programming Paradigm & LanguagesGaditek
 
The Art of Evolutionary Algorithms Programming
The Art of Evolutionary Algorithms ProgrammingThe Art of Evolutionary Algorithms Programming
The Art of Evolutionary Algorithms ProgrammingJuan J. Merelo
 
ProgFund_Lecture_1_Introduction_to_Programming.pdf
ProgFund_Lecture_1_Introduction_to_Programming.pdfProgFund_Lecture_1_Introduction_to_Programming.pdf
ProgFund_Lecture_1_Introduction_to_Programming.pdflailoesakhan
 
Cd ch1 - introduction
Cd   ch1 - introductionCd   ch1 - introduction
Cd ch1 - introductionmengistu23
 
CD - CH1 - Introduction to compiler design.pptx
CD - CH1 - Introduction to compiler design.pptxCD - CH1 - Introduction to compiler design.pptx
CD - CH1 - Introduction to compiler design.pptxZiyadMohammed17
 
4_5802928814682016556.pptx
4_5802928814682016556.pptx4_5802928814682016556.pptx
4_5802928814682016556.pptxAshenafiGirma5
 
YAPC::NA 2007 - Epic Perl Coding
YAPC::NA 2007 - Epic Perl CodingYAPC::NA 2007 - Epic Perl Coding
YAPC::NA 2007 - Epic Perl Codingjoshua.mcadams
 
Half-automatic Compilable Source Code Recovery
Half-automatic Compilable Source Code RecoveryHalf-automatic Compilable Source Code Recovery
Half-automatic Compilable Source Code RecoveryJoxean Koret
 
Serverless Functions and Machine Learning: Putting the AI in APIs
Serverless Functions and Machine Learning: Putting the AI in APIsServerless Functions and Machine Learning: Putting the AI in APIs
Serverless Functions and Machine Learning: Putting the AI in APIsNordic APIs
 
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)goccy
 
Compiler Design Introduction
Compiler Design IntroductionCompiler Design Introduction
Compiler Design IntroductionKuppusamy P
 
Merged Automation Talk - Pete Carapetyan - Feb 2016
Merged Automation Talk - Pete Carapetyan - Feb 2016 Merged Automation Talk - Pete Carapetyan - Feb 2016
Merged Automation Talk - Pete Carapetyan - Feb 2016 petecarapetyan
 
Compilers and interpreters
Compilers and interpretersCompilers and interpreters
Compilers and interpretersRAJU KATHI
 
Embedded c c++ programming fundamentals master
Embedded c c++ programming fundamentals masterEmbedded c c++ programming fundamentals master
Embedded c c++ programming fundamentals masterHossam Hassan
 

Similar to Code Generation in Perl (20)

C# Fundamental
C# FundamentalC# Fundamental
C# Fundamental
 
Node & Express as Workflow Tools
Node & Express as Workflow ToolsNode & Express as Workflow Tools
Node & Express as Workflow Tools
 
Programming Paradigm & Languages
Programming Paradigm & LanguagesProgramming Paradigm & Languages
Programming Paradigm & Languages
 
Programming Paradigm & Languages
Programming Paradigm & LanguagesProgramming Paradigm & Languages
Programming Paradigm & Languages
 
The Art of Evolutionary Algorithms Programming
The Art of Evolutionary Algorithms ProgrammingThe Art of Evolutionary Algorithms Programming
The Art of Evolutionary Algorithms Programming
 
ProgFund_Lecture_1_Introduction_to_Programming.pdf
ProgFund_Lecture_1_Introduction_to_Programming.pdfProgFund_Lecture_1_Introduction_to_Programming.pdf
ProgFund_Lecture_1_Introduction_to_Programming.pdf
 
Cd ch1 - introduction
Cd   ch1 - introductionCd   ch1 - introduction
Cd ch1 - introduction
 
CD - CH1 - Introduction to compiler design.pptx
CD - CH1 - Introduction to compiler design.pptxCD - CH1 - Introduction to compiler design.pptx
CD - CH1 - Introduction to compiler design.pptx
 
4_5802928814682016556.pptx
4_5802928814682016556.pptx4_5802928814682016556.pptx
4_5802928814682016556.pptx
 
C Language
C LanguageC Language
C Language
 
YAPC::NA 2007 - Epic Perl Coding
YAPC::NA 2007 - Epic Perl CodingYAPC::NA 2007 - Epic Perl Coding
YAPC::NA 2007 - Epic Perl Coding
 
Half-automatic Compilable Source Code Recovery
Half-automatic Compilable Source Code RecoveryHalf-automatic Compilable Source Code Recovery
Half-automatic Compilable Source Code Recovery
 
Serverless Functions and Machine Learning: Putting the AI in APIs
Serverless Functions and Machine Learning: Putting the AI in APIsServerless Functions and Machine Learning: Putting the AI in APIs
Serverless Functions and Machine Learning: Putting the AI in APIs
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
 
Quick Intro to Clean Coding
Quick Intro to Clean CodingQuick Intro to Clean Coding
Quick Intro to Clean Coding
 
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
 
Compiler Design Introduction
Compiler Design IntroductionCompiler Design Introduction
Compiler Design Introduction
 
Merged Automation Talk - Pete Carapetyan - Feb 2016
Merged Automation Talk - Pete Carapetyan - Feb 2016 Merged Automation Talk - Pete Carapetyan - Feb 2016
Merged Automation Talk - Pete Carapetyan - Feb 2016
 
Compilers and interpreters
Compilers and interpretersCompilers and interpreters
Compilers and interpreters
 
Embedded c c++ programming fundamentals master
Embedded c c++ programming fundamentals masterEmbedded c c++ programming fundamentals master
Embedded c c++ programming fundamentals master
 

More from Ian Kluft

"#AprilFools Hijinks" at SVPerl April 2021 meeting
"#AprilFools Hijinks" at SVPerl April 2021 meeting"#AprilFools Hijinks" at SVPerl April 2021 meeting
"#AprilFools Hijinks" at SVPerl April 2021 meetingIan Kluft
 
Secure Coding in Perl
Secure Coding in PerlSecure Coding in Perl
Secure Coding in PerlIan Kluft
 
New Perl module Container::Buildah - SVPerl presentation
New Perl module Container::Buildah - SVPerl presentationNew Perl module Container::Buildah - SVPerl presentation
New Perl module Container::Buildah - SVPerl presentationIan Kluft
 
Securing a Raspberry Pi and other DIY IoT devices
Securing a Raspberry Pi and other DIY IoT devicesSecuring a Raspberry Pi and other DIY IoT devices
Securing a Raspberry Pi and other DIY IoT devicesIan Kluft
 
Best Practices for Recovering Rocket & Balloon Payloads
Best Practices for Recovering Rocket & Balloon PayloadsBest Practices for Recovering Rocket & Balloon Payloads
Best Practices for Recovering Rocket & Balloon PayloadsIan Kluft
 
PiFlash: Linux utility to flash SD cards for Raspberry Pi computers
PiFlash: Linux utility to flash SD cards for Raspberry Pi computersPiFlash: Linux utility to flash SD cards for Raspberry Pi computers
PiFlash: Linux utility to flash SD cards for Raspberry Pi computersIan Kluft
 
Aerospace applications of Perl
Aerospace applications of PerlAerospace applications of Perl
Aerospace applications of PerlIan Kluft
 
Command Line Arguments with Getopt::Long
Command Line Arguments with Getopt::LongCommand Line Arguments with Getopt::Long
Command Line Arguments with Getopt::LongIan Kluft
 
Geographic Computation in Perl
Geographic Computation in PerlGeographic Computation in Perl
Geographic Computation in PerlIan Kluft
 
Black Rock Desert Impact Theory
Black Rock Desert Impact TheoryBlack Rock Desert Impact Theory
Black Rock Desert Impact TheoryIan Kluft
 
Exception Handling in Perl
Exception Handling in PerlException Handling in Perl
Exception Handling in PerlIan Kluft
 
Geographic Computation in Perl
Geographic Computation in PerlGeographic Computation in Perl
Geographic Computation in PerlIan Kluft
 
Stratofox Aerospace Tracking Team presentation at Space Access 2013
Stratofox Aerospace Tracking Team presentation at Space Access 2013Stratofox Aerospace Tracking Team presentation at Space Access 2013
Stratofox Aerospace Tracking Team presentation at Space Access 2013Ian Kluft
 
Pacificon 200905
Pacificon 200905Pacificon 200905
Pacificon 200905Ian Kluft
 

More from Ian Kluft (14)

"#AprilFools Hijinks" at SVPerl April 2021 meeting
"#AprilFools Hijinks" at SVPerl April 2021 meeting"#AprilFools Hijinks" at SVPerl April 2021 meeting
"#AprilFools Hijinks" at SVPerl April 2021 meeting
 
Secure Coding in Perl
Secure Coding in PerlSecure Coding in Perl
Secure Coding in Perl
 
New Perl module Container::Buildah - SVPerl presentation
New Perl module Container::Buildah - SVPerl presentationNew Perl module Container::Buildah - SVPerl presentation
New Perl module Container::Buildah - SVPerl presentation
 
Securing a Raspberry Pi and other DIY IoT devices
Securing a Raspberry Pi and other DIY IoT devicesSecuring a Raspberry Pi and other DIY IoT devices
Securing a Raspberry Pi and other DIY IoT devices
 
Best Practices for Recovering Rocket & Balloon Payloads
Best Practices for Recovering Rocket & Balloon PayloadsBest Practices for Recovering Rocket & Balloon Payloads
Best Practices for Recovering Rocket & Balloon Payloads
 
PiFlash: Linux utility to flash SD cards for Raspberry Pi computers
PiFlash: Linux utility to flash SD cards for Raspberry Pi computersPiFlash: Linux utility to flash SD cards for Raspberry Pi computers
PiFlash: Linux utility to flash SD cards for Raspberry Pi computers
 
Aerospace applications of Perl
Aerospace applications of PerlAerospace applications of Perl
Aerospace applications of Perl
 
Command Line Arguments with Getopt::Long
Command Line Arguments with Getopt::LongCommand Line Arguments with Getopt::Long
Command Line Arguments with Getopt::Long
 
Geographic Computation in Perl
Geographic Computation in PerlGeographic Computation in Perl
Geographic Computation in Perl
 
Black Rock Desert Impact Theory
Black Rock Desert Impact TheoryBlack Rock Desert Impact Theory
Black Rock Desert Impact Theory
 
Exception Handling in Perl
Exception Handling in PerlException Handling in Perl
Exception Handling in Perl
 
Geographic Computation in Perl
Geographic Computation in PerlGeographic Computation in Perl
Geographic Computation in Perl
 
Stratofox Aerospace Tracking Team presentation at Space Access 2013
Stratofox Aerospace Tracking Team presentation at Space Access 2013Stratofox Aerospace Tracking Team presentation at Space Access 2013
Stratofox Aerospace Tracking Team presentation at Space Access 2013
 
Pacificon 200905
Pacificon 200905Pacificon 200905
Pacificon 200905
 

Recently uploaded

VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024Mind IT Systems
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...kalichargn70th171
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfVishalKumarJha10
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfryanfarris8
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...software pro Development
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 

Recently uploaded (20)

VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 

Code Generation in Perl

  • 1. Code Generation in Perl Presentation by Ian Kluft for Silicon Valley Perl September 7, 2017 Santa Clara, California
  • 2. What is Code Generation? ● Programs that write programs ● There are many ways to approach this ● Advantage: lets the coder work at a higher level ● Disadvantage: someone still has to write program
  • 3. The simplest example ● A program hard-coded to print another program ● Even the simple example has non-trivial quoting #!/usr/bin/perl use strict; use warnings; print qq(#!/usr/bin/perln); print qq(use strict;n); print qq(print "hello worldn";n);
  • 4. Other approaches ● Templates – fill in the blanks ● Translators – parse, analyze and re-generate ● Compilers – parse high level, generate lower level ● SQL schemas & queries – generate SQL code ● XML parsing – generate programs from XML data ● UML tools – draw diagrams, generate code
  • 5. CPAN Modules which generate code ● At a low level it’s widespread – Many modules & scripts generate code for eval() ● Perl build tools ● SQL generation for queries and schemas ● Perl application frameworks – Easier to get started with tools that generate examples ● Compilers
  • 6. CPAN Modules Perl build tools ● CPAN Modules which generate code – Dist::Zilla – ExtUtils::MakeMaker – Module::Build ● These generate build scripts from module configuration data
  • 7. CPAN Modules SQL code generation ● DBIx::Class – object relational mapper ● Fey – SQL schema and query generator ● …CPAN is huge - the list goes on and on... ● Many examples – which do you like?
  • 8. CPAN Modules XML & data code generators ● Data::Dumper – dumps data as Perl code ● Faker – extensible fake data generator ● Not as much code generation from XML on CPAN – Obvious category for ad hoc tools – Any XML parser can be used to generate code ● Writing HTML is not technically writing code – But it also has similarities
  • 9. CPAN Modules Compilers ● B::* - access to Perl compiler ● Compiler generation tools – Parse::Yapp/Parse::Eyapp – compiler parser generator ● Similar to Unix “yacc” but generates Perl code – Parse::RecDescent – generate recursive descent compiler – Parse::Lex – generate lexical analyzer for compiler ● A lot of CPAN modules claiming to “compile” actually “translate”
  • 10. How Compilers Work ● High level view of a compiler Preprocessor Scanner/ Tokenizer Parser Semantics ● Preprocessor – macros & text manipulation ● Scanner – generates stream of tokens – Removes comments ● Parser – recognizes language structures ● Semantics – generate code – Some compilers like Perl make intermediate code for interpretation
  • 11. Using Parser Generator Tools ● Have you noticed that language compilers do things that are way above the capabilities of regular expressions? – RegEx’es are ideal for tokenizers/scanners – There’s another level of language parsing above that ● One example is to grab a yacc grammar and translate it to Parse::Yapp or Parse::Eyapp – I did that once for a Perl script that parsed /etc/sudoers files for automated security audits ● Language definitions in Backus-Naur Form (BNF) can be converted to language parser defintions
  • 12. UML Unified Modeling Language ● XML format representing standard diagrams – Parts of a program or system design – Analysis of code can generate UML for documentation – Active research into ways to generate code from UML ● Code generation can be done ● But diagramming is far more tedious than typing code ● You can experiment with this on your own projects ● Idea is to use UML as design/documentation & generate code
  • 13. UML – Unified Modeling Language types of diagrams Diagram Class Diagram Component Diagram Object Diagram Activity Diagram Use Case Diagram Profile Diagram Composite Structure Diagram Deployment Diagram Package Diagram Interaction Diagram State Machine Diagram Sequence Diagram Communication Diagram Interaction Overview Diagram Timing Diagram Notation: UML Behaviour Diagram Structure Diagram UML diagram types – as a class diagram (from Wikipedia)
  • 14. UML – Unified Modeling Language example class: Pizza UML code generation makes class source code starter templates for ● Pizza ● CrustEnum ● ToppingList ● ToppingEnum ● SizeEnum How would you go from here to write the code for the classes in UML? Good ways to do that are still open to suggestion.
  • 15. UML – Unified Modeling Language Tools for Code Generation from UML ● Open source “umbrello” from KDE generated previous slide’s graphic ● Eclipse IDE has UML generation tools ● CPAN has many UML modules, mostly for generating UML from Perl for analysis ● Many other examples...
  • 16. Setting expectations What a non-engineer manager wants… This one doesn’t grasp the current limitations. He isn’t alone. What people want is often a hint where research should push the limits for the future.
  • 17. Setting expectations ”Artificial Intelligence” ● Artificial Intelligence has a broken promise built right into its name ● It has always been advanced algorithms – It’s always non-trivial – Not all uses of the term AI are as sophisticated as claimed ● Its results usually appear clever ● It can do lots of things people don’t do well ● But it still can’t think ● It isn’t real or artificial intelligence… yet
  • 18. Science Fiction examples Code generation and AI ● One early SciFi story: “The Adolescence of P1” by Thomas J Ryan, 1977 ● Based on modem-connected IBM 360 mainframes ● Program to break OS “supervisor” – Needed decision trees, code generator, threat analysis – When told to shut down it played dead, kept running – AI evolved organically – Installed itself like a worm, broke OS like a virus ● Few SciFi AI’s attempted such depth
  • 19. Code Generation Setting expectations back to reality ● SciFi myths need to be debunked ● Code generation just adds a level of abstraction ● Someone still has to write the code ● Short of an actual artificial intelligence, programs won’t be writing programs any time soon ● Maybe during 21st Century? – 20th Century showed how much advancement can happen – But AI is a fundamentally difficult computing challenge – Don’t count on it