SlideShare a Scribd company logo
1 of 25
Getting Groovy
JVM Languages Java JRuby Jython
JVM Languages Java JRuby Jython
JVM Languages Java JRuby Jython Groovy
Two Worlds Collide Java Perl
Two Worlds Collide Java Perl
Two Worlds Collide Java Perl
Two Worlds Collide Java Perl
Slurping files in Perl
Slurping files in Perl my $fh = open '<', $filename; local $/ = undef; my $contents = <$fh>;
Slurping files in Perl my $fh = open '<', $filename; local $/ = undef; my $contents = <$fh>; Slurping in Ruby
Slurping files in Perl my $fh = open '<', $filename; local $/ = undef; my $contents = <$fh>; Slurping in Ruby file = File.open(filename, "rb") contents = file.read
Java?
Java? StringBuilder contents = new StringBuilder(); try {   BufferedReader input = new BufferedReader(new FileReader(aFile)); 	try { 		String line = null;  		while ( (line = input.readLine()) != null) { 		    contents.append(line); 		    contents.append(lineSeparator); 		} 	} finally { input.close();	} } catch (IOException ex) { ex.printStackTrace(); } ... = contents.toString();
Java’s True Character
Java’s True Character
What would Groovy do?
What would Groovy do? def contents = new File(filename) …
What would Groovy do? def contents = new File(filename) .text
XML Parsing <langs type="current"> 	<language>Perl</language> 	<language>Java</language> 	<language>Groovy</language></langs>
XML Parsing <langs type="current"> 	<language>Perl</language> 	<language>Java</language> 	<language>Groovy</language></langs> import org.w3c.dom.*; import org.xml.sax.SAXException; import javax.xml.parsers.*; import java.io.IOException;
XML Parsing <langs type="current"> 	<language>Perl</language> 	<language>Java</language> 	<language>Groovy</language></langs> public class ParseXml {     public static void main(String[] args) {         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();         try { 	    DocumentBuilder db = dbf.newDocumentBuilder(); 	    Document doc = db.parse(“langs.xml"); 	    Element langs = doc.getDocumentElement(); 	    System.out.println("type = " + langs.getAttribute("type")); 	    NodeList list = langs.getElementsByTagName("language"); 	    for(int i=0; i < list.getLength(); i++) { 	        Element language = (Element) list.item(i); 	        System.out.println(language.getTextContent()); 	    }         } catch(ParserConfigurationException pce) { pce.printStackTrace(); }           catch(SAXException se) { se.printStackTrace(); }           catch(IOException ioe) { ioe.printStackTrace(); }         }     } }
XML Parsing in Groovy <langs type="current"> 	<language>Perl</language> 	<language>Java</language> 	<language>Groovy</language></langs>
XML Parsing in Groovy <langs type="current"> 	<language>Perl</language> 	<language>Java</language> 	<language>Groovy</language></langs> def langs = new XmlSlurper().parse("langs.xml") println langs.@type langs.language.each { elem ->     println elem }
XML Parsing in Groovy <langs type="current"> 	<language>Perl</language> 	<language>Java</language> 	<language>Groovy</language></langs> def langs = new XmlSlurper().parse("langs.xml") println langs.@type langs.language.each {     println it }

More Related Content

What's hot

Logrotate sh
Logrotate shLogrotate sh
Logrotate shBen Pope
 
Control your Voice like a Bene Gesserit
Control your Voice like a Bene GesseritControl your Voice like a Bene Gesserit
Control your Voice like a Bene GesseritJorge Ortiz
 
Php File Operations
Php File OperationsPhp File Operations
Php File Operationsmussawir20
 
TDC São Paulo 2016 - Become a jedi with php streams
TDC São Paulo 2016 - Become a jedi with php streamsTDC São Paulo 2016 - Become a jedi with php streams
TDC São Paulo 2016 - Become a jedi with php streamsMatheus Marabesi
 
It’s about time to embrace Streams (Node Ukraine 2019)
 It’s about time to embrace Streams (Node Ukraine 2019) It’s about time to embrace Streams (Node Ukraine 2019)
It’s about time to embrace Streams (Node Ukraine 2019)Luciano Mammino
 
"It’s about time to embrace Streams" Luciano Mammino
"It’s about time to embrace Streams" Luciano Mammino"It’s about time to embrace Streams" Luciano Mammino
"It’s about time to embrace Streams" Luciano MamminoJulia Cherniak
 
Groovy on the Shell
Groovy on the ShellGroovy on the Shell
Groovy on the Shellsascha_klein
 
Using the Power to Prove
Using the Power to ProveUsing the Power to Prove
Using the Power to ProveKazuho Oku
 
Unix Programming with Perl
Unix Programming with PerlUnix Programming with Perl
Unix Programming with PerlKazuho Oku
 
PyCon 2013 : Scripting to PyPi to GitHub and More
PyCon 2013 : Scripting to PyPi to GitHub and MorePyCon 2013 : Scripting to PyPi to GitHub and More
PyCon 2013 : Scripting to PyPi to GitHub and MoreMatt Harrison
 
Learning go for perl programmers
Learning go for perl programmersLearning go for perl programmers
Learning go for perl programmersFred Moyer
 
On secure application of PHP wrappers
On secure application  of PHP wrappersOn secure application  of PHP wrappers
On secure application of PHP wrappersPositive Hack Days
 
Devinsampa nginx-scripting
Devinsampa nginx-scriptingDevinsampa nginx-scripting
Devinsampa nginx-scriptingTony Fabeen
 
Redis is not just a cache, Andrew Lavers, ConFoo Montreal 2020
Redis is not just a cache, Andrew Lavers, ConFoo Montreal 2020Redis is not just a cache, Andrew Lavers, ConFoo Montreal 2020
Redis is not just a cache, Andrew Lavers, ConFoo Montreal 2020Andrew Lavers
 

What's hot (20)

Logrotate sh
Logrotate shLogrotate sh
Logrotate sh
 
Control your Voice like a Bene Gesserit
Control your Voice like a Bene GesseritControl your Voice like a Bene Gesserit
Control your Voice like a Bene Gesserit
 
Cpp lab 13_pres
Cpp lab 13_presCpp lab 13_pres
Cpp lab 13_pres
 
Php File Operations
Php File OperationsPhp File Operations
Php File Operations
 
TDC São Paulo 2016 - Become a jedi with php streams
TDC São Paulo 2016 - Become a jedi with php streamsTDC São Paulo 2016 - Become a jedi with php streams
TDC São Paulo 2016 - Become a jedi with php streams
 
Php extensions
Php extensionsPhp extensions
Php extensions
 
It’s about time to embrace Streams (Node Ukraine 2019)
 It’s about time to embrace Streams (Node Ukraine 2019) It’s about time to embrace Streams (Node Ukraine 2019)
It’s about time to embrace Streams (Node Ukraine 2019)
 
"It’s about time to embrace Streams" Luciano Mammino
"It’s about time to embrace Streams" Luciano Mammino"It’s about time to embrace Streams" Luciano Mammino
"It’s about time to embrace Streams" Luciano Mammino
 
Groovy on the Shell
Groovy on the ShellGroovy on the Shell
Groovy on the Shell
 
Using the Power to Prove
Using the Power to ProveUsing the Power to Prove
Using the Power to Prove
 
php file uploading
php file uploadingphp file uploading
php file uploading
 
Unix Programming with Perl
Unix Programming with PerlUnix Programming with Perl
Unix Programming with Perl
 
PyCon 2013 : Scripting to PyPi to GitHub and More
PyCon 2013 : Scripting to PyPi to GitHub and MorePyCon 2013 : Scripting to PyPi to GitHub and More
PyCon 2013 : Scripting to PyPi to GitHub and More
 
Php extensions
Php extensionsPhp extensions
Php extensions
 
Php File Operations
Php File OperationsPhp File Operations
Php File Operations
 
Perl Basics for Pentesters Part 1
Perl Basics for Pentesters Part 1Perl Basics for Pentesters Part 1
Perl Basics for Pentesters Part 1
 
Learning go for perl programmers
Learning go for perl programmersLearning go for perl programmers
Learning go for perl programmers
 
On secure application of PHP wrappers
On secure application  of PHP wrappersOn secure application  of PHP wrappers
On secure application of PHP wrappers
 
Devinsampa nginx-scripting
Devinsampa nginx-scriptingDevinsampa nginx-scripting
Devinsampa nginx-scripting
 
Redis is not just a cache, Andrew Lavers, ConFoo Montreal 2020
Redis is not just a cache, Andrew Lavers, ConFoo Montreal 2020Redis is not just a cache, Andrew Lavers, ConFoo Montreal 2020
Redis is not just a cache, Andrew Lavers, ConFoo Montreal 2020
 

Viewers also liked

реферати, контрольні, курсові та дипломні роботи
реферати, контрольні, курсові та дипломні роботиреферати, контрольні, курсові та дипломні роботи
реферати, контрольні, курсові та дипломні роботиSashylka
 
บทที่+7
บทที่+7บทที่+7
บทที่+7paynarumon
 
Madal kõrge
Madal kõrgeMadal kõrge
Madal kõrgemeelimae
 
Tutorial bikin blog
Tutorial bikin blogTutorial bikin blog
Tutorial bikin blogGagaz Ngawi
 
PANTALLAZOS
PANTALLAZOSPANTALLAZOS
PANTALLAZOSanacar
 
Saukon Taivaspaikka ja Creative Commons
Saukon Taivaspaikka ja Creative CommonsSaukon Taivaspaikka ja Creative Commons
Saukon Taivaspaikka ja Creative CommonsLinda Saukko-Rauta
 
AFL7020 (Θεωρία): Εισαγωγικές έννοιες
AFL7020 (Θεωρία): Εισαγωγικές έννοιεςAFL7020 (Θεωρία): Εισαγωγικές έννοιες
AFL7020 (Θεωρία): Εισαγωγικές έννοιεςAchilleas Kostoulas
 
איך השתנה מערך מקורות הגיוס
איך השתנה מערך מקורות הגיוסאיך השתנה מערך מקורות הגיוס
איך השתנה מערך מקורות הגיוסMorit Rozen
 
A formação do império feudal 7º anos
A formação do império feudal   7º anosA formação do império feudal   7º anos
A formação do império feudal 7º anosÍris Ferreira
 
Musiikin näkymatön oppiminen
Musiikin näkymatön oppiminenMusiikin näkymatön oppiminen
Musiikin näkymatön oppiminenTero Toivanen
 
욕하는 청소년, 그들의 심리
욕하는 청소년, 그들의 심리욕하는 청소년, 그들의 심리
욕하는 청소년, 그들의 심리ChansunP
 

Viewers also liked (20)

Leito
LeitoLeito
Leito
 
реферати, контрольні, курсові та дипломні роботи
реферати, контрольні, курсові та дипломні роботиреферати, контрольні, курсові та дипломні роботи
реферати, контрольні, курсові та дипломні роботи
 
授業プレゼン
授業プレゼン授業プレゼン
授業プレゼン
 
บทที่+7
บทที่+7บทที่+7
บทที่+7
 
Madal kõrge
Madal kõrgeMadal kõrge
Madal kõrge
 
Hola mundo
Hola mundoHola mundo
Hola mundo
 
溝通升級版201005
溝通升級版201005溝通升級版201005
溝通升級版201005
 
Tutorial bikin blog
Tutorial bikin blogTutorial bikin blog
Tutorial bikin blog
 
Arte
ArteArte
Arte
 
PANTALLAZOS
PANTALLAZOSPANTALLAZOS
PANTALLAZOS
 
Els assajos
Els assajosEls assajos
Els assajos
 
Saukon Taivaspaikka ja Creative Commons
Saukon Taivaspaikka ja Creative CommonsSaukon Taivaspaikka ja Creative Commons
Saukon Taivaspaikka ja Creative Commons
 
Vidensmedier 26.9.2011
Vidensmedier 26.9.2011Vidensmedier 26.9.2011
Vidensmedier 26.9.2011
 
AFL7020 (Θεωρία): Εισαγωγικές έννοιες
AFL7020 (Θεωρία): Εισαγωγικές έννοιεςAFL7020 (Θεωρία): Εισαγωγικές έννοιες
AFL7020 (Θεωρία): Εισαγωγικές έννοιες
 
איך השתנה מערך מקורות הגיוס
איך השתנה מערך מקורות הגיוסאיך השתנה מערך מקורות הגיוס
איך השתנה מערך מקורות הגיוס
 
A formação do império feudal 7º anos
A formação do império feudal   7º anosA formação do império feudal   7º anos
A formação do império feudal 7º anos
 
Hindi janlokpal
Hindi janlokpalHindi janlokpal
Hindi janlokpal
 
Musiikin näkymatön oppiminen
Musiikin näkymatön oppiminenMusiikin näkymatön oppiminen
Musiikin näkymatön oppiminen
 
욕하는 청소년, 그들의 심리
욕하는 청소년, 그들의 심리욕하는 청소년, 그들의 심리
욕하는 청소년, 그들의 심리
 
Sebastião freitas lima
Sebastião freitas limaSebastião freitas lima
Sebastião freitas lima
 

Similar to Getting groovy

2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Ws2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Wsloffenauer
 
Perl Xpath Lightning Talk
Perl Xpath Lightning TalkPerl Xpath Lightning Talk
Perl Xpath Lightning Talkddn123456
 
Using DAOs without implementing them
Using DAOs without implementing themUsing DAOs without implementing them
Using DAOs without implementing thembenfante
 
Zendcon 2007 Features
Zendcon 2007 FeaturesZendcon 2007 Features
Zendcon 2007 Featuresfivespeed5
 
Php Simple Xml
Php Simple XmlPhp Simple Xml
Php Simple Xmlmussawir20
 
What's new in Perl 5.10?
What's new in Perl 5.10?What's new in Perl 5.10?
What's new in Perl 5.10?acme
 
Php Training
Php TrainingPhp Training
Php Trainingadfa
 
Writing Friendly libraries for CodeIgniter
Writing Friendly libraries for CodeIgniterWriting Friendly libraries for CodeIgniter
Writing Friendly libraries for CodeIgniterCodeIgniter Conference
 
Douglas Crockford Presentation Jsonsaga
Douglas Crockford Presentation JsonsagaDouglas Crockford Presentation Jsonsaga
Douglas Crockford Presentation JsonsagaAjax Experience 2009
 
Jsonsaga
JsonsagaJsonsaga
Jsonsaganohmad
 
Good Evils In Perl
Good Evils In PerlGood Evils In Perl
Good Evils In PerlKang-min Liu
 
Python - Getting to the Essence - Points.com - Dave Park
Python - Getting to the Essence - Points.com - Dave ParkPython - Getting to the Essence - Points.com - Dave Park
Python - Getting to the Essence - Points.com - Dave Parkpointstechgeeks
 
Maybe you do not know that ...
Maybe you do not know that ...Maybe you do not know that ...
Maybe you do not know that ...Viktor Turskyi
 

Similar to Getting groovy (20)

Perl Moderno
Perl ModernoPerl Moderno
Perl Moderno
 
Web Scraping with PHP
Web Scraping with PHPWeb Scraping with PHP
Web Scraping with PHP
 
2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Ws2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Ws
 
Perl Xpath Lightning Talk
Perl Xpath Lightning TalkPerl Xpath Lightning Talk
Perl Xpath Lightning Talk
 
Using DAOs without implementing them
Using DAOs without implementing themUsing DAOs without implementing them
Using DAOs without implementing them
 
Zendcon 2007 Features
Zendcon 2007 FeaturesZendcon 2007 Features
Zendcon 2007 Features
 
Php Simple Xml
Php Simple XmlPhp Simple Xml
Php Simple Xml
 
What's new in Perl 5.10?
What's new in Perl 5.10?What's new in Perl 5.10?
What's new in Perl 5.10?
 
PHP
PHP PHP
PHP
 
Php
PhpPhp
Php
 
Php Training
Php TrainingPhp Training
Php Training
 
spug_2008-08
spug_2008-08spug_2008-08
spug_2008-08
 
Writing Friendly libraries for CodeIgniter
Writing Friendly libraries for CodeIgniterWriting Friendly libraries for CodeIgniter
Writing Friendly libraries for CodeIgniter
 
Modern Perl
Modern PerlModern Perl
Modern Perl
 
Douglas Crockford Presentation Jsonsaga
Douglas Crockford Presentation JsonsagaDouglas Crockford Presentation Jsonsaga
Douglas Crockford Presentation Jsonsaga
 
Jsonsaga
JsonsagaJsonsaga
Jsonsaga
 
Good Evils In Perl
Good Evils In PerlGood Evils In Perl
Good Evils In Perl
 
Python - Getting to the Essence - Points.com - Dave Park
Python - Getting to the Essence - Points.com - Dave ParkPython - Getting to the Essence - Points.com - Dave Park
Python - Getting to the Essence - Points.com - Dave Park
 
Perl basics for Pentesters
Perl basics for PentestersPerl basics for Pentesters
Perl basics for Pentesters
 
Maybe you do not know that ...
Maybe you do not know that ...Maybe you do not know that ...
Maybe you do not know that ...
 

Recently uploaded

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 

Recently uploaded (20)

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 

Getting groovy

  • 2. JVM Languages Java JRuby Jython
  • 3. JVM Languages Java JRuby Jython
  • 4. JVM Languages Java JRuby Jython Groovy
  • 5. Two Worlds Collide Java Perl
  • 6. Two Worlds Collide Java Perl
  • 7. Two Worlds Collide Java Perl
  • 8. Two Worlds Collide Java Perl
  • 10. Slurping files in Perl my $fh = open '<', $filename; local $/ = undef; my $contents = <$fh>;
  • 11. Slurping files in Perl my $fh = open '<', $filename; local $/ = undef; my $contents = <$fh>; Slurping in Ruby
  • 12. Slurping files in Perl my $fh = open '<', $filename; local $/ = undef; my $contents = <$fh>; Slurping in Ruby file = File.open(filename, "rb") contents = file.read
  • 13. Java?
  • 14. Java? StringBuilder contents = new StringBuilder(); try { BufferedReader input = new BufferedReader(new FileReader(aFile)); try { String line = null; while ( (line = input.readLine()) != null) { contents.append(line); contents.append(lineSeparator); } } finally { input.close(); } } catch (IOException ex) { ex.printStackTrace(); } ... = contents.toString();
  • 18. What would Groovy do? def contents = new File(filename) …
  • 19. What would Groovy do? def contents = new File(filename) .text
  • 20. XML Parsing <langs type="current"> <language>Perl</language> <language>Java</language> <language>Groovy</language></langs>
  • 21. XML Parsing <langs type="current"> <language>Perl</language> <language>Java</language> <language>Groovy</language></langs> import org.w3c.dom.*; import org.xml.sax.SAXException; import javax.xml.parsers.*; import java.io.IOException;
  • 22. XML Parsing <langs type="current"> <language>Perl</language> <language>Java</language> <language>Groovy</language></langs> public class ParseXml { public static void main(String[] args) { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); try { DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(“langs.xml"); Element langs = doc.getDocumentElement(); System.out.println("type = " + langs.getAttribute("type")); NodeList list = langs.getElementsByTagName("language"); for(int i=0; i < list.getLength(); i++) { Element language = (Element) list.item(i); System.out.println(language.getTextContent()); } } catch(ParserConfigurationException pce) { pce.printStackTrace(); } catch(SAXException se) { se.printStackTrace(); } catch(IOException ioe) { ioe.printStackTrace(); } } } }
  • 23. XML Parsing in Groovy <langs type="current"> <language>Perl</language> <language>Java</language> <language>Groovy</language></langs>
  • 24. XML Parsing in Groovy <langs type="current"> <language>Perl</language> <language>Java</language> <language>Groovy</language></langs> def langs = new XmlSlurper().parse("langs.xml") println langs.@type langs.language.each { elem -> println elem }
  • 25. XML Parsing in Groovy <langs type="current"> <language>Perl</language> <language>Java</language> <language>Groovy</language></langs> def langs = new XmlSlurper().parse("langs.xml") println langs.@type langs.language.each { println it }
  • 26. Configuration foo { port = 80 bar { baz { some.thing = "burp" } } } def config = new ConfigSlurper().parse(...) def config = new ConfigSlurper() .parse(new File("config.groovy").toURL()) assert config.foo.port == 80 assert config.foo.bar.baz.some.thing == "burp"
  • 27. Environment Configuration foo.bar = "baz" something.else = 99 environments { development { port = 8181 db = "devdb" } test { port = 8080 db = "testdb" } production { port = 80 db = "proddb" } } ConfigSlurper("production")

Editor's Notes

  1. Wait – that’s too verbose…
  2. “it” is shorthand – a default parameter, like Perl’s $_