SlideShare a Scribd company logo
Why	
  Grails?	
  

  Yiguang	
  Hu	
  
What	
  is	
  Grails?	
  
•  Grails	
  is	
  a	
  web	
  framework	
  based	
  on	
  
    –  JAVA,	
  GROOVY,	
  Spring,	
  GORM	
  
•  Scaffolding!	
  
•  Plugin	
  everything!!!	
  
    –  GWT,	
  DWR,	
  YUI,	
  ACEGI,	
  Google	
  AppEngine,	
  Google	
  
       Wave,	
  COMET,	
  JQuery,	
  Clojure,	
  Scala,	
  JSF,	
  Struts…	
  
•  Support	
  all	
  modern	
  browsers	
  automaRcally	
  
•  Render	
  object	
  to	
  JSON,	
  XML	
  free!	
  
•  MVC+IOC(services)+plugin	
  
Why	
  Grails?	
  
•  Rapid	
  
    –  Have	
  your	
  next	
  Web	
  2.0	
  project	
  done	
  in	
  weeks	
  instead	
  of	
  
       months.	
  Grails	
  delivers	
  a	
  new	
  age	
  of	
  Java	
  web	
  applicaRon	
  
       producRvity.	
  
•  Dynamic	
  
    –  Get	
  instant	
  feedback,	
  see	
  instant	
  results.	
  Grails	
  is	
  the	
  
       premier	
  dynamic	
  language	
  web	
  framework	
  for	
  the	
  JVM.	
  
•  Robust	
  
    –  Powered	
  by	
  Spring,	
  Grails	
  out	
  performs	
  the	
  compeRRon.	
  
       Dynamic,	
  agile	
  web	
  development	
  without	
  compromises.	
  
•  Proven	
  Technologies:	
  JAVA(Groovy),	
  Spring,	
  GORM	
  
What	
  is	
  Groovy?	
  
•  Groovy	
  =	
  
    –  JAVA+Dynamic	
  Typing+Closure+	
  
        DSL,	
  GPars,Griffon….	
  
•  Runs	
  on	
  JVM	
  


• 0      	
  Learning	
  curve	
  for	
  Java	
  programmer	
  
Success	
  Stories	
  
•  The	
  Sites	
  I	
  personally	
  involved:	
  
    –  Worthpoint.com	
  (80	
  million	
  records)	
  
    –  Gsword:	
  h_p://www.ccimweb.org/gsword	
  
        •  Web	
  2.0.	
  Highly	
  interacRve.	
  
        •  Done	
  in	
  two	
  days!	
  
    –  Others	
  
Demo	
  
•  Install	
  java,	
  groovy,	
  grails	
  
•  grails	
  create-­‐app	
  interop	
  
    –  Goto	
  dir	
  interop	
  and	
  see	
  the	
  dires/files	
  created	
  
•  Run	
  it!	
  
•  Add	
  domain	
  
•  Generate	
  controller/views	
  and	
  run	
  
    –  SorRng,	
  paginaRon	
  are	
  there	
  already!	
  
•  Add	
  a	
  service	
  and	
  use	
  in	
  controller	
  
•  Run	
  it!	
  
Demo…	
  
•  SOA	
  
    –  Render	
  objects	
  as	
  JSON,	
  XML	
  etc	
  
    –  Import	
  grails.converters.*;	
  
•  Parallel	
  compuRng	
  in	
  Services	
  using	
  GPars	
  
•  Using	
  other	
  languages	
  like	
  Clojure	
  in	
  grails	
  
•  …	
  
Performance	
  Concern?	
  
•    User	
  Java	
  in	
  high	
  demanding	
  place	
  
•    Gpars	
  (Actors,	
  map	
  reducer…)	
  
•    Use	
  clojure	
  in	
  services	
  
•    User	
  Scala	
  in	
  services	
  

•  Yes.	
  It	
  is	
  AGILE!	
  
Clojure	
  Demo	
  
•  grails	
  install-­‐plugin	
  clojure	
  
•  New	
  dir	
  src/clj	
  is	
  created	
  
•  Add	
  file	
  Addnumber.clj	
  in	
  src/clj	
  
        (ns	
  grails)	
  
        (def	
  twenty	
  20)	
  
        (defn	
  add_numbers	
  [a	
  b]	
  
        	
  	
  	
  	
  (+	
  a	
  b))	
  
Call	
  Clojure	
  from	
  Service	
  
class	
  ClojService	
  {	
  
	
  	
  	
  	
  boolean	
  transacRonal	
  =	
  false	
  
	
  	
  	
  	
  def	
  addNumbers(x,	
  y)	
  {	
  
	
  	
  	
  	
  clj.add_numbers(x,	
  y)	
  
	
  	
  	
  	
  }	
  
	
  	
  	
  def	
  addTwenty(x)	
  {	
  
	
  	
  	
  clj.add_numbers(x,	
  clj.twenty)	
  
	
  	
  	
  }	
  
}	
  
Call	
  Service	
  in	
  Controller	
  
import	
  grails.converters.XML;	
  
class	
  PlayController	
  {	
  
	
  	
  	
  	
  def	
  index	
  =	
  {	
  }	
  
	
  	
  def	
  clojService	
  
def	
  cljaddnumber={	
  
	
  	
  	
  	
  	
  	
  	
  render	
  clojService.addNumbers(Integer.parseInt(params.a?:"5"),	
  
                        Integer.parseInt(params.b?:"4"))	
  
	
  	
  }	
  
	
  	
  def	
  cljadd20={	
  
	
  	
  	
  	
  render	
  clojService.addTwenty(Integer.parseInt(params.a?:"10"))	
  
	
  	
  }	
  
}	
  
Gpars	
  Map	
  Reducer	
  Demo	
  
//@Grab(group='org.codehaus.gpars',	
  module='gpars',	
  version='0.9')	
  
import	
  staRc	
  groovyx.gpars.Parallelizer.*	
  
class	
  ConcurrentService	
  {	
  
	
  	
  	
  	
  boolean	
  transacRonal	
  =	
  true	
  
	
  	
  	
  	
  def	
  sqr()	
  {	
  
	
  	
  	
  	
  	
  	
  def	
  myNumbers	
  
	
  	
  	
  	
  	
  	
  doParallel{	
  
	
  	
  	
  	
  	
  myNumbers	
  =	
  (1..1000).parallel.filter{it	
  %	
  2	
  ==	
  0}.map{Math.sqrt	
  
                        it}.collecRon	
  
	
  	
  	
  	
  	
  	
  }	
  
	
  	
  	
  	
  	
  	
  myNumbers	
  
	
  	
  	
  	
  }	
  
Gpars	
  Map	
  Reducer	
  Demo	
  
def	
  search(String	
  key,keys){	
  
	
  	
  	
  	
  	
  key+":"+	
  keys.replaceAll(key,key.toUpperCase())	
  	
  	
  	
  /turns	
  key	
  to	
  upper	
  case	
  
	
  	
  }	
  
	
  	
  def	
  webs=["a	
  b	
  c	
  d	
  e	
  f	
  g	
  h	
  j	
  k	
  i	
  o	
  as	
  da	
  o	
  sa	
  ds	
  h	
  vcx	
  aw	
  s	
  dsf	
  gdsg	
  	
  ds	
  ,	
  bbx	
  
                        fdwvcx	
  786	
  ",	
  "b	
  sd	
  sd	
  sd	
  dsfgh	
  fds	
  	
  ewr	
  56y	
  	
  k	
  o	
  aw	
  	
  n	
  q	
  	
  12	
  	
  g	
  	
  n	
  1	
  	
  	
  	
  	
  uy	
  t	
  r",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "sad	
  assa	
  sa	
  sa	
  sa	
  sa	
  456t465367	
  45	
  45	
  23	
  23	
  12	
  	
  	
  453	
  43	
  5	
  3	
  234	
  523	
  ",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "8sdf	
  ds	
  5ue	
  	
  we	
  	
  123	
  	
  42	
  hg	
  	
  h	
  k	
  	
  	
  s	
  x	
  d	
  f	
  	
  t	
  r	
  g	
  h	
  j	
  	
  y	
  k	
  v	
  	
  b	
  n	
  	
  m	
  l	
  qw	
  ew	
  c"]	
  
	
  	
  def	
  reducer(String	
  key)	
  {	
  
	
  	
  	
  	
  	
  	
  	
  def	
  rst	
  
	
  	
  	
  	
  doParallel	
  {	
  
rst	
  =	
  webs.parallel.map	
  {search(key,it)}.collecRon	
  
	
  	
  	
  	
  }	
  
	
  	
  	
  	
  rst	
  
	
  	
  }}	
  

More Related Content

PPT
JVM performance options. How it works
PDF
GCPUG meetup 201610 - Dataflow Introduction
PPTX
Rubyslava + PyVo #48
PPTX
Azure sql insert perf
PPTX
Jk rubyslava 25
PDF
-XX:+UseG1GC
PDF
Living With Garbage
PDF
Living with Garbage by Gregg Donovan at LuceneSolr Revolution 2013
JVM performance options. How it works
GCPUG meetup 201610 - Dataflow Introduction
Rubyslava + PyVo #48
Azure sql insert perf
Jk rubyslava 25
-XX:+UseG1GC
Living With Garbage
Living with Garbage by Gregg Donovan at LuceneSolr Revolution 2013

What's hot (20)

PDF
Declarative Infrastructure Tools
PDF
2016 foss4 g track: developing and implementing spatial etl processes with...
PDF
Js interpreter interpreted
PDF
Functional Programming with JavaScript
PDF
Single qubit-gates operations
PDF
Data structure programs in c++
PDF
Cassandra Day Denver 2014: Building Java Applications with Apache Cassandra
PDF
201801 CSE240 Lecture 15
PDF
Presto in Treasure Data
PDF
Cascadia.js: Don't Cross the Streams
KEY
W3C HTML5 KIG-How to write low garbage real-time javascript
PDF
RxJS - The Reactive extensions for JavaScript
PDF
Virtual machine and javascript engine
PDF
Metrics 2.0 @ Monitorama PDX 2014
PDF
Metrics 2.0 & Graph-Explorer
PDF
How the Go runtime implement maps efficiently
PDF
TPC-DS performance evaluation for JAQL and PIG queries - Andrii Vozniuk, Serg...
PDF
Metrics stack 2.0
PDF
The Ring programming language version 1.5.4 book - Part 62 of 185
PPTX
Nicety of java 8 multithreading for advanced, Max Voronoy
Declarative Infrastructure Tools
2016 foss4 g track: developing and implementing spatial etl processes with...
Js interpreter interpreted
Functional Programming with JavaScript
Single qubit-gates operations
Data structure programs in c++
Cassandra Day Denver 2014: Building Java Applications with Apache Cassandra
201801 CSE240 Lecture 15
Presto in Treasure Data
Cascadia.js: Don't Cross the Streams
W3C HTML5 KIG-How to write low garbage real-time javascript
RxJS - The Reactive extensions for JavaScript
Virtual machine and javascript engine
Metrics 2.0 @ Monitorama PDX 2014
Metrics 2.0 & Graph-Explorer
How the Go runtime implement maps efficiently
TPC-DS performance evaluation for JAQL and PIG queries - Andrii Vozniuk, Serg...
Metrics stack 2.0
The Ring programming language version 1.5.4 book - Part 62 of 185
Nicety of java 8 multithreading for advanced, Max Voronoy
Ad

Viewers also liked (20)

DOC
2ª Etapa CSPC Viradouro SP
PDF
Pmi sac november 20
PDF
Desarrollo de aplicaciones PHP con Azure
PDF
62eboluzioa
PDF
"MobileFirst and UX Design" - 120725
KEY
Webアプリケーション開発での位置情報活用
PDF
2013 12 02_osm 浜松セミナー
PDF
2013 06-22osc nagoya-netmf
PDF
変化する力〜これまでのキャリアを振り返って
PDF
課題仮説検証完全マニュアルα版
PPT
DOC
Mundial Master mtb inscricao
PDF
Getting started raspberry pi osc hamamatsu
PDF
[沖縄レキサスセミナー]小さな会社のゲームチェンジ
PDF
2014 07 23 豊橋IT勉強会
PPTX
Niver andrea
PPTX
Top connected friends photosブロック
PPT
Examen CapíTulos
PPT
HSE{Consult}: DevOps – новая методология разработки
PDF
Osc2013 nagoya0622moodle
2ª Etapa CSPC Viradouro SP
Pmi sac november 20
Desarrollo de aplicaciones PHP con Azure
62eboluzioa
"MobileFirst and UX Design" - 120725
Webアプリケーション開発での位置情報活用
2013 12 02_osm 浜松セミナー
2013 06-22osc nagoya-netmf
変化する力〜これまでのキャリアを振り返って
課題仮説検証完全マニュアルα版
Mundial Master mtb inscricao
Getting started raspberry pi osc hamamatsu
[沖縄レキサスセミナー]小さな会社のゲームチェンジ
2014 07 23 豊橋IT勉強会
Niver andrea
Top connected friends photosブロック
Examen CapíTulos
HSE{Consult}: DevOps – новая методология разработки
Osc2013 nagoya0622moodle
Ad

Similar to Why Grails (20)

ZIP
Building Web Apps Sanely - EclipseCon 2010
KEY
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
ZIP
Google Developer Fest 2010
KEY
JBoss World 2010
PDF
HTML5 for the Silverlight Guy
PDF
Living with garbage
PDF
Porting legacy apps to Griffon
PDF
Node azure
PDF
PPTX
React inter3
PDF
Groovy On Trading Desk (2010)
PPT
Scripting Oracle Develop 2007
KEY
JavaScript Growing Up
PDF
Geo script opengeo spring 2013
PDF
Improving Apache Spark Downscaling
PDF
Scripting GeoServer
PDF
Easy Cloud Native Transformation using HashiCorp Nomad
PDF
Integrating React.js Into a PHP Application
PDF
The MEAN stack
PDF
Cross Domain Web
Mashups with JQuery and Google App Engine
Building Web Apps Sanely - EclipseCon 2010
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
Google Developer Fest 2010
JBoss World 2010
HTML5 for the Silverlight Guy
Living with garbage
Porting legacy apps to Griffon
Node azure
React inter3
Groovy On Trading Desk (2010)
Scripting Oracle Develop 2007
JavaScript Growing Up
Geo script opengeo spring 2013
Improving Apache Spark Downscaling
Scripting GeoServer
Easy Cloud Native Transformation using HashiCorp Nomad
Integrating React.js Into a PHP Application
The MEAN stack
Cross Domain Web
Mashups with JQuery and Google App Engine

More from Yiguang Hu (10)

PPTX
Data analysis scala_spark
PPTX
Java8 and Functional Programming
PPTX
Introduction to Vert.x
PPTX
Cross platform Mobile development on Titanium
PPTX
Phone Gap
PPT
Google Web Toolkits
PPT
Clojure
PDF
Why Grails?
PPT
Gsword
PPT
Google Web Toolkits
Data analysis scala_spark
Java8 and Functional Programming
Introduction to Vert.x
Cross platform Mobile development on Titanium
Phone Gap
Google Web Toolkits
Clojure
Why Grails?
Gsword
Google Web Toolkits

Recently uploaded (20)

PDF
Encapsulation theory and applications.pdf
PDF
DP Operators-handbook-extract for the Mautical Institute
PDF
Zenith AI: Advanced Artificial Intelligence
PDF
A novel scalable deep ensemble learning framework for big data classification...
PPTX
Chapter 5: Probability Theory and Statistics
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
A Presentation on Touch Screen Technology
PDF
A comparative analysis of optical character recognition models for extracting...
PPTX
TLE Review Electricity (Electricity).pptx
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Encapsulation theory and applications.pdf
DP Operators-handbook-extract for the Mautical Institute
Zenith AI: Advanced Artificial Intelligence
A novel scalable deep ensemble learning framework for big data classification...
Chapter 5: Probability Theory and Statistics
gpt5_lecture_notes_comprehensive_20250812015547.pdf
NewMind AI Weekly Chronicles - August'25-Week II
A Presentation on Touch Screen Technology
A comparative analysis of optical character recognition models for extracting...
TLE Review Electricity (Electricity).pptx
Assigned Numbers - 2025 - Bluetooth® Document
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
1 - Historical Antecedents, Social Consideration.pdf
A comparative study of natural language inference in Swahili using monolingua...
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Group 1 Presentation -Planning and Decision Making .pptx
Encapsulation_ Review paper, used for researhc scholars
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
Accuracy of neural networks in brain wave diagnosis of schizophrenia

Why Grails

  • 1. Why  Grails?   Yiguang  Hu  
  • 2. What  is  Grails?   •  Grails  is  a  web  framework  based  on   –  JAVA,  GROOVY,  Spring,  GORM   •  Scaffolding!   •  Plugin  everything!!!   –  GWT,  DWR,  YUI,  ACEGI,  Google  AppEngine,  Google   Wave,  COMET,  JQuery,  Clojure,  Scala,  JSF,  Struts…   •  Support  all  modern  browsers  automaRcally   •  Render  object  to  JSON,  XML  free!   •  MVC+IOC(services)+plugin  
  • 3. Why  Grails?   •  Rapid   –  Have  your  next  Web  2.0  project  done  in  weeks  instead  of   months.  Grails  delivers  a  new  age  of  Java  web  applicaRon   producRvity.   •  Dynamic   –  Get  instant  feedback,  see  instant  results.  Grails  is  the   premier  dynamic  language  web  framework  for  the  JVM.   •  Robust   –  Powered  by  Spring,  Grails  out  performs  the  compeRRon.   Dynamic,  agile  web  development  without  compromises.   •  Proven  Technologies:  JAVA(Groovy),  Spring,  GORM  
  • 4. What  is  Groovy?   •  Groovy  =   –  JAVA+Dynamic  Typing+Closure+   DSL,  GPars,Griffon….   •  Runs  on  JVM   • 0  Learning  curve  for  Java  programmer  
  • 5. Success  Stories   •  The  Sites  I  personally  involved:   –  Worthpoint.com  (80  million  records)   –  Gsword:  h_p://www.ccimweb.org/gsword   •  Web  2.0.  Highly  interacRve.   •  Done  in  two  days!   –  Others  
  • 6. Demo   •  Install  java,  groovy,  grails   •  grails  create-­‐app  interop   –  Goto  dir  interop  and  see  the  dires/files  created   •  Run  it!   •  Add  domain   •  Generate  controller/views  and  run   –  SorRng,  paginaRon  are  there  already!   •  Add  a  service  and  use  in  controller   •  Run  it!  
  • 7. Demo…   •  SOA   –  Render  objects  as  JSON,  XML  etc   –  Import  grails.converters.*;   •  Parallel  compuRng  in  Services  using  GPars   •  Using  other  languages  like  Clojure  in  grails   •  …  
  • 8. Performance  Concern?   •  User  Java  in  high  demanding  place   •  Gpars  (Actors,  map  reducer…)   •  Use  clojure  in  services   •  User  Scala  in  services   •  Yes.  It  is  AGILE!  
  • 9. Clojure  Demo   •  grails  install-­‐plugin  clojure   •  New  dir  src/clj  is  created   •  Add  file  Addnumber.clj  in  src/clj   (ns  grails)   (def  twenty  20)   (defn  add_numbers  [a  b]          (+  a  b))  
  • 10. Call  Clojure  from  Service   class  ClojService  {          boolean  transacRonal  =  false          def  addNumbers(x,  y)  {          clj.add_numbers(x,  y)          }        def  addTwenty(x)  {        clj.add_numbers(x,  clj.twenty)        }   }  
  • 11. Call  Service  in  Controller   import  grails.converters.XML;   class  PlayController  {          def  index  =  {  }      def  clojService   def  cljaddnumber={                render  clojService.addNumbers(Integer.parseInt(params.a?:"5"),   Integer.parseInt(params.b?:"4"))      }      def  cljadd20={          render  clojService.addTwenty(Integer.parseInt(params.a?:"10"))      }   }  
  • 12. Gpars  Map  Reducer  Demo   //@Grab(group='org.codehaus.gpars',  module='gpars',  version='0.9')   import  staRc  groovyx.gpars.Parallelizer.*   class  ConcurrentService  {          boolean  transacRonal  =  true          def  sqr()  {              def  myNumbers              doParallel{            myNumbers  =  (1..1000).parallel.filter{it  %  2  ==  0}.map{Math.sqrt   it}.collecRon              }              myNumbers          }  
  • 13. Gpars  Map  Reducer  Demo   def  search(String  key,keys){            key+":"+  keys.replaceAll(key,key.toUpperCase())        /turns  key  to  upper  case      }      def  webs=["a  b  c  d  e  f  g  h  j  k  i  o  as  da  o  sa  ds  h  vcx  aw  s  dsf  gdsg    ds  ,  bbx   fdwvcx  786  ",  "b  sd  sd  sd  dsfgh  fds    ewr  56y    k  o  aw    n  q    12    g    n  1          uy  t  r",                      "sad  assa  sa  sa  sa  sa  456t465367  45  45  23  23  12      453  43  5  3  234  523  ",                      "8sdf  ds  5ue    we    123    42  hg    h  k      s  x  d  f    t  r  g  h  j    y  k  v    b  n    m  l  qw  ew  c"]      def  reducer(String  key)  {                def  rst          doParallel  {   rst  =  webs.parallel.map  {search(key,it)}.collecRon          }          rst      }}