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

What's hot (20)

PDF
Declarative Infrastructure Tools
Yulia Shcherbachova
 
PDF
2016 foss4 g track: developing and implementing spatial etl processes with...
GIS in the Rockies
 
PDF
Js interpreter interpreted
Martha Schumann
 
PDF
Functional Programming with JavaScript
Mark Shelton
 
PDF
Single qubit-gates operations
Vijayananda Mohire
 
PDF
Data structure programs in c++
mmirfan
 
PDF
Cassandra Day Denver 2014: Building Java Applications with Apache Cassandra
DataStax Academy
 
PDF
201801 CSE240 Lecture 15
Javier Gonzalez-Sanchez
 
PDF
Presto in Treasure Data
Mitsunori Komatsu
 
PDF
Cascadia.js: Don't Cross the Streams
mattpodwysocki
 
KEY
W3C HTML5 KIG-How to write low garbage real-time javascript
Changhwan Yi
 
PDF
RxJS - The Reactive extensions for JavaScript
Viliam Elischer
 
PDF
Virtual machine and javascript engine
Duoyi Wu
 
PDF
Metrics 2.0 @ Monitorama PDX 2014
Dieter Plaetinck
 
PDF
Metrics 2.0 & Graph-Explorer
Dieter Plaetinck
 
PDF
How the Go runtime implement maps efficiently
Ting-Li Chou
 
PDF
TPC-DS performance evaluation for JAQL and PIG queries - Andrii Vozniuk, Serg...
Andrii Vozniuk
 
PDF
Metrics stack 2.0
Dieter Plaetinck
 
PDF
The Ring programming language version 1.5.4 book - Part 62 of 185
Mahmoud Samir Fayed
 
PPTX
Nicety of java 8 multithreading for advanced, Max Voronoy
Sigma Software
 
Declarative Infrastructure Tools
Yulia Shcherbachova
 
2016 foss4 g track: developing and implementing spatial etl processes with...
GIS in the Rockies
 
Js interpreter interpreted
Martha Schumann
 
Functional Programming with JavaScript
Mark Shelton
 
Single qubit-gates operations
Vijayananda Mohire
 
Data structure programs in c++
mmirfan
 
Cassandra Day Denver 2014: Building Java Applications with Apache Cassandra
DataStax Academy
 
201801 CSE240 Lecture 15
Javier Gonzalez-Sanchez
 
Presto in Treasure Data
Mitsunori Komatsu
 
Cascadia.js: Don't Cross the Streams
mattpodwysocki
 
W3C HTML5 KIG-How to write low garbage real-time javascript
Changhwan Yi
 
RxJS - The Reactive extensions for JavaScript
Viliam Elischer
 
Virtual machine and javascript engine
Duoyi Wu
 
Metrics 2.0 @ Monitorama PDX 2014
Dieter Plaetinck
 
Metrics 2.0 & Graph-Explorer
Dieter Plaetinck
 
How the Go runtime implement maps efficiently
Ting-Li Chou
 
TPC-DS performance evaluation for JAQL and PIG queries - Andrii Vozniuk, Serg...
Andrii Vozniuk
 
Metrics stack 2.0
Dieter Plaetinck
 
The Ring programming language version 1.5.4 book - Part 62 of 185
Mahmoud Samir Fayed
 
Nicety of java 8 multithreading for advanced, Max Voronoy
Sigma Software
 

Similar to Why Grails? (20)

PDF
Groovy in the Enterprise - Case Studies - TSSJS Prague 2008 - Guillaume Laforge
Guillaume Laforge
 
ODP
Groovy and Grails intro
Miguel Pastor
 
PPT
Introduction To Groovy 2005
Tugdual Grall
 
PPT
Groovy Update - JavaPolis 2007
Guillaume Laforge
 
PPT
Groovy Introduction - JAX Germany - 2008
Guillaume Laforge
 
PPT
Groovy & Grails: Scripting for Modern Web Applications
rohitnayak
 
PDF
Groovy and Grails talk
desistartups
 
PDF
Groovy - Grails as a modern scripting language for Web applications
IndicThreads
 
ODP
Groovygrailsnetbeans 12517452668498-phpapp03
Kevin Juma
 
POT
intoduction to Grails Framework
Harshdeep Kaur
 
ODP
Agile web development Groovy Grails with Netbeans
Carol McDonald
 
KEY
Polyglot Grails
Marcin Gryszko
 
PPTX
Magic with groovy & grails
George Platon
 
PPTX
Groovy And Grails Introduction
Eric Weimer
 
PPTX
Spring Northwest Usergroup Grails Presentation
ajevans
 
PDF
Groovy Online 100
reynolds
 
PDF
Grails @ Java User Group Silicon Valley
Sven Haiges
 
PDF
Grails 101
David Jacobs
 
PDF
Grooscript gr8conf
GR8Conf
 
PDF
GR8Conf 2009: What's New in Groovy 1.6? by Guillaume Laforge
GR8Conf
 
Groovy in the Enterprise - Case Studies - TSSJS Prague 2008 - Guillaume Laforge
Guillaume Laforge
 
Groovy and Grails intro
Miguel Pastor
 
Introduction To Groovy 2005
Tugdual Grall
 
Groovy Update - JavaPolis 2007
Guillaume Laforge
 
Groovy Introduction - JAX Germany - 2008
Guillaume Laforge
 
Groovy & Grails: Scripting for Modern Web Applications
rohitnayak
 
Groovy and Grails talk
desistartups
 
Groovy - Grails as a modern scripting language for Web applications
IndicThreads
 
Groovygrailsnetbeans 12517452668498-phpapp03
Kevin Juma
 
intoduction to Grails Framework
Harshdeep Kaur
 
Agile web development Groovy Grails with Netbeans
Carol McDonald
 
Polyglot Grails
Marcin Gryszko
 
Magic with groovy & grails
George Platon
 
Groovy And Grails Introduction
Eric Weimer
 
Spring Northwest Usergroup Grails Presentation
ajevans
 
Groovy Online 100
reynolds
 
Grails @ Java User Group Silicon Valley
Sven Haiges
 
Grails 101
David Jacobs
 
Grooscript gr8conf
GR8Conf
 
GR8Conf 2009: What's New in Groovy 1.6? by Guillaume Laforge
GR8Conf
 
Ad

More from Yiguang Hu (10)

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

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      }}