SlideShare une entreprise Scribd logo
1  sur  20
Télécharger pour lire hors ligne
Groovy: a Scripting
 Language for Java
        Charles Anderson
    Western Skies Consulting
  cander@westernskiesweb.com
Outline

• Introduction and Context
• Stupid Pet Tricks
• Using Groovy in a Java project
• Conclusion
• Grails?
Introduction
• There are now many dynamic and/or
  scripting languages that run on the Java
  Platform
• Groovy is a scripting language specifically for
  the Java Platform - feature-rich, Java-friendly
• Groovy compiles to Java classes & byte
  code - can use all of Java Platform
Introduction

• Scripting - don’t have to explicitly compile
• Typing - static or dynamic (optional/duck)
• Mature - version 1.5, 1.6 Beta 2
 • Books, websites, commercial backing, JSR
• IDE Support
Code Comparison


 Groovy     Groovy


Java          Java


 Syntax   Functionality
Java or Groovy?
class Book {
  private String title;
  Book (String theTitle) {
    title = theTitle;
  }
  String getTitle() {
    return title
  }
}
Stupid Pet Tricks
public class Main {
  public static void main(...)
    System.out.println(“Hello
    World”);
  }}

println ‘Hello World’
More Powerful Switch
switch   (x) {
  case   0:     // single int
  case   1..9: // range
  case   [11,13,17]: // list
  case   Float: // type check
  case   ‘cat’: // string
  case   ~/[A-Z][0-9]/: //regexp
}
Groovy Beans
public class MyBean implements
Serializable {
  private String myProp;
  public String getMyProp()...
  public void setMyProp(...)...
}
class MyBean implements Serializable {
  String myProp;
}
Terse NPE Safety

if (x!=null && x.y!=null) {
  z = x.y.z;
}

z = x?.y?.z
Bob the Builder
writer = new FileWriter(‘bob.html’)
def page = new MarkupBuilder(writer)
page.html{
  head { title ‘An HTML Page’ }
  body {
    h1 ‘The big heading’
    form (action:’submit’) {
      input(type:’checkbox’, id:’yes’)
      input(type:’checkbox’, id:’no’)
}}}
Closures
• A closure is a chunk of code that is a first-
  class entity/object in the language
  • From functional programming
• Can accept parameters and return a value
• Typical Java solution: inner classes, visitor
  pattern, template method pattern
Exorcising Inner
       Classes
t = new Thread(new Runable() {
  public void run() {
    // some code
  }});
t.start();

Thread.start { //some code }
Java Iteration
for (Iterator it=coll.iterator();
     it.hasNext(); ) {
  Item item=(Item)it.next();
  //some code
}

for (Item item : coll) {
  // some code
}
Groovy Iteration

coll.each(item-> // some code)

coll.findAll(it % 2 == 0).each(...)

new File(‘foo.txt’).eachLine {
                       println it }
Embrace and Extend
• Groovy “extends” Java classes - GDK
 • Object, GString, Collections, Files,
    Threads, Beans
• Groovy enhances existing Java tools
 • JUnit, Ant, Swing
• Reduce tedious boiler-plate - DRY
using Groovy

• Little development tasks - automation
 • Can script COM and Windows
• Experiments and spiking
• Testing - unit tests, data loading, scaffolding
Conclusion
• Groovy is a dynamic scripting language that
  is designed specifically for Java
• Lots of “tricks” to make life easier, but they
  can be introduced gradually
• Groovy is a playground for the future of
  Java - e.g., closures, properties
• Questions, job leads, Grails?
Grails: Groovy on Rails
• Accelerate and simplify web development
  on the Java Platform - but not Java Language
 • Deploys as a WAR file
• MVC structure
• Convention over configuration
• Uses Spring and Hibernate under covers
Grails Commands
Usage: grails command
  create-app
  run-app
  create-domain-class Entity
  generate-all Entity
  generate-webtest
  run-webtest
  war

Contenu connexe

Tendances

Web technologies for desktop development
Web technologies for desktop developmentWeb technologies for desktop development
Web technologies for desktop developmentDarko Kukovec
 
Groovy for java developers
Groovy for java developersGroovy for java developers
Groovy for java developersPuneet Behl
 
TDC2016POA | Trilha Programacao Funcional - Considere usar Clojure/ClojureScr...
TDC2016POA | Trilha Programacao Funcional - Considere usar Clojure/ClojureScr...TDC2016POA | Trilha Programacao Funcional - Considere usar Clojure/ClojureScr...
TDC2016POA | Trilha Programacao Funcional - Considere usar Clojure/ClojureScr...tdc-globalcode
 
10 reasons to be excited about go
10 reasons to be excited about go10 reasons to be excited about go
10 reasons to be excited about goDvir Volk
 
Fundamental of Node.JS - Internship Presentation - Week7
Fundamental of Node.JS - Internship Presentation - Week7Fundamental of Node.JS - Internship Presentation - Week7
Fundamental of Node.JS - Internship Presentation - Week7Devang Garach
 
PHP & MySQL: PDO x MySQLi
PHP & MySQL: PDO x MySQLiPHP & MySQL: PDO x MySQLi
PHP & MySQL: PDO x MySQLiMarcos Marcolin
 
My talk on Piter Py 2016
My talk on Piter Py 2016My talk on Piter Py 2016
My talk on Piter Py 2016Alex Chistyakov
 
WebCamp 2016: PHP.Алексей Петров.PHP at Scale: System Architect Toolbox
WebCamp 2016: PHP.Алексей Петров.PHP at Scale: System Architect ToolboxWebCamp 2016: PHP.Алексей Петров.PHP at Scale: System Architect Toolbox
WebCamp 2016: PHP.Алексей Петров.PHP at Scale: System Architect ToolboxWebCamp
 
GDB: A Lot More Than You Knew
GDB: A Lot More Than You KnewGDB: A Lot More Than You Knew
GDB: A Lot More Than You KnewUndo
 
Ruby on Docker
Ruby on DockerRuby on Docker
Ruby on Dockerjasnow
 
Why use JavaScript in Hardware? GoTo Conf - Berlin
Why use JavaScript in Hardware? GoTo Conf - Berlin Why use JavaScript in Hardware? GoTo Conf - Berlin
Why use JavaScript in Hardware? GoTo Conf - Berlin TechnicalMachine
 
Give me 15 minutes and i'll change your view of gdb
Give me 15 minutes and i'll change your view of gdbGive me 15 minutes and i'll change your view of gdb
Give me 15 minutes and i'll change your view of gdbgregthelaw
 
Writing NetBSD Sound Drivers in Haskell
Writing NetBSD Sound Drivers in HaskellWriting NetBSD Sound Drivers in Haskell
Writing NetBSD Sound Drivers in HaskellKiwamu Okabe
 
A Look at Command Line Swift
A Look at Command Line SwiftA Look at Command Line Swift
A Look at Command Line SwiftJoshuaKaplan22
 

Tendances (20)

Web technologies for desktop development
Web technologies for desktop developmentWeb technologies for desktop development
Web technologies for desktop development
 
Groovy for java developers
Groovy for java developersGroovy for java developers
Groovy for java developers
 
TDC2016POA | Trilha Programacao Funcional - Considere usar Clojure/ClojureScr...
TDC2016POA | Trilha Programacao Funcional - Considere usar Clojure/ClojureScr...TDC2016POA | Trilha Programacao Funcional - Considere usar Clojure/ClojureScr...
TDC2016POA | Trilha Programacao Funcional - Considere usar Clojure/ClojureScr...
 
Revealing ALLSTOCKER
Revealing ALLSTOCKERRevealing ALLSTOCKER
Revealing ALLSTOCKER
 
10 reasons to be excited about go
10 reasons to be excited about go10 reasons to be excited about go
10 reasons to be excited about go
 
Fundamental of Node.JS - Internship Presentation - Week7
Fundamental of Node.JS - Internship Presentation - Week7Fundamental of Node.JS - Internship Presentation - Week7
Fundamental of Node.JS - Internship Presentation - Week7
 
Tangram
TangramTangram
Tangram
 
PHP & MySQL: PDO x MySQLi
PHP & MySQL: PDO x MySQLiPHP & MySQL: PDO x MySQLi
PHP & MySQL: PDO x MySQLi
 
My talk on Piter Py 2016
My talk on Piter Py 2016My talk on Piter Py 2016
My talk on Piter Py 2016
 
WebCamp 2016: PHP.Алексей Петров.PHP at Scale: System Architect Toolbox
WebCamp 2016: PHP.Алексей Петров.PHP at Scale: System Architect ToolboxWebCamp 2016: PHP.Алексей Петров.PHP at Scale: System Architect Toolbox
WebCamp 2016: PHP.Алексей Петров.PHP at Scale: System Architect Toolbox
 
GDB: A Lot More Than You Knew
GDB: A Lot More Than You KnewGDB: A Lot More Than You Knew
GDB: A Lot More Than You Knew
 
Ruby on Docker
Ruby on DockerRuby on Docker
Ruby on Docker
 
NodeJS
NodeJSNodeJS
NodeJS
 
Nodejs presentation
Nodejs presentationNodejs presentation
Nodejs presentation
 
Why use JavaScript in Hardware? GoTo Conf - Berlin
Why use JavaScript in Hardware? GoTo Conf - Berlin Why use JavaScript in Hardware? GoTo Conf - Berlin
Why use JavaScript in Hardware? GoTo Conf - Berlin
 
Give me 15 minutes and i'll change your view of gdb
Give me 15 minutes and i'll change your view of gdbGive me 15 minutes and i'll change your view of gdb
Give me 15 minutes and i'll change your view of gdb
 
Writing NetBSD Sound Drivers in Haskell
Writing NetBSD Sound Drivers in HaskellWriting NetBSD Sound Drivers in Haskell
Writing NetBSD Sound Drivers in Haskell
 
A Look at Command Line Swift
A Look at Command Line SwiftA Look at Command Line Swift
A Look at Command Line Swift
 
Node.js and Ruby
Node.js and RubyNode.js and Ruby
Node.js and Ruby
 
NodeJS
NodeJSNodeJS
NodeJS
 

En vedette

December 2 General Meeting
December 2 General MeetingDecember 2 General Meeting
December 2 General MeetingMSU PRSSA
 
一流企业员工应具备的心态
一流企业员工应具备的心态一流企业员工应具备的心态
一流企业员工应具备的心态20004
 
企业人力资源管理
企业人力资源管理企业人力资源管理
企业人力资源管理20004
 
职业经理人的心态与解压
职业经理人的心态与解压职业经理人的心态与解压
职业经理人的心态与解压20004
 
现代商务礼仪指引
现代商务礼仪指引现代商务礼仪指引
现代商务礼仪指引20004
 
It Service Green Tech V5webprint
It Service Green Tech V5webprintIt Service Green Tech V5webprint
It Service Green Tech V5webprintmanavsingh
 
聚成团队复制之人员招聘
聚成团队复制之人员招聘聚成团队复制之人员招聘
聚成团队复制之人员招聘20004
 
启迪培训公司
启迪培训公司启迪培训公司
启迪培训公司20004
 
Seven Habits
Seven HabitsSeven Habits
Seven Habits20004
 
择业心态
择业心态择业心态
择业心态20004
 
团队建设
团队建设团队建设
团队建设20004
 
Intro To Design Kitchen Bath
Intro To Design Kitchen BathIntro To Design Kitchen Bath
Intro To Design Kitchen BathJABVAB
 
职前培训安排(好)
职前培训安排(好)职前培训安排(好)
职前培训安排(好)20004
 
《跟你的产品谈恋爱》
《跟你的产品谈恋爱》《跟你的产品谈恋爱》
《跟你的产品谈恋爱》20004
 
研发中心08年度计划书打印版
研发中心08年度计划书打印版研发中心08年度计划书打印版
研发中心08年度计划书打印版20004
 
Docker - Hack Salem! - November 2014
Docker - Hack Salem! - November 2014Docker - Hack Salem! - November 2014
Docker - Hack Salem! - November 2014Charles Anderson
 

En vedette (20)

Literate Programming
Literate ProgrammingLiterate Programming
Literate Programming
 
December 2 General Meeting
December 2 General MeetingDecember 2 General Meeting
December 2 General Meeting
 
一流企业员工应具备的心态
一流企业员工应具备的心态一流企业员工应具备的心态
一流企业员工应具备的心态
 
企业人力资源管理
企业人力资源管理企业人力资源管理
企业人力资源管理
 
职业经理人的心态与解压
职业经理人的心态与解压职业经理人的心态与解压
职业经理人的心态与解压
 
现代商务礼仪指引
现代商务礼仪指引现代商务礼仪指引
现代商务礼仪指引
 
It Service Green Tech V5webprint
It Service Green Tech V5webprintIt Service Green Tech V5webprint
It Service Green Tech V5webprint
 
聚成团队复制之人员招聘
聚成团队复制之人员招聘聚成团队复制之人员招聘
聚成团队复制之人员招聘
 
启迪培训公司
启迪培训公司启迪培训公司
启迪培训公司
 
Seven Habits
Seven HabitsSeven Habits
Seven Habits
 
择业心态
择业心态择业心态
择业心态
 
团队建设
团队建设团队建设
团队建设
 
Intro To Design Kitchen Bath
Intro To Design Kitchen BathIntro To Design Kitchen Bath
Intro To Design Kitchen Bath
 
7
77
7
 
Clip
ClipClip
Clip
 
职前培训安排(好)
职前培训安排(好)职前培训安排(好)
职前培训安排(好)
 
《跟你的产品谈恋爱》
《跟你的产品谈恋爱》《跟你的产品谈恋爱》
《跟你的产品谈恋爱》
 
研发中心08年度计划书打印版
研发中心08年度计划书打印版研发中心08年度计划书打印版
研发中心08年度计划书打印版
 
1
11
1
 
Docker - Hack Salem! - November 2014
Docker - Hack Salem! - November 2014Docker - Hack Salem! - November 2014
Docker - Hack Salem! - November 2014
 

Similaire à Groovy a Scripting Language for Java

Groovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume LaforgeGroovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume LaforgeGuillaume Laforge
 
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
 
Groovy And Grails Introduction
Groovy And Grails IntroductionGroovy And Grails Introduction
Groovy And Grails IntroductionEric Weimer
 
Oscon Java Testing on the Fast Lane
Oscon Java Testing on the Fast LaneOscon Java Testing on the Fast Lane
Oscon Java Testing on the Fast LaneAndres Almiray
 
Javaone2008 Bof 5101 Groovytesting
Javaone2008 Bof 5101 GroovytestingJavaone2008 Bof 5101 Groovytesting
Javaone2008 Bof 5101 GroovytestingAndres Almiray
 
Boosting Your Testing Productivity with Groovy
Boosting Your Testing Productivity with GroovyBoosting Your Testing Productivity with Groovy
Boosting Your Testing Productivity with GroovyJames Williams
 
Hacking with ruby2ruby
Hacking with ruby2rubyHacking with ruby2ruby
Hacking with ruby2rubyMarc Chung
 
GTAC Boosting your Testing Productivity with Groovy
GTAC Boosting your Testing Productivity with GroovyGTAC Boosting your Testing Productivity with Groovy
GTAC Boosting your Testing Productivity with GroovyAndres Almiray
 
Groovy in the Enterprise - Case Studies - TSSJS Prague 2008 - Guillaume Laforge
Groovy in the Enterprise - Case Studies - TSSJS Prague 2008 - Guillaume LaforgeGroovy in the Enterprise - Case Studies - TSSJS Prague 2008 - Guillaume Laforge
Groovy in the Enterprise - Case Studies - TSSJS Prague 2008 - Guillaume LaforgeGuillaume Laforge
 
An Introduction to Gradle for Java Developers
An Introduction to Gradle for Java DevelopersAn Introduction to Gradle for Java Developers
An Introduction to Gradle for Java DevelopersKostas Saidis
 
Groovy Update - JavaPolis 2007
Groovy Update - JavaPolis 2007Groovy Update - JavaPolis 2007
Groovy Update - JavaPolis 2007Guillaume Laforge
 
Groovy & Grails: Scripting for Modern Web Applications
Groovy & Grails: Scripting for Modern Web ApplicationsGroovy & Grails: Scripting for Modern Web Applications
Groovy & Grails: Scripting for Modern Web Applicationsrohitnayak
 
Apache Groovy: the language and the ecosystem
Apache Groovy: the language and the ecosystemApache Groovy: the language and the ecosystem
Apache Groovy: the language and the ecosystemKostas Saidis
 
LISA Qooxdoo Tutorial Handouts
LISA Qooxdoo Tutorial HandoutsLISA Qooxdoo Tutorial Handouts
LISA Qooxdoo Tutorial HandoutsTobias Oetiker
 
Developing cross platform desktop application with Ruby
Developing cross platform desktop application with RubyDeveloping cross platform desktop application with Ruby
Developing cross platform desktop application with RubyAnis Ahmad
 
An Introduction to Groovy for Java Developers
An Introduction to Groovy for Java DevelopersAn Introduction to Groovy for Java Developers
An Introduction to Groovy for Java DevelopersKostas Saidis
 
JavaCro 2016 - From Java to Groovy: Adventure Time!
JavaCro 2016 - From Java to Groovy: Adventure Time!JavaCro 2016 - From Java to Groovy: Adventure Time!
JavaCro 2016 - From Java to Groovy: Adventure Time!Iván López Martín
 
Groovy Up Your Code
Groovy Up Your CodeGroovy Up Your Code
Groovy Up Your CodePaulo Traça
 

Similaire à Groovy a Scripting Language for Java (20)

OpenLogic
OpenLogicOpenLogic
OpenLogic
 
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume LaforgeGroovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
 
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
 
Groovy And Grails Introduction
Groovy And Grails IntroductionGroovy And Grails Introduction
Groovy And Grails Introduction
 
Oscon Java Testing on the Fast Lane
Oscon Java Testing on the Fast LaneOscon Java Testing on the Fast Lane
Oscon Java Testing on the Fast Lane
 
Javaone2008 Bof 5101 Groovytesting
Javaone2008 Bof 5101 GroovytestingJavaone2008 Bof 5101 Groovytesting
Javaone2008 Bof 5101 Groovytesting
 
Boosting Your Testing Productivity with Groovy
Boosting Your Testing Productivity with GroovyBoosting Your Testing Productivity with Groovy
Boosting Your Testing Productivity with Groovy
 
Hacking with ruby2ruby
Hacking with ruby2rubyHacking with ruby2ruby
Hacking with ruby2ruby
 
GTAC Boosting your Testing Productivity with Groovy
GTAC Boosting your Testing Productivity with GroovyGTAC Boosting your Testing Productivity with Groovy
GTAC Boosting your Testing Productivity with Groovy
 
What's New in Groovy 1.6?
What's New in Groovy 1.6?What's New in Groovy 1.6?
What's New in Groovy 1.6?
 
Groovy in the Enterprise - Case Studies - TSSJS Prague 2008 - Guillaume Laforge
Groovy in the Enterprise - Case Studies - TSSJS Prague 2008 - Guillaume LaforgeGroovy in the Enterprise - Case Studies - TSSJS Prague 2008 - Guillaume Laforge
Groovy in the Enterprise - Case Studies - TSSJS Prague 2008 - Guillaume Laforge
 
An Introduction to Gradle for Java Developers
An Introduction to Gradle for Java DevelopersAn Introduction to Gradle for Java Developers
An Introduction to Gradle for Java Developers
 
Groovy Update - JavaPolis 2007
Groovy Update - JavaPolis 2007Groovy Update - JavaPolis 2007
Groovy Update - JavaPolis 2007
 
Groovy & Grails: Scripting for Modern Web Applications
Groovy & Grails: Scripting for Modern Web ApplicationsGroovy & Grails: Scripting for Modern Web Applications
Groovy & Grails: Scripting for Modern Web Applications
 
Apache Groovy: the language and the ecosystem
Apache Groovy: the language and the ecosystemApache Groovy: the language and the ecosystem
Apache Groovy: the language and the ecosystem
 
LISA Qooxdoo Tutorial Handouts
LISA Qooxdoo Tutorial HandoutsLISA Qooxdoo Tutorial Handouts
LISA Qooxdoo Tutorial Handouts
 
Developing cross platform desktop application with Ruby
Developing cross platform desktop application with RubyDeveloping cross platform desktop application with Ruby
Developing cross platform desktop application with Ruby
 
An Introduction to Groovy for Java Developers
An Introduction to Groovy for Java DevelopersAn Introduction to Groovy for Java Developers
An Introduction to Groovy for Java Developers
 
JavaCro 2016 - From Java to Groovy: Adventure Time!
JavaCro 2016 - From Java to Groovy: Adventure Time!JavaCro 2016 - From Java to Groovy: Adventure Time!
JavaCro 2016 - From Java to Groovy: Adventure Time!
 
Groovy Up Your Code
Groovy Up Your CodeGroovy Up Your Code
Groovy Up Your Code
 

Plus de Charles Anderson

How to get a Software Job w/o Experience
How to get a Software Job w/o ExperienceHow to get a Software Job w/o Experience
How to get a Software Job w/o ExperienceCharles Anderson
 
A Brief Introduction to Redis
A Brief Introduction to RedisA Brief Introduction to Redis
A Brief Introduction to RedisCharles Anderson
 
A Shallow Survey of Alternative Languages on the JVM
A Shallow Survey of Alternative Languages on the JVMA Shallow Survey of Alternative Languages on the JVM
A Shallow Survey of Alternative Languages on the JVMCharles Anderson
 
How to Get a Software Job w/o Experience
How to Get a Software Job w/o ExperienceHow to Get a Software Job w/o Experience
How to Get a Software Job w/o ExperienceCharles Anderson
 
How To Protect Yourself and Your Computer Online
How To Protect Yourself and Your Computer OnlineHow To Protect Yourself and Your Computer Online
How To Protect Yourself and Your Computer OnlineCharles Anderson
 
Jython: Integrating Python and Java
Jython: Integrating Python and JavaJython: Integrating Python and Java
Jython: Integrating Python and JavaCharles Anderson
 

Plus de Charles Anderson (8)

Modern php
Modern phpModern php
Modern php
 
Inrastructure as Code
Inrastructure as CodeInrastructure as Code
Inrastructure as Code
 
How to get a Software Job w/o Experience
How to get a Software Job w/o ExperienceHow to get a Software Job w/o Experience
How to get a Software Job w/o Experience
 
A Brief Introduction to Redis
A Brief Introduction to RedisA Brief Introduction to Redis
A Brief Introduction to Redis
 
A Shallow Survey of Alternative Languages on the JVM
A Shallow Survey of Alternative Languages on the JVMA Shallow Survey of Alternative Languages on the JVM
A Shallow Survey of Alternative Languages on the JVM
 
How to Get a Software Job w/o Experience
How to Get a Software Job w/o ExperienceHow to Get a Software Job w/o Experience
How to Get a Software Job w/o Experience
 
How To Protect Yourself and Your Computer Online
How To Protect Yourself and Your Computer OnlineHow To Protect Yourself and Your Computer Online
How To Protect Yourself and Your Computer Online
 
Jython: Integrating Python and Java
Jython: Integrating Python and JavaJython: Integrating Python and Java
Jython: Integrating Python and Java
 

Dernier

Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 

Dernier (20)

Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 

Groovy a Scripting Language for Java

  • 1. Groovy: a Scripting Language for Java Charles Anderson Western Skies Consulting cander@westernskiesweb.com
  • 2. Outline • Introduction and Context • Stupid Pet Tricks • Using Groovy in a Java project • Conclusion • Grails?
  • 3. Introduction • There are now many dynamic and/or scripting languages that run on the Java Platform • Groovy is a scripting language specifically for the Java Platform - feature-rich, Java-friendly • Groovy compiles to Java classes & byte code - can use all of Java Platform
  • 4. Introduction • Scripting - don’t have to explicitly compile • Typing - static or dynamic (optional/duck) • Mature - version 1.5, 1.6 Beta 2 • Books, websites, commercial backing, JSR • IDE Support
  • 5. Code Comparison Groovy Groovy Java Java Syntax Functionality
  • 6. Java or Groovy? class Book { private String title; Book (String theTitle) { title = theTitle; } String getTitle() { return title } }
  • 7. Stupid Pet Tricks public class Main { public static void main(...) System.out.println(“Hello World”); }} println ‘Hello World’
  • 8. More Powerful Switch switch (x) { case 0: // single int case 1..9: // range case [11,13,17]: // list case Float: // type check case ‘cat’: // string case ~/[A-Z][0-9]/: //regexp }
  • 9. Groovy Beans public class MyBean implements Serializable { private String myProp; public String getMyProp()... public void setMyProp(...)... } class MyBean implements Serializable { String myProp; }
  • 10. Terse NPE Safety if (x!=null && x.y!=null) { z = x.y.z; } z = x?.y?.z
  • 11. Bob the Builder writer = new FileWriter(‘bob.html’) def page = new MarkupBuilder(writer) page.html{ head { title ‘An HTML Page’ } body { h1 ‘The big heading’ form (action:’submit’) { input(type:’checkbox’, id:’yes’) input(type:’checkbox’, id:’no’) }}}
  • 12. Closures • A closure is a chunk of code that is a first- class entity/object in the language • From functional programming • Can accept parameters and return a value • Typical Java solution: inner classes, visitor pattern, template method pattern
  • 13. Exorcising Inner Classes t = new Thread(new Runable() { public void run() { // some code }}); t.start(); Thread.start { //some code }
  • 14. Java Iteration for (Iterator it=coll.iterator(); it.hasNext(); ) { Item item=(Item)it.next(); //some code } for (Item item : coll) { // some code }
  • 15. Groovy Iteration coll.each(item-> // some code) coll.findAll(it % 2 == 0).each(...) new File(‘foo.txt’).eachLine { println it }
  • 16. Embrace and Extend • Groovy “extends” Java classes - GDK • Object, GString, Collections, Files, Threads, Beans • Groovy enhances existing Java tools • JUnit, Ant, Swing • Reduce tedious boiler-plate - DRY
  • 17. using Groovy • Little development tasks - automation • Can script COM and Windows • Experiments and spiking • Testing - unit tests, data loading, scaffolding
  • 18. Conclusion • Groovy is a dynamic scripting language that is designed specifically for Java • Lots of “tricks” to make life easier, but they can be introduced gradually • Groovy is a playground for the future of Java - e.g., closures, properties • Questions, job leads, Grails?
  • 19. Grails: Groovy on Rails • Accelerate and simplify web development on the Java Platform - but not Java Language • Deploys as a WAR file • MVC structure • Convention over configuration • Uses Spring and Hibernate under covers
  • 20. Grails Commands Usage: grails command create-app run-app create-domain-class Entity generate-all Entity generate-webtest run-webtest war