SlideShare a Scribd company logo
1 of 19
Groovy: Fly Beyond Java Copyright © 2001-2008 Infor Global Solutions
Agenda ,[object Object],[object Object]
[object Object]
CEO 的梦想 =
程序员的梦想 写程序 泡网 午饭 和美眉网聊 打游戏 下班
Copyright © 2001-2006 Infor Global Solutions 哪种编程语言更“好”? 义 義 好 的编程语言也许应该更像是一门 “ 语言 ”
Copyright © 2001-2006 Infor Global Solutions 于是 Groovy 诞生了 Groovy 使得 Java 更“ 语言 ” Java 的 强大技术 类 Ruby 等动态语言 的轻盈语法 Groovy
Copyright © 2001-2006 Infor Global Solutions 欢迎来到简洁美妙的 Groovy 世界
Copyright © 2001-2006 Infor Global Solutions 别在乎类型 Java: String name = “abc”; Groovy: String name = “abc” def  name name = “abc”
Copyright © 2001-2006 Infor Global Solutions “ 直接”访问属性 class Person { private String name; public Person(String name) {this.name = name;} public String getName() {return name;} } Person person = new person(“ocean”) return person.getName(); class Person { String name; } Person person = new Person(name:”ocean”) return person .name
Copyright © 2001-2006 Infor Global Solutions 了不起的字符串 firstName = “ocean” lastName = “dong” message = “My name is  $ firstName  $ lastName” person = new Person() person.setName(“ocean”) message = “My name is  ${ person.name } ” Message =  “ ““ Hi, My name is ${person.name} ””” def pattern =  / hello.* /
Copyright © 2001-2006 Infor Global Solutions 集合:简单类型而已 List: def aList = [1, 2, 3] def aList = [10, “abc”, new Date()] Map: def aMap = [a:1, b:2] Range: def aRange = ‘a’..’z’ def numbers = 0..<10
Copyright © 2001-2006 Infor Global Solutions 可爱的操作符 [1, 2, 3]  <<  4 def aMap = [a:1, b:2] println aMap . a println aMap [ a ] “ hello world”  =~  /hello.*/ println person ? .wife ? .name
Copyright © 2001-2006 Infor Global Solutions 万物皆可判断 If(1) assert 1 def aList = [1, 2, 3] If(aList) assert aList def person If(person) assert !person
Copyright © 2001-2006 Infor Global Solutions 四通八达的 Switch switch(10) { case 0: case 0..9: case [8,9,11]: case Float: case {it % 3 == 0}: case ~/../: default: }
Copyright © 2001-2006 Infor Global Solutions 透明的集合 ArrayList names = new ArrayList() for(Person person : persons) { names.add(person.getName()); } return names; def persons = [new Person(”ocean”), new Person(”coco”)] assert persons .name  == [“ocean”, “coco”] assert persons *.getGender()  == [“Male”, “Female”]
Copyright © 2001-2006 Infor Global Solutions Closure:  终极代码重用 ArrayList persons = … for(Person person : persons) { System.out.println(person.getName()); } persons.each  {it ->  println it.name }
Copyright © 2001-2006 Infor Global Solutions 远远不止这些哦。。。 Builder Meta Programming Groovylet GSP GRails Scriptom Griffon GMaven Gant GSQL GORM Tellurium http://groovy.codehaus.org/
Thanks

More Related Content

Similar to Groovy Intro

introduction-to-ruby
introduction-to-rubyintroduction-to-ruby
introduction-to-ruby
Ademar Tutor
 
Polyglot Programming @ Jax.de 2010
Polyglot Programming @ Jax.de 2010Polyglot Programming @ Jax.de 2010
Polyglot Programming @ Jax.de 2010
Andres Almiray
 
Migrating To Ruby1.9
Migrating To Ruby1.9Migrating To Ruby1.9
Migrating To Ruby1.9
tomaspavelka
 
Voicecon - Mashups with Tropo.com
Voicecon - Mashups with Tropo.comVoicecon - Mashups with Tropo.com
Voicecon - Mashups with Tropo.com
Voxeo Corp
 
Clojure for Java developers - Stockholm
Clojure for Java developers - StockholmClojure for Java developers - Stockholm
Clojure for Java developers - Stockholm
Jan Kronquist
 

Similar to Groovy Intro (20)

introduction-to-ruby
introduction-to-rubyintroduction-to-ruby
introduction-to-ruby
 
Groovy!
Groovy!Groovy!
Groovy!
 
Opa hackathon
Opa hackathonOpa hackathon
Opa hackathon
 
Making Java Groovy (JavaOne 2013)
Making Java Groovy (JavaOne 2013)Making Java Groovy (JavaOne 2013)
Making Java Groovy (JavaOne 2013)
 
Introduction to Domain-Driven Design
Introduction to Domain-Driven DesignIntroduction to Domain-Driven Design
Introduction to Domain-Driven Design
 
Does Java Have a Future After Version 8? (Belfast JUG April 2014)
Does Java Have a Future After Version 8? (Belfast JUG April 2014)Does Java Have a Future After Version 8? (Belfast JUG April 2014)
Does Java Have a Future After Version 8? (Belfast JUG April 2014)
 
Cより速いRubyプログラム
Cより速いRubyプログラムCより速いRubyプログラム
Cより速いRubyプログラム
 
Polyglot Programming @ Jax.de 2010
Polyglot Programming @ Jax.de 2010Polyglot Programming @ Jax.de 2010
Polyglot Programming @ Jax.de 2010
 
Building native Android applications with Mirah and Pindah
Building native Android applications with Mirah and PindahBuilding native Android applications with Mirah and Pindah
Building native Android applications with Mirah and Pindah
 
Clojure And Swing
Clojure And SwingClojure And Swing
Clojure And Swing
 
Clojure: Functional Concurrency for the JVM (presented at OSCON)
Clojure: Functional Concurrency for the JVM (presented at OSCON)Clojure: Functional Concurrency for the JVM (presented at OSCON)
Clojure: Functional Concurrency for the JVM (presented at OSCON)
 
Migrating To Ruby1.9
Migrating To Ruby1.9Migrating To Ruby1.9
Migrating To Ruby1.9
 
What's new in DWR version 3
What's new in DWR version 3What's new in DWR version 3
What's new in DWR version 3
 
Goodparts
GoodpartsGoodparts
Goodparts
 
Voicecon - Mashups with Tropo.com
Voicecon - Mashups with Tropo.comVoicecon - Mashups with Tropo.com
Voicecon - Mashups with Tropo.com
 
Go is geting Rusty
Go is geting RustyGo is geting Rusty
Go is geting Rusty
 
Clojure for Java developers - Stockholm
Clojure for Java developers - StockholmClojure for Java developers - Stockholm
Clojure for Java developers - Stockholm
 
Free The Enterprise With Ruby & Master Your Own Domain
Free The Enterprise With Ruby & Master Your Own DomainFree The Enterprise With Ruby & Master Your Own Domain
Free The Enterprise With Ruby & Master Your Own Domain
 
Groovy
GroovyGroovy
Groovy
 
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
 

More from Ocean Dong (11)

Software Dev Process In A Nutshell
Software Dev Process In A NutshellSoftware Dev Process In A Nutshell
Software Dev Process In A Nutshell
 
Review of code review
Review of code reviewReview of code review
Review of code review
 
RUP Basics
RUP BasicsRUP Basics
RUP Basics
 
Software Design Principles
Software Design PrinciplesSoftware Design Principles
Software Design Principles
 
A Glance At Scrum
A Glance At ScrumA Glance At Scrum
A Glance At Scrum
 
How To Write Work Mail
How To Write Work MailHow To Write Work Mail
How To Write Work Mail
 
Continuous Code Quality Improvement
Continuous Code Quality ImprovementContinuous Code Quality Improvement
Continuous Code Quality Improvement
 
Stress free email handling
Stress free email handlingStress free email handling
Stress free email handling
 
柬埔寨之旅
柬埔寨之旅柬埔寨之旅
柬埔寨之旅
 
Introduction About Lean Way
Introduction About Lean WayIntroduction About Lean Way
Introduction About Lean Way
 
Agile Testing
Agile TestingAgile Testing
Agile Testing
 

Groovy Intro

  • 1. Groovy: Fly Beyond Java Copyright © 2001-2008 Infor Global Solutions
  • 2.
  • 3.
  • 5. 程序员的梦想 写程序 泡网 午饭 和美眉网聊 打游戏 下班
  • 6. Copyright © 2001-2006 Infor Global Solutions 哪种编程语言更“好”? 义 義 好 的编程语言也许应该更像是一门 “ 语言 ”
  • 7. Copyright © 2001-2006 Infor Global Solutions 于是 Groovy 诞生了 Groovy 使得 Java 更“ 语言 ” Java 的 强大技术 类 Ruby 等动态语言 的轻盈语法 Groovy
  • 8. Copyright © 2001-2006 Infor Global Solutions 欢迎来到简洁美妙的 Groovy 世界
  • 9. Copyright © 2001-2006 Infor Global Solutions 别在乎类型 Java: String name = “abc”; Groovy: String name = “abc” def name name = “abc”
  • 10. Copyright © 2001-2006 Infor Global Solutions “ 直接”访问属性 class Person { private String name; public Person(String name) {this.name = name;} public String getName() {return name;} } Person person = new person(“ocean”) return person.getName(); class Person { String name; } Person person = new Person(name:”ocean”) return person .name
  • 11. Copyright © 2001-2006 Infor Global Solutions 了不起的字符串 firstName = “ocean” lastName = “dong” message = “My name is $ firstName $ lastName” person = new Person() person.setName(“ocean”) message = “My name is ${ person.name } ” Message = “ ““ Hi, My name is ${person.name} ””” def pattern = / hello.* /
  • 12. Copyright © 2001-2006 Infor Global Solutions 集合:简单类型而已 List: def aList = [1, 2, 3] def aList = [10, “abc”, new Date()] Map: def aMap = [a:1, b:2] Range: def aRange = ‘a’..’z’ def numbers = 0..<10
  • 13. Copyright © 2001-2006 Infor Global Solutions 可爱的操作符 [1, 2, 3] << 4 def aMap = [a:1, b:2] println aMap . a println aMap [ a ] “ hello world” =~ /hello.*/ println person ? .wife ? .name
  • 14. Copyright © 2001-2006 Infor Global Solutions 万物皆可判断 If(1) assert 1 def aList = [1, 2, 3] If(aList) assert aList def person If(person) assert !person
  • 15. Copyright © 2001-2006 Infor Global Solutions 四通八达的 Switch switch(10) { case 0: case 0..9: case [8,9,11]: case Float: case {it % 3 == 0}: case ~/../: default: }
  • 16. Copyright © 2001-2006 Infor Global Solutions 透明的集合 ArrayList names = new ArrayList() for(Person person : persons) { names.add(person.getName()); } return names; def persons = [new Person(”ocean”), new Person(”coco”)] assert persons .name == [“ocean”, “coco”] assert persons *.getGender() == [“Male”, “Female”]
  • 17. Copyright © 2001-2006 Infor Global Solutions Closure: 终极代码重用 ArrayList persons = … for(Person person : persons) { System.out.println(person.getName()); } persons.each {it -> println it.name }
  • 18. Copyright © 2001-2006 Infor Global Solutions 远远不止这些哦。。。 Builder Meta Programming Groovylet GSP GRails Scriptom Griffon GMaven Gant GSQL GORM Tellurium http://groovy.codehaus.org/

Editor's Notes

  1. Introduce wiki page
  2. Introduce wiki page
  3. Introduce wiki page
  4. Introduce wiki page