SlideShare a Scribd company logo
2011.1.24
Slide # 2   DevLOVE   Groovy 2011.1.24
http://d.hatena.ne.jp/uehaj/




Slide # 3   DevLOVE   Groovy 2011.1.24
new!          JJUG CCC
               update
Slide # 4   DevLOVE   Groovy 2011.1.24
Slide # 5   DevLOVE   Groovy 2011.1.24
Slide # 6   DevLOVE   Groovy 2011.1.24
import java.io.*;                                     BufferedReader bis = new BufferedReader
import java.net.*;                              (new InputStreamReader(ins));
                                                      String line;
public class SocketAccess {                           while ((line = bis.readLine()) != null) {
                                                        System.out.println(line);
  public static void main(String[] args) {            }
   Socket soc = null;                               }
   InputStream ins = null;                          catch (IOException e) {
   OutputStream outs = null;                          e.printStackTrace();
   try {                                              try {
     soc = new Socket("www.java-users.jp", 80);         if (soc != null) soc.close();
     ins = soc.getInputStream();                      }
     outs = soc.getOutputStream();                    catch(IOException ex) {}
     outs.write("GET / HTTP/1.0nn".getBytes       }
());                                              }
                                                }


  Slide # 7      DevLOVE          Groovy 2011.1.24
import java.io.*;                                     BufferedReader bis = new BufferedReader
import java.net.*;                              (new InputStreamReader(ins));
                                                      String line;
public class SocketAccess {                           while ((line = bis.readLine()) != null) {
                                                        System.out.println(line);
  public static void main(String[] args) {            }
   Socket soc = null;                               }
   InputStream ins = null;                          catch (IOException e) {
   OutputStream outs = null;                          e.printStackTrace();
   try {                                              try {
     soc = new Socket("www.java-users.jp", 80);         if (soc != null) soc.close();
     ins = soc.getInputStream();                      }
     outs = soc.getOutputStream();                    catch(IOException ex) {}
     outs.write("GET / HTTP/1.0nn".getBytes       }
());                                              }
                                                }


  Slide # 8      DevLOVE          Groovy 2011.1.24
import java.io.*;                                     BufferedReader bis = new BufferedReader
import java.net.*;                              (new InputStreamReader(ins));
                                                      String line;
public class SocketAccess {                           while ((line = bis.readLine()) != null) {
                                                        System.out.println(line);
  public static void main(String[] args) {            }
   Socket soc = null;                               }
   InputStream ins = null;                          catch (IOException e) {
   OutputStream outs = null;                          e.printStackTrace();
   try {                                              try {
     soc = new Socket("www.java-users.jp", 80);         if (soc != null) soc.close();
     ins = soc.getInputStream();                      }
     outs = soc.getOutputStream();                    catch(IOException ex) {}
     outs.write("GET / HTTP/1.0nn".getBytes       }
());                                              }
                                                }


  Slide # 8      DevLOVE          Groovy 2011.1.24
import java.io.*;                                     BufferedReader bis = new BufferedReader
import java.net.*;                              (new InputStreamReader(ins));
                                                      String line;
public class SocketAccess {                           while ((line = bis.readLine()) != null) {
                                                        System.out.println(line);
  public static void main(String[] args) {            }
   Socket soc = null;                               }
   InputStream ins = null;                          catch (IOException e) {
   OutputStream outs = null;                          e.printStackTrace();
   try {                                              try {
     soc = new Socket("www.java-users.jp", 80);         if (soc != null) soc.close();
     ins = soc.getInputStream();                      }
     outs = soc.getOutputStream();                    catch(IOException ex) {}
     outs.write("GET / HTTP/1.0nn".getBytes       }
());                                              }
                                                }


  Slide # 9      DevLOVE          Groovy 2011.1.24
import java.io.*;                                     BufferedReader bis = new BufferedReader
import java.net.*;                              (new InputStreamReader(ins));
                                                      String line;
public class SocketAccess {                           while ((line = bis.readLine()) != null) {
                                                        System.out.println(line);
  public static void main(String[] args) {            }
   Socket soc = null;                               }
   InputStream ins = null;                          catch (IOException e) {
   OutputStream outs = null;                          e.printStackTrace();
   try {                                              try {
     soc = new Socket("www.java-users.jp", 80);         if (soc != null) soc.close();
     ins = soc.getInputStream();                      }
     outs = soc.getOutputStream();                    catch(IOException ex) {}
     outs.write("GET / HTTP/1.0nn".getBytes       }
());                                              }
                                                }


  Slide # 9      DevLOVE          Groovy 2011.1.24
BufferedReader bis = new BufferedReader
                                                (new InputStreamReader(ins));
                                                      String line;
public class SocketAccess {                           while ((line = bis.readLine()) != null) {
                                                        System.out.println(line);
  public static void main(String[] args) {            }
   Socket soc = null;                               }
   InputStream ins = null;                          catch (IOException e) {
   OutputStream outs = null;                          e.printStackTrace();
   try {                                              try {
     soc = new Socket("www.java-users.jp", 80);         if (soc != null) soc.close();
     ins = soc.getInputStream();                      }
     outs = soc.getOutputStream();                    catch(IOException ex) {}
     outs.write("GET / HTTP/1.0nn".getBytes       }
());                                              }
                                                }


  Slide #10     DevLOVE           Groovy 2011.1.24
BufferedReader bis = new BufferedReader
                                                (new InputStreamReader(ins));
                                                      String line;
public class SocketAccess {                           while ((line = bis.readLine()) != null) {
                                                        System.out.println(line);
  public static void main(String[] args) {            }
   Socket soc = null;                               }
   InputStream ins = null;                          catch (IOException e) {
   OutputStream outs = null;                          e.printStackTrace();
   try {                                              try {
     soc = new Socket("www.java-users.jp", 80);         if (soc != null) soc.close();
     ins = soc.getInputStream();                      }
     outs = soc.getOutputStream();                    catch(IOException ex) {}
     outs.write("GET / HTTP/1.0nn".getBytes       }
());                                              }
                                                }


  Slide #10     DevLOVE           Groovy 2011.1.24
BufferedReader bis = new BufferedReader
                                                (new InputStreamReader(ins));
                                                    String line;
                                                    while ((line = bis.readLine()) != null) {
                                                      System.out.println(line);
                                                    }
   Socket soc = null;                             }
   InputStream ins = null;                        catch (IOException e) {
   OutputStream outs = null;                        e.printStackTrace();
   try {                                            try {
     soc = new Socket("www.java-users.jp", 80);       if (soc != null) soc.close();
     ins = soc.getInputStream();                    }
     outs = soc.getOutputStream();                  catch(IOException ex) {}
     outs.write("GET / HTTP/1.0nn".getBytes     }
());



  Slide #11     DevLOVE          Groovy 2011.1.24
BufferedReader bis = new BufferedReader
                                                (new InputStreamReader(ins));
                                                    String line;
                                                    while ((line = bis.readLine()) != null) {
                                                      System.out.println(line);
                                                    }
   Socket soc = null;                             }
   InputStream ins = null;                        catch (IOException e) {
   OutputStream outs = null;                        e.printStackTrace();
   try {                                            try {
     soc = new Socket("www.java-users.jp", 80);       if (soc != null) soc.close();
     ins = soc.getInputStream();                    }
     outs = soc.getOutputStream();                  catch(IOException ex) {}
     outs.write("GET / HTTP/1.0nn".getBytes     }
());



  Slide #11     DevLOVE          Groovy 2011.1.24
BufferedReader bis = new BufferedReader
                                                    (new InputStreamReader(ins));
                                                       String line;
                                                       while ((line = bis.readLine()) != null) {
                                                         System.out.println(line);
                                                       }
   Socket soc = null;
   InputStream ins = null;
   OutputStream outs = null;

       soc = new Socket("www.java-users.jp", 80);       if (soc != null) soc.close();
       ins = soc.getInputStream();
       outs = soc.getOutputStream();
       outs.write("GET / HTTP/1.0nn".getBytes
());



   Slide #12       DevLOVE          Groovy 2011.1.24
BufferedReader bis = new BufferedReader
                                                    (new InputStreamReader(ins));
                                                       String line;
                                                       while ((line = bis.readLine()) != null) {
                                                         System.out.println(line);
                                                       }
   Socket soc = null;
   InputStream ins = null;
   OutputStream outs = null;

       soc = new Socket("www.java-users.jp", 80);       if (soc != null) soc.close();
       ins = soc.getInputStream();
       outs = soc.getOutputStream();
       outs.write("GET / HTTP/1.0nn".getBytes
());



   Slide #12       DevLOVE          Groovy 2011.1.24
bis = new BufferedReader(new
                                                    InputStreamReader(ins));
                                                       def line = null;
                                                       while ((line = bis.readLine()) != null) {
                                                         System.out.println(line);
                                                       }
   def soc = null;
   def ins = null;
   def outs = null;

       soc = new Socket("www.java-users.jp", 80);        if (soc != null) soc.close();
       ins = soc.getInputStream();
       outs = soc.getOutputStream();
       outs.write("GET / HTTP/1.0nn".getBytes
());



   Slide #13       DevLOVE          Groovy 2011.1.24
bis = new BufferedReader(new
                                                    InputStreamReader(ins));
                                                       def line = null;
                                                       while ((line = bis.readLine()) != null) {
                                                         System.out.println(line);
                                                       }
   def soc = null;
   def ins = null;
   def outs = null;

       soc = new Socket("www.java-users.jp", 80);        if (soc != null) soc.close();
       ins = soc.getInputStream();
       outs = soc.getOutputStream();
       outs.write("GET / HTTP/1.0nn".getBytes
());



   Slide #13       DevLOVE          Groovy 2011.1.24
bis = new BufferedReader(new
                                                  InputStreamReader(ins));
                                                      def line = null;
                                                      while ((line = bis.readLine()) != null) {
                                                        System.out.println(line);
                                                      }
                                                    }



    new Socket("www.java-users.jp",
80).withStreams { ins, outs ->

       outs.write("GET / HTTP/1.0nn".getBytes
());



   Slide #14       DevLOVE          Groovy 2011.1.24
bis = new BufferedReader(new
                                                  InputStreamReader(ins));
                                                      def line = null;
                                                      while ((line = bis.readLine()) != null) {
                                                        System.out.println(line);
                                                      }
                                                    }



    new Socket("www.java-users.jp",
80).withStreams { ins, outs ->

       outs.write("GET / HTTP/1.0nn".getBytes
());



   Slide #14       DevLOVE          Groovy 2011.1.24
ins.eachLine{ line ->
                                                          System.out.println(line);
                                                        }
                                                   }



    new Socket("www.java-users.jp",
80).withStreams { ins, outs ->

       outs.write("GET / HTTP/1.0nn".getBytes
());



   Slide #15       DevLOVE          Groovy 2011.1.24
new Socket("www.java-users.jp", 80).withStreams { ins, outs ->
    outs.write("GET / HTTP/1.0nn".getBytes());
    ins.eachLine { line ->
     System.out.println(line);
   }
 }




Slide #16    DevLOVE           Groovy 2011.1.24
new Socket("www.java-users.jp", 80).withStreams { ins, outs ->
    outs.write("GET / HTTP/1.0nn".getBytes());
    ins.eachLine { line ->
     System.out.println(line);
   }
 }




Slide #17    DevLOVE           Groovy 2011.1.24
new Socket("www.java-users.jp", 80).withStreams { ins, outs ->
    outs.write("GET / HTTP/1.0nn".getBytes());
    ins.eachLine { line ->
     System.out.println(line);
   }
 }




Slide #17    DevLOVE           Groovy 2011.1.24
new Socket("www.java-users.jp", 80).withStreams { ins, outs ->
    outs.write("GET / HTTP/1.0nn".bytes);
    ins.eachLine { line ->
     System.out.println(line);
   }
 }




Slide #18    DevLOVE           Groovy 2011.1.24
new Socket("www.java-users.jp", 80).withStreams { ins, outs ->
    outs.write("GET / HTTP/1.0nn".bytes);
    ins.eachLine { line ->
     System.out.println(line);
   }
 }




Slide #18    DevLOVE           Groovy 2011.1.24
new Socket("www.java-users.jp", 80).withStreams { ins, outs ->
    outs.write("GET / HTTP/1.0nn".bytes);
    ins.eachLine { line ->
     println(line);
   }
 }




Slide #19    DevLOVE           Groovy 2011.1.24
new Socket("www.java-users.jp", 80).withStreams { ins, outs ->
    outs.write("GET / HTTP/1.0nn".bytes);
    ins.eachLine { line ->
     println(line);
   }
 }




Slide #19    DevLOVE           Groovy 2011.1.24
new Socket("www.java-users.jp", 80).withStreams { ins, outs ->
    outs.write("GET / HTTP/1.0nn".bytes);
    ins.eachLine {
     println(it);
   }
 }




Slide #20    DevLOVE           Groovy 2011.1.24
new Socket("www.java-users.jp", 80).withStreams { ins, outs ->
    outs.write("GET / HTTP/1.0nn".bytes);
    ins.eachLine {
     println(it);
   }
 }




Slide #20    DevLOVE           Groovy 2011.1.24
new Socket("www.java-users.jp", 80).withStreams { ins, outs ->
    outs.write("GET / HTTP/1.0nn".bytes)
    ins.eachLine {
     println(it)
   }
 }




Slide #21    DevLOVE           Groovy 2011.1.24
new Socket("www.java-users.jp", 80).withStreams { ins, outs ->
    outs.write("GET / HTTP/1.0nn".bytes)
    ins.eachLine {
     println(it)
   }
 }




Slide #21    DevLOVE           Groovy 2011.1.24
new Socket("www.java-users.jp", 80).withStreams { ins, outs ->
     outs.write "GET / HTTP/1.0nn".bytes
     ins.eachLine {
      println it
    }
  }




Slide #22   DevLOVE       Groovy 2011.1.24
println new URL("http://www.java-users.jp").text




Slide #23   DevLOVE   Groovy 2011.1.24
println new URL("http://www.java-users.jp").text




       Java      Groovy




                                         Java 7



Slide #23   DevLOVE   Groovy 2011.1.24
Gaelyk
                                Grails(Web)
     GSQL                        GSP,GORM
     SwingBuilder               Griffon(GUI)
     MarkupBuilder
                                           GMaven,Maven3
                 /DSL
                                           Hudson   JBoss
      Gant                                 FreeMind
      Gradle
      Spock,EasyB              Gpars
                               Groovy++
Slide #24   DevLOVE     Groovy 2011.1.24
Slide # 25   DevLOVE   Groovy 2011.1.24
Slide #26   DevLOVE   Groovy 2011.1.24
Slide #27   DevLOVE   Groovy 2011.1.24
@Grab('net.sourceforge.htmlunit:htmlunit:2.8')
  import com.gargoylesoftware.htmlunit.WebClient;

  // Ant Bzip2
  new AntBuilder().bzip2(src:args[0], zipfile:args[0]+".bz2")
  // HtmlUnit
  url = "http://pukiwiki.example.com/index.php?
  plugin=attach&pcmd=upload&page=test"
  page = new WebClient().getPage(url)
  file = page.getElementById('_p_attach_file')
  file.valueAttribute = args[0]+".bz2"
  page.getByXPath("//input[@value='          ']")[0].click()




Slide #28   DevLOVE   Groovy 2011.1.24
@Grab('net.sourceforge.htmlunit:htmlunit:2.8')
  import com.gargoylesoftware.htmlunit.WebClient;

  // Ant Bzip2
  new AntBuilder().bzip2(src:args[0], zipfile:args[0]+".bz2")
  // HtmlUnit
  url = "http://pukiwiki.example.com/index.php?
  plugin=attach&pcmd=upload&page=test"
  page = new WebClient().getPage(url)
  file = page.getElementById('_p_attach_file')
  file.valueAttribute = args[0]+".bz2"
  page.getByXPath("//input[@value='          ']")[0].click()




Slide #28   DevLOVE   Groovy 2011.1.24
@Grab('net.sourceforge.htmlunit:htmlunit:2.8')
  import com.gargoylesoftware.htmlunit.WebClient;

  // Ant Bzip2
  new AntBuilder().bzip2(src:args[0], zipfile:args[0]+".bz2")
  // HtmlUnit
  url = "http://pukiwiki.example.com/index.php?
  plugin=attach&pcmd=upload&page=test"
  page = new WebClient().getPage(url)
  file = page.getElementById('_p_attach_file')
  file.valueAttribute = args[0]+".bz2"
  page.getByXPath("//input[@value='          ']")[0].click()




Slide #28   DevLOVE   Groovy 2011.1.24
@Grab('net.sourceforge.htmlunit:htmlunit:2.8')
  import com.gargoylesoftware.htmlunit.WebClient;

  // Ant Bzip2
  new AntBuilder().bzip2(src:args[0], zipfile:args[0]+".bz2")
  // HtmlUnit
  url = "http://pukiwiki.example.com/index.php?
  plugin=attach&pcmd=upload&page=test"
  page = new WebClient().getPage(url)
  file = page.getElementById('_p_attach_file')
  file.valueAttribute = args[0]+".bz2"
  page.getByXPath("//input[@value='          ']")[0].click()




Slide #28   DevLOVE   Groovy 2011.1.24
@Grab('net.sourceforge.htmlunit:htmlunit:2.8')
  import com.gargoylesoftware.htmlunit.WebClient;




Slide #29   DevLOVE   Groovy 2011.1.24
// Ant Bzip2
  new AntBuilder().bzip2(src:args[0], zipfile:args[0]+".bz2")




Slide #30   DevLOVE   Groovy 2011.1.24
Slide #31   DevLOVE   Groovy 2011.1.24
cities.csv
                                         ,35676000,
                                                 ,19040000,
                                                      =                 ,1018000,
                                                          ,5492000,




Slide #31   DevLOVE   Groovy 2011.1.24
cities.csv
                                                 ,35676000,
                                                         ,19040000,
                      ,   ,                                   =                 ,1018000,
                                                                  ,5492000,




Slide #31   DevLOVE           Groovy 2011.1.24
@Grab('com.h2database:h2:1.2.143')
@GrabConfig(systemClassLoader=true)
import groovy.sql.Sql
sql = Sql.newInstance("jdbc:h2:cities")
sql.execute """ CREATE TABLE Cities (
                  id INT IDENTITY PRIMARY KEY, name VARCHAR,
                  population DECIMAL(10), country VARCHAR)"""
cities = sql.dataSet("Cities")
new File("cities.csv").splitEachLine(",") { f1, f2, f3 ->
  //
  cities.add(name:f1, population:f2, country:f3)
}
assert cities.findAll{ it.country=="    " &&
                          it.population>1000000 }.rows()*.name ==
    ['      ', '   =    (   )', '    ', '     ', '   ']




Slide #32     DevLOVE     Groovy 2011.1.24
@Grab('com.h2database:h2:1.2.143')
@GrabConfig(systemClassLoader=true)
import groovy.sql.Sql
sql = Sql.newInstance("jdbc:h2:cities")
sql.execute """ CREATE TABLE Cities (
                  id INT IDENTITY PRIMARY KEY, name VARCHAR,
                  population DECIMAL(10), country VARCHAR)"""
cities = sql.dataSet("Cities")
new File("cities.csv").splitEachLine(",") { f1, f2, f3 ->
  //
  cities.add(name:f1, population:f2, country:f3)
}
assert cities.findAll{ it.country=="    " &&
                          it.population>1000000 }.rows()*.name ==
    ['      ', '   =    (   )', '    ', '     ', '   ']




Slide #32     DevLOVE     Groovy 2011.1.24
@Grab('com.h2database:h2:1.2.143')
@GrabConfig(systemClassLoader=true)
import groovy.sql.Sql
sql = Sql.newInstance("jdbc:h2:cities")
sql.execute """ CREATE TABLE Cities (
                  id INT IDENTITY PRIMARY KEY, name VARCHAR,
                  population DECIMAL(10), country VARCHAR)"""
cities = sql.dataSet("Cities")
new File("cities.csv").splitEachLine(",") { f1, f2, f3 ->
  //
  cities.add(name:f1, population:f2, country:f3)
}
assert cities.findAll{ it.country=="    " &&
                          it.population>1000000 }.rows()*.name ==
    ['      ', '   =    (   )', '    ', '     ', '   ']




Slide #32     DevLOVE     Groovy 2011.1.24
@Grab('com.h2database:h2:1.2.143')
@GrabConfig(systemClassLoader=true)
import groovy.sql.Sql
sql = Sql.newInstance("jdbc:h2:cities")
sql.execute """ CREATE TABLE Cities (
                  id INT IDENTITY PRIMARY KEY, name VARCHAR,
                  population DECIMAL(10), country VARCHAR)"""
cities = sql.dataSet("Cities")
new File("cities.csv").splitEachLine(",") { f1, f2, f3 ->
  //
  cities.add(name:f1, population:f2, country:f3)
}
assert cities.findAll{ it.country=="    " &&
                          it.population>1000000 }.rows()*.name ==
    ['      ', '   =    (   )', '    ', '     ', '   ']




Slide #32     DevLOVE     Groovy 2011.1.24
@Grab('com.h2database:h2:1.2.143')
@GrabConfig(systemClassLoader=true)
import groovy.sql.Sql
sql = Sql.newInstance("jdbc:h2:cities")
sql.execute """ CREATE TABLE Cities (
                  id INT IDENTITY PRIMARY KEY, name VARCHAR,
                  population DECIMAL(10), country VARCHAR)"""
cities = sql.dataSet("Cities")
new File("cities.csv").splitEachLine(",") { f1, f2, f3 ->
  //
  cities.add(name:f1, population:f2, country:f3)
}
assert cities.findAll{ it.country=="    " &&
                          it.population>1000000 }.rows()*.name ==
    ['      ', '   =    (   )', '    ', '     ', '   ']




Slide #32     DevLOVE     Groovy 2011.1.24
@Grab('com.h2database:h2:1.2.143')
@GrabConfig(systemClassLoader=true)
import groovy.sql.Sql




Slide #33   DevLOVE    Groovy 2011.1.24
cities = sql.dataSet("Cities")
new File("cities.csv").splitEachLine(",") { f1, f2, f3 ->
  //
  cities.add(name:f1, population:f2, country:f3)
}




Slide #34   DevLOVE    Groovy 2011.1.24
cities = sql.dataSet("Cities")


assert cities.findAll{ it.country=="          " &&
                          it.population>1000000 }.rows()*.name ==
    ['      ', '   =    (   )', '    ', '     ', '   ']




cities = sql.dataSet("Cities")


assert cities.findAll{ it.country=="          " }
                 .findAll{ it.population>1000000 }.rows()*.name ==
    ['      ', '    =    (   )', '    ', '     ', '   ']




Slide #35     DevLOVE      Groovy 2011.1.24
Slide # 36   DevLOVE   Groovy 2011.1.24
update




                          http://d.hatena.ne.jp/ksky/20090618/p1
Slide #37   DevLOVE   Groovy 2011.1.24
update




                                                                   !




                          http://d.hatena.ne.jp/ksky/20090618/p1
Slide #37   DevLOVE   Groovy 2011.1.24
http://kokucheese.com/event/index/5267/

Slide #38   DevLOVE    Groovy 2011.1.24
http://bit.ly/g5iE0m


Slide #39    DevLOVE      Groovy 2011.1.24
Slide # 40   DevLOVE   Groovy 2011.1.24
Slide #41   DevLOVE   Groovy 2011.1.24
update




Slide #42   DevLOVE   Groovy 2011.1.24
http://kobo.github.com/groovyserv/




Slide # 43   DevLOVE   Groovy 2011.1.24
Slide #44   DevLOVE   Groovy 2011.1.24
Shell Environment                              User Groovy
                                                                   Srcipt
               C
                LA
                SS . lin
                  PA
               cm
                                                              System.in

                    TH
                     d
                                                             System.out

                       en
                         e


                          v
                                                             SYstem.err
                           ar
                              gs

               Ctrl-C
                                  groovyclient          TCP/IP
                                                                   groovyserver
                           n
                      di
                    st
                      de t
                    st dou
                        rr




                                                                          JavaVM
                       st




                               exit status
                                             File System

                                                 Authentication
                                                 Cookie File




Slide #   DevLOVE                  Groovy 2011.1.24
            45
User Groovy
                      Shell Environment
                                 Srcipt
                 C
                  LA
                                                System.in
                  SS . lin
                    PA
                 cm
                                               System.out

                      TH
                       d
                                               SYstem.err

                         en
                           e


                            v
                             ar
                                gs

                 Ctrl-C
                                     groovy


                             n
                        di
                      st
                        de t
                      st dou




                                      JavaVM
                          rr
                         st




                       exit status
                                               File System




Slide #46   DevLOVE               Groovy 2011.1.24
19.6




      normal groovy                                  3.041                         1.0
      Installer   groovy                             1.262                         2.4
      groovyclient(C       )                         0.155                         19.6
      groovyclient(Ruby        )                     0.193                         15.8
                  •Groovy 1.7.3, GroovyServ 0.4-SNAPSHOT, WinXP SP3,Core2Duo 2GHz,JDK1
Slide #           •time
                    DevLOVE real                   10
                                           Groovy 2011.1.24
35.8




         normal groovy                                 1.112                         1.0
         Mac Ports   groovy(1.7.2)                     0.321                         3.5
         groovyclient(C   )                            0.031                         35.8
         groovyclient(Ruby    )                        0.041                         27.1
        •Groovy 1.7.3, GroovyServ 0.4-SNAPSHOT, MacOSX 10.6.3, MacBook Core2duo 2.53GHz, JDK1.6.0u20
        •time            real            10
Slide #48       DevLOVE               Groovy 2011.1.24
for (i=0; i<1000000; i++) {};

       groovy(Client VM)                                            593.7
       groovy(Server VM)                                            243.8
       groovyclient(Client VM)                                      454.6
       groovyclient(Server VM)                                      197.0

                     •Groovy 1.7.3, GroovyServ 0.4, Windows XP SP3(cygwin 1.7.5),Core2duo 2.00GHz, JDK1.6.0u13
Slide #49        DevLOVE
                   •time               Groovy 2011.1.24
                                     real
Groovy

                for (i=0; i<1000000; i++) {};


       scalac                                         6.6      1.0
       fsc                                            1.2      5.5
       scalac/GroovyServ                              1.1      6.6
       fsc/GroovyServ                                 0.4      16.5


Slide #50         DevLOVE                   Groovy 2011.1.24
Slide #51   DevLOVE   Groovy 2011.1.24
Slide #52   DevLOVE   Groovy 2011.1.24
new!


thanks for the great work on groovyserv!
I use it everyday and enjoy its performance.
I also give it lots of credit in my workshops and talks.
(you may have recognized the additional
hackergarten screencast.)
                                                            I was thinking about maybe
                                                              making GroovyServ the
                                                           default way of how groovy
                                                                     executes a script.
 That sounds like a great release to me!
 Congratulations to the team!




    Great work, this thing really helps.


Slide #53    DevLOVE          Groovy 2011.1.24
new!


thanks for the great work on groovyserv!
I use it everyday and enjoy its performance.
I also give it lots of credit in my workshops and talks.
(you may have recognized the additional
hackergarten screencast.)
                                                            I was thinking about maybe
                                                              making GroovyServ the
                                                           default way of how groovy
                                                                     executes a script.
 That sounds like a great release to me!
 Congratulations to the team!




    Great work, this thing really helps.


Slide #53    DevLOVE          Groovy 2011.1.24
Slide #54   DevLOVE   Groovy 2011.1.24
Slide #55   DevLOVE   Groovy 2011.1.24
Slide # 56   DevLOVE   Groovy 2011.1.24
GEP ‥ Groovy Enhancement Proposal
Slide #57   DevLOVE    Groovy 2011.1.24
100
            1   2            3                                                        {         ->
    
  }
              1          100                                 .           (            )

            1         100                                .           (            )
  {         ->
                             + "     6               "
  }
                         "       "
                                                                         http://d.hatena.ne.jp/uehaj/20100919/1284906117


   10.0                                                          18      6
   2                                                             24      6
   6
   [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72,               :
   78, 84, 90, 96]
   6 6                                                           96      6
   12   6
Slide #58         DevLOVE                Groovy 2011.1.24
(100). (     ).              (          )
            (1). (2). (3).                      (    ).                       (     ({     ->
                 (   ). (                      )
   }))
             (1).       (100).                 ((                 .       (         ))).   (        )

            (1).       (100).              (              .           (           )).           (
   ({         ->
                   (        + "   6                 ").       (               )
   }))
                       ("       ").    (             )




Slide #59      DevLOVE                Groovy 2011.1.24
new
 int fib (int n) {
                                               groovyc
     if (n<=1) return 1
     return fib(n-1) + fib(n-2)               jad
 }




Slide #60   DevLOVE        Groovy 2011.1.24
new
  int fib (int n) {
                                                  groovyc
      if (n<=1) return 1
      return fib(n-1) + fib(n-2)                 jad
  }



public int fib(int n)
{
    CallSite acallsite[] = $getCallSiteArray();
    if(ScriptBytecodeAdapter.compareLessThanEqual
(DefaultTypeTransformation.box(n), $const$0))
        return DefaultTypeTransformation.intUnbox((Integer)
ScriptBytecodeAdapter.castToType($const$0, $get$$class$java$lang$Integer()));
    else
        return DefaultTypeTransformation.intUnbox((Integer)
ScriptBytecodeAdapter.castToType(acallsite[0].call(acallsite[1].callCurrent
(this, acallsite[2].call(DefaultTypeTransformation.box(n), $const$0)),
acallsite[3].callCurrent(this, acallsite[4].call
(DefaultTypeTransformation.box(n), $const$1))), $get$$class$java$lang$Integer
()));
}


 Slide #60    DevLOVE         Groovy 2011.1.24
new
  int fib (int n) {
                                                     groovyc
      if (n<=1) return 1
      return fib(n-1) + fib(n-2)                    jad
  }



                                  public int fib(int n)
public int fib(int n)           {
{                                   CallSite acallsite[] = $getCallSiteArray();
    CallSite acallsite[] = $getCallSiteArray();
                                    if(!ScriptBytecodeAdapter.isOrigInt())
                                        if(ScriptBytecodeAdapter.compareLessThanEqual((Integer)
    if(ScriptBytecodeAdapter.compareLessThanEqual
                                DefaultTypeTransformation.box(n), (Integer)
(DefaultTypeTransformation.box(n), $const$0))
                                DefaultTypeTransformation.box(1)))
        return DefaultTypeTransformation.intUnbox((Integer)
                                            return 1;
ScriptBytecodeAdapter.castToType($const$0, $get$$class$java$lang$Integer()));
                                        else
    else                                    return DefaultTypeTransformation.intUnbox(acallsite
        return DefaultTypeTransformation.intUnbox((Integer)
                                [0].call(acallsite[1].callCurrent(this, acallsite[2].call
ScriptBytecodeAdapter.castToType(acallsite[0].call(acallsite[1].callCurrent
                                ((Integer)DefaultTypeTransformation.box(n), (Integer)
                                DefaultTypeTransformation.box(1))), acallsite[3].callCurrent
(this, acallsite[2].call(DefaultTypeTransformation.box(n), $const$0)),
                                (this, acallsite[4].call((Integer)DefaultTypeTransformation.box
acallsite[3].callCurrent(this, acallsite[4].call
                                (n), (Integer)DefaultTypeTransformation.box(2)))));
(DefaultTypeTransformation.box(n), $const$1))), $get$$class$java$lang$Integer
                                    if(n <= 1)
()));
                                        return 1;
}                                   else
                                          return fib(n - 1) + fib(n - 2);
                                  }
 Slide #60      DevLOVE          Groovy 2011.1.24
new
  int fib (int n) {
                                                     groovyc
      if (n<=1) return 1
      return fib(n-1) + fib(n-2)                    jad
  }



                                  public int fib(int n)
public int fib(int n)           {
{                                   CallSite acallsite[] = $getCallSiteArray();
    CallSite acallsite[] = $getCallSiteArray();
                                    if(!ScriptBytecodeAdapter.isOrigInt())
                                        if(ScriptBytecodeAdapter.compareLessThanEqual((Integer)
    if(ScriptBytecodeAdapter.compareLessThanEqual
                                DefaultTypeTransformation.box(n), (Integer)
(DefaultTypeTransformation.box(n), $const$0))
                                DefaultTypeTransformation.box(1)))
        return DefaultTypeTransformation.intUnbox((Integer)
                                            return 1;
ScriptBytecodeAdapter.castToType($const$0, $get$$class$java$lang$Integer()));
                                        else
    else                                    return DefaultTypeTransformation.intUnbox(acallsite
        return DefaultTypeTransformation.intUnbox((Integer)
                                [0].call(acallsite[1].callCurrent(this, acallsite[2].call
ScriptBytecodeAdapter.castToType(acallsite[0].call(acallsite[1].callCurrent
                                ((Integer)DefaultTypeTransformation.box(n), (Integer)
                                DefaultTypeTransformation.box(1))), acallsite[3].callCurrent
(this, acallsite[2].call(DefaultTypeTransformation.box(n), $const$0)),
                                (this, acallsite[4].call((Integer)DefaultTypeTransformation.box
acallsite[3].callCurrent(this, acallsite[4].call
                                (n), (Integer)DefaultTypeTransformation.box(2)))));
(DefaultTypeTransformation.box(n), $const$1))), $get$$class$java$lang$Integer
                                    if(n <= 1)
()));
                                        return 1;
}                                   else
                                          return fib(n - 1) + fib(n - 2);
                                  }
 Slide #60      DevLOVE          Groovy 2011.1.24
new
  int fib (int n) {
                                                     groovyc
      if (n<=1) return 1
      return fib(n-1) + fib(n-2)                    jad
  }



                                  public int fib(int n)
public int fib(int n)           {
{                                   CallSite acallsite[] = $getCallSiteArray();
                               if(n <= 1)
    CallSite acallsite[] = $getCallSiteArray();
                                    if(!ScriptBytecodeAdapter.isOrigInt())
                                       if(ScriptBytecodeAdapter.compareLessThanEqual((Integer)
                                   return 1;
    if(ScriptBytecodeAdapter.compareLessThanEqual
                                DefaultTypeTransformation.box(n), (Integer)
(DefaultTypeTransformation.box(n), $const$0))
                               else
                                DefaultTypeTransformation.box(1)))
        return DefaultTypeTransformation.intUnbox((Integer)
                                            return 1;
                                       else fib(n - 1) + fib(n - 2);
                                   return
ScriptBytecodeAdapter.castToType($const$0, $get$$class$java$lang$Integer()));
    else                                    return DefaultTypeTransformation.intUnbox(acallsite
        return DefaultTypeTransformation.intUnbox((Integer)
                                [0].call(acallsite[1].callCurrent(this, acallsite[2].call
ScriptBytecodeAdapter.castToType(acallsite[0].call(acallsite[1].callCurrent
                                ((Integer)DefaultTypeTransformation.box(n), (Integer)
                                DefaultTypeTransformation.box(1))), acallsite[3].callCurrent
(this, acallsite[2].call(DefaultTypeTransformation.box(n), $const$0)),
                                (this, acallsite[4].call((Integer)DefaultTypeTransformation.box
acallsite[3].callCurrent(this, acallsite[4].call
                                (n), (Integer)DefaultTypeTransformation.box(2)))));
(DefaultTypeTransformation.box(n), $const$1))), $get$$class$java$lang$Integer
                                    if(n <= 1)
()));
                                        return 1;
}                                   else
                                          return fib(n - 1) + fib(n - 2);
                                  }
 Slide #60      DevLOVE          Groovy 2011.1.24
new
     long begin = System.nanoTime();
     FibJava foo = new FibJava();
     int result = foo.fib(32); //
     long end = System.nanoTime();
     System.out.println("Elapsed time: " + (end - begin) + "ns");


                                                                     (ns)         Java   1


     Groovy 1.7.5                                  1,639,852,000                             66.46

     Groovy 1.8.0 beta 3                                 65,497,000                           2.65

     Java(OpenJDK 1.7)                                   24,672,000                            1.0

            • MacOSX 10.6.3, MacBook Core2duo 2.53GHz,openjdk version "1.7.0-internal"
Slide #61   DevLOVE                 Groovy 2011.1.24
@Invariant({ elements != null })                         
     class Stack {                                                 def boolean is_empty()  {
                                                                       elements.isEmpty()
         private List elements                                     }
                                                             
         @Ensures({ is_empty() })                                  @Requires({ !is_empty() })
         public Stack()  {                                         def last_item()  {
             elements = []                                             elements.last()
         }                                                         }
                                                             
         @Requires({ preElements?.size() >                         def count() {
    0 })                                                               elements.size()
         @Ensures({ !is_empty() })                                 }
         public Stack(List preElements)  {
             elements = preElements
         }
     http://github.com/andresteingress/gcontracts/wiki
Slide #62        DevLOVE                 Groovy 2011.1.24
update
        http://canoo.com/blog/2010/09/20/log-groovys-new-and-extensible-logging-conveniences/

Slide #63       DevLOVE              Groovy 2011.1.24
import groovy.util.logging.Log
     @Log
     class MyClass {
         def invoke() {
             log.info('... an info message')
             log.fine('... a fine message')
         }
     }

    http://canoo.com/blog/2010/09/20/log-groovys-new-and-extensible-logging-conveniences/
Slide #64       DevLOVE              Groovy 2011.1.24
New!




Slide #65   DevLOVE   Groovy 2011.1.24
http://kokucheese.com/event/index/5267/

                      Groovy&Grails exchange 2010@London                by
                 tyama, tamada (               )
                      Gradle       G*                      by   (LITERAL-ICE)

Slide #66   DevLOVE        Groovy 2011.1.24
http://kokucheese.com/event/index/5267/

                      Groovy&Grails exchange 2010@London                by
                 tyama, tamada (               )
                      Gradle       G*                      by   (LITERAL-ICE)

Slide #66   DevLOVE        Groovy 2011.1.24
Slide # 67   DevLOVE   Groovy 2011.1.24

More Related Content

Easy Going Groovy 2nd season on DevLOVE

  • 2. Slide # 2 DevLOVE Groovy 2011.1.24
  • 3. http://d.hatena.ne.jp/uehaj/ Slide # 3 DevLOVE Groovy 2011.1.24
  • 4. new! JJUG CCC update Slide # 4 DevLOVE Groovy 2011.1.24
  • 5. Slide # 5 DevLOVE Groovy 2011.1.24
  • 6. Slide # 6 DevLOVE Groovy 2011.1.24
  • 7. import java.io.*; BufferedReader bis = new BufferedReader import java.net.*; (new InputStreamReader(ins)); String line; public class SocketAccess { while ((line = bis.readLine()) != null) { System.out.println(line); public static void main(String[] args) { } Socket soc = null; } InputStream ins = null; catch (IOException e) { OutputStream outs = null; e.printStackTrace(); try { try { soc = new Socket("www.java-users.jp", 80); if (soc != null) soc.close(); ins = soc.getInputStream(); } outs = soc.getOutputStream(); catch(IOException ex) {} outs.write("GET / HTTP/1.0nn".getBytes } ()); } } Slide # 7 DevLOVE Groovy 2011.1.24
  • 8. import java.io.*; BufferedReader bis = new BufferedReader import java.net.*; (new InputStreamReader(ins)); String line; public class SocketAccess { while ((line = bis.readLine()) != null) { System.out.println(line); public static void main(String[] args) { } Socket soc = null; } InputStream ins = null; catch (IOException e) { OutputStream outs = null; e.printStackTrace(); try { try { soc = new Socket("www.java-users.jp", 80); if (soc != null) soc.close(); ins = soc.getInputStream(); } outs = soc.getOutputStream(); catch(IOException ex) {} outs.write("GET / HTTP/1.0nn".getBytes } ()); } } Slide # 8 DevLOVE Groovy 2011.1.24
  • 9. import java.io.*; BufferedReader bis = new BufferedReader import java.net.*; (new InputStreamReader(ins)); String line; public class SocketAccess { while ((line = bis.readLine()) != null) { System.out.println(line); public static void main(String[] args) { } Socket soc = null; } InputStream ins = null; catch (IOException e) { OutputStream outs = null; e.printStackTrace(); try { try { soc = new Socket("www.java-users.jp", 80); if (soc != null) soc.close(); ins = soc.getInputStream(); } outs = soc.getOutputStream(); catch(IOException ex) {} outs.write("GET / HTTP/1.0nn".getBytes } ()); } } Slide # 8 DevLOVE Groovy 2011.1.24
  • 10. import java.io.*; BufferedReader bis = new BufferedReader import java.net.*; (new InputStreamReader(ins)); String line; public class SocketAccess { while ((line = bis.readLine()) != null) { System.out.println(line); public static void main(String[] args) { } Socket soc = null; } InputStream ins = null; catch (IOException e) { OutputStream outs = null; e.printStackTrace(); try { try { soc = new Socket("www.java-users.jp", 80); if (soc != null) soc.close(); ins = soc.getInputStream(); } outs = soc.getOutputStream(); catch(IOException ex) {} outs.write("GET / HTTP/1.0nn".getBytes } ()); } } Slide # 9 DevLOVE Groovy 2011.1.24
  • 11. import java.io.*; BufferedReader bis = new BufferedReader import java.net.*; (new InputStreamReader(ins)); String line; public class SocketAccess { while ((line = bis.readLine()) != null) { System.out.println(line); public static void main(String[] args) { } Socket soc = null; } InputStream ins = null; catch (IOException e) { OutputStream outs = null; e.printStackTrace(); try { try { soc = new Socket("www.java-users.jp", 80); if (soc != null) soc.close(); ins = soc.getInputStream(); } outs = soc.getOutputStream(); catch(IOException ex) {} outs.write("GET / HTTP/1.0nn".getBytes } ()); } } Slide # 9 DevLOVE Groovy 2011.1.24
  • 12. BufferedReader bis = new BufferedReader (new InputStreamReader(ins)); String line; public class SocketAccess { while ((line = bis.readLine()) != null) { System.out.println(line); public static void main(String[] args) { } Socket soc = null; } InputStream ins = null; catch (IOException e) { OutputStream outs = null; e.printStackTrace(); try { try { soc = new Socket("www.java-users.jp", 80); if (soc != null) soc.close(); ins = soc.getInputStream(); } outs = soc.getOutputStream(); catch(IOException ex) {} outs.write("GET / HTTP/1.0nn".getBytes } ()); } } Slide #10 DevLOVE Groovy 2011.1.24
  • 13. BufferedReader bis = new BufferedReader (new InputStreamReader(ins)); String line; public class SocketAccess { while ((line = bis.readLine()) != null) { System.out.println(line); public static void main(String[] args) { } Socket soc = null; } InputStream ins = null; catch (IOException e) { OutputStream outs = null; e.printStackTrace(); try { try { soc = new Socket("www.java-users.jp", 80); if (soc != null) soc.close(); ins = soc.getInputStream(); } outs = soc.getOutputStream(); catch(IOException ex) {} outs.write("GET / HTTP/1.0nn".getBytes } ()); } } Slide #10 DevLOVE Groovy 2011.1.24
  • 14. BufferedReader bis = new BufferedReader (new InputStreamReader(ins)); String line; while ((line = bis.readLine()) != null) { System.out.println(line); } Socket soc = null; } InputStream ins = null; catch (IOException e) { OutputStream outs = null; e.printStackTrace(); try { try { soc = new Socket("www.java-users.jp", 80); if (soc != null) soc.close(); ins = soc.getInputStream(); } outs = soc.getOutputStream(); catch(IOException ex) {} outs.write("GET / HTTP/1.0nn".getBytes } ()); Slide #11 DevLOVE Groovy 2011.1.24
  • 15. BufferedReader bis = new BufferedReader (new InputStreamReader(ins)); String line; while ((line = bis.readLine()) != null) { System.out.println(line); } Socket soc = null; } InputStream ins = null; catch (IOException e) { OutputStream outs = null; e.printStackTrace(); try { try { soc = new Socket("www.java-users.jp", 80); if (soc != null) soc.close(); ins = soc.getInputStream(); } outs = soc.getOutputStream(); catch(IOException ex) {} outs.write("GET / HTTP/1.0nn".getBytes } ()); Slide #11 DevLOVE Groovy 2011.1.24
  • 16. BufferedReader bis = new BufferedReader (new InputStreamReader(ins)); String line; while ((line = bis.readLine()) != null) { System.out.println(line); } Socket soc = null; InputStream ins = null; OutputStream outs = null; soc = new Socket("www.java-users.jp", 80); if (soc != null) soc.close(); ins = soc.getInputStream(); outs = soc.getOutputStream(); outs.write("GET / HTTP/1.0nn".getBytes ()); Slide #12 DevLOVE Groovy 2011.1.24
  • 17. BufferedReader bis = new BufferedReader (new InputStreamReader(ins)); String line; while ((line = bis.readLine()) != null) { System.out.println(line); } Socket soc = null; InputStream ins = null; OutputStream outs = null; soc = new Socket("www.java-users.jp", 80); if (soc != null) soc.close(); ins = soc.getInputStream(); outs = soc.getOutputStream(); outs.write("GET / HTTP/1.0nn".getBytes ()); Slide #12 DevLOVE Groovy 2011.1.24
  • 18. bis = new BufferedReader(new InputStreamReader(ins)); def line = null; while ((line = bis.readLine()) != null) { System.out.println(line); } def soc = null; def ins = null; def outs = null; soc = new Socket("www.java-users.jp", 80); if (soc != null) soc.close(); ins = soc.getInputStream(); outs = soc.getOutputStream(); outs.write("GET / HTTP/1.0nn".getBytes ()); Slide #13 DevLOVE Groovy 2011.1.24
  • 19. bis = new BufferedReader(new InputStreamReader(ins)); def line = null; while ((line = bis.readLine()) != null) { System.out.println(line); } def soc = null; def ins = null; def outs = null; soc = new Socket("www.java-users.jp", 80); if (soc != null) soc.close(); ins = soc.getInputStream(); outs = soc.getOutputStream(); outs.write("GET / HTTP/1.0nn".getBytes ()); Slide #13 DevLOVE Groovy 2011.1.24
  • 20. bis = new BufferedReader(new InputStreamReader(ins)); def line = null; while ((line = bis.readLine()) != null) { System.out.println(line); } } new Socket("www.java-users.jp", 80).withStreams { ins, outs -> outs.write("GET / HTTP/1.0nn".getBytes ()); Slide #14 DevLOVE Groovy 2011.1.24
  • 21. bis = new BufferedReader(new InputStreamReader(ins)); def line = null; while ((line = bis.readLine()) != null) { System.out.println(line); } } new Socket("www.java-users.jp", 80).withStreams { ins, outs -> outs.write("GET / HTTP/1.0nn".getBytes ()); Slide #14 DevLOVE Groovy 2011.1.24
  • 22. ins.eachLine{ line -> System.out.println(line); } } new Socket("www.java-users.jp", 80).withStreams { ins, outs -> outs.write("GET / HTTP/1.0nn".getBytes ()); Slide #15 DevLOVE Groovy 2011.1.24
  • 23. new Socket("www.java-users.jp", 80).withStreams { ins, outs -> outs.write("GET / HTTP/1.0nn".getBytes()); ins.eachLine { line -> System.out.println(line); } } Slide #16 DevLOVE Groovy 2011.1.24
  • 24. new Socket("www.java-users.jp", 80).withStreams { ins, outs -> outs.write("GET / HTTP/1.0nn".getBytes()); ins.eachLine { line -> System.out.println(line); } } Slide #17 DevLOVE Groovy 2011.1.24
  • 25. new Socket("www.java-users.jp", 80).withStreams { ins, outs -> outs.write("GET / HTTP/1.0nn".getBytes()); ins.eachLine { line -> System.out.println(line); } } Slide #17 DevLOVE Groovy 2011.1.24
  • 26. new Socket("www.java-users.jp", 80).withStreams { ins, outs -> outs.write("GET / HTTP/1.0nn".bytes); ins.eachLine { line -> System.out.println(line); } } Slide #18 DevLOVE Groovy 2011.1.24
  • 27. new Socket("www.java-users.jp", 80).withStreams { ins, outs -> outs.write("GET / HTTP/1.0nn".bytes); ins.eachLine { line -> System.out.println(line); } } Slide #18 DevLOVE Groovy 2011.1.24
  • 28. new Socket("www.java-users.jp", 80).withStreams { ins, outs -> outs.write("GET / HTTP/1.0nn".bytes); ins.eachLine { line -> println(line); } } Slide #19 DevLOVE Groovy 2011.1.24
  • 29. new Socket("www.java-users.jp", 80).withStreams { ins, outs -> outs.write("GET / HTTP/1.0nn".bytes); ins.eachLine { line -> println(line); } } Slide #19 DevLOVE Groovy 2011.1.24
  • 30. new Socket("www.java-users.jp", 80).withStreams { ins, outs -> outs.write("GET / HTTP/1.0nn".bytes); ins.eachLine { println(it); } } Slide #20 DevLOVE Groovy 2011.1.24
  • 31. new Socket("www.java-users.jp", 80).withStreams { ins, outs -> outs.write("GET / HTTP/1.0nn".bytes); ins.eachLine { println(it); } } Slide #20 DevLOVE Groovy 2011.1.24
  • 32. new Socket("www.java-users.jp", 80).withStreams { ins, outs -> outs.write("GET / HTTP/1.0nn".bytes) ins.eachLine { println(it) } } Slide #21 DevLOVE Groovy 2011.1.24
  • 33. new Socket("www.java-users.jp", 80).withStreams { ins, outs -> outs.write("GET / HTTP/1.0nn".bytes) ins.eachLine { println(it) } } Slide #21 DevLOVE Groovy 2011.1.24
  • 34. new Socket("www.java-users.jp", 80).withStreams { ins, outs -> outs.write "GET / HTTP/1.0nn".bytes ins.eachLine { println it } } Slide #22 DevLOVE Groovy 2011.1.24
  • 36. println new URL("http://www.java-users.jp").text Java Groovy Java 7 Slide #23 DevLOVE Groovy 2011.1.24
  • 37. Gaelyk Grails(Web) GSQL GSP,GORM SwingBuilder Griffon(GUI) MarkupBuilder GMaven,Maven3 /DSL Hudson JBoss Gant FreeMind Gradle Spock,EasyB Gpars Groovy++ Slide #24 DevLOVE Groovy 2011.1.24
  • 38. Slide # 25 DevLOVE Groovy 2011.1.24
  • 39. Slide #26 DevLOVE Groovy 2011.1.24
  • 40. Slide #27 DevLOVE Groovy 2011.1.24
  • 41. @Grab('net.sourceforge.htmlunit:htmlunit:2.8') import com.gargoylesoftware.htmlunit.WebClient; // Ant Bzip2 new AntBuilder().bzip2(src:args[0], zipfile:args[0]+".bz2") // HtmlUnit url = "http://pukiwiki.example.com/index.php? plugin=attach&pcmd=upload&page=test" page = new WebClient().getPage(url) file = page.getElementById('_p_attach_file') file.valueAttribute = args[0]+".bz2" page.getByXPath("//input[@value=' ']")[0].click() Slide #28 DevLOVE Groovy 2011.1.24
  • 42. @Grab('net.sourceforge.htmlunit:htmlunit:2.8') import com.gargoylesoftware.htmlunit.WebClient; // Ant Bzip2 new AntBuilder().bzip2(src:args[0], zipfile:args[0]+".bz2") // HtmlUnit url = "http://pukiwiki.example.com/index.php? plugin=attach&pcmd=upload&page=test" page = new WebClient().getPage(url) file = page.getElementById('_p_attach_file') file.valueAttribute = args[0]+".bz2" page.getByXPath("//input[@value=' ']")[0].click() Slide #28 DevLOVE Groovy 2011.1.24
  • 43. @Grab('net.sourceforge.htmlunit:htmlunit:2.8') import com.gargoylesoftware.htmlunit.WebClient; // Ant Bzip2 new AntBuilder().bzip2(src:args[0], zipfile:args[0]+".bz2") // HtmlUnit url = "http://pukiwiki.example.com/index.php? plugin=attach&pcmd=upload&page=test" page = new WebClient().getPage(url) file = page.getElementById('_p_attach_file') file.valueAttribute = args[0]+".bz2" page.getByXPath("//input[@value=' ']")[0].click() Slide #28 DevLOVE Groovy 2011.1.24
  • 44. @Grab('net.sourceforge.htmlunit:htmlunit:2.8') import com.gargoylesoftware.htmlunit.WebClient; // Ant Bzip2 new AntBuilder().bzip2(src:args[0], zipfile:args[0]+".bz2") // HtmlUnit url = "http://pukiwiki.example.com/index.php? plugin=attach&pcmd=upload&page=test" page = new WebClient().getPage(url) file = page.getElementById('_p_attach_file') file.valueAttribute = args[0]+".bz2" page.getByXPath("//input[@value=' ']")[0].click() Slide #28 DevLOVE Groovy 2011.1.24
  • 45. @Grab('net.sourceforge.htmlunit:htmlunit:2.8') import com.gargoylesoftware.htmlunit.WebClient; Slide #29 DevLOVE Groovy 2011.1.24
  • 46. // Ant Bzip2 new AntBuilder().bzip2(src:args[0], zipfile:args[0]+".bz2") Slide #30 DevLOVE Groovy 2011.1.24
  • 47. Slide #31 DevLOVE Groovy 2011.1.24
  • 48. cities.csv ,35676000, ,19040000, = ,1018000, ,5492000, Slide #31 DevLOVE Groovy 2011.1.24
  • 49. cities.csv ,35676000, ,19040000, , , = ,1018000, ,5492000, Slide #31 DevLOVE Groovy 2011.1.24
  • 50. @Grab('com.h2database:h2:1.2.143') @GrabConfig(systemClassLoader=true) import groovy.sql.Sql sql = Sql.newInstance("jdbc:h2:cities") sql.execute """ CREATE TABLE Cities (                   id INT IDENTITY PRIMARY KEY, name VARCHAR,                   population DECIMAL(10), country VARCHAR)""" cities = sql.dataSet("Cities") new File("cities.csv").splitEachLine(",") { f1, f2, f3 -> //   cities.add(name:f1, population:f2, country:f3) } assert cities.findAll{ it.country==" " && it.population>1000000 }.rows()*.name == [' ', ' = ( )', ' ', ' ', ' '] Slide #32 DevLOVE Groovy 2011.1.24
  • 51. @Grab('com.h2database:h2:1.2.143') @GrabConfig(systemClassLoader=true) import groovy.sql.Sql sql = Sql.newInstance("jdbc:h2:cities") sql.execute """ CREATE TABLE Cities (                   id INT IDENTITY PRIMARY KEY, name VARCHAR,                   population DECIMAL(10), country VARCHAR)""" cities = sql.dataSet("Cities") new File("cities.csv").splitEachLine(",") { f1, f2, f3 -> //   cities.add(name:f1, population:f2, country:f3) } assert cities.findAll{ it.country==" " && it.population>1000000 }.rows()*.name == [' ', ' = ( )', ' ', ' ', ' '] Slide #32 DevLOVE Groovy 2011.1.24
  • 52. @Grab('com.h2database:h2:1.2.143') @GrabConfig(systemClassLoader=true) import groovy.sql.Sql sql = Sql.newInstance("jdbc:h2:cities") sql.execute """ CREATE TABLE Cities (                   id INT IDENTITY PRIMARY KEY, name VARCHAR,                   population DECIMAL(10), country VARCHAR)""" cities = sql.dataSet("Cities") new File("cities.csv").splitEachLine(",") { f1, f2, f3 -> //   cities.add(name:f1, population:f2, country:f3) } assert cities.findAll{ it.country==" " && it.population>1000000 }.rows()*.name == [' ', ' = ( )', ' ', ' ', ' '] Slide #32 DevLOVE Groovy 2011.1.24
  • 53. @Grab('com.h2database:h2:1.2.143') @GrabConfig(systemClassLoader=true) import groovy.sql.Sql sql = Sql.newInstance("jdbc:h2:cities") sql.execute """ CREATE TABLE Cities (                   id INT IDENTITY PRIMARY KEY, name VARCHAR,                   population DECIMAL(10), country VARCHAR)""" cities = sql.dataSet("Cities") new File("cities.csv").splitEachLine(",") { f1, f2, f3 -> //   cities.add(name:f1, population:f2, country:f3) } assert cities.findAll{ it.country==" " && it.population>1000000 }.rows()*.name == [' ', ' = ( )', ' ', ' ', ' '] Slide #32 DevLOVE Groovy 2011.1.24
  • 54. @Grab('com.h2database:h2:1.2.143') @GrabConfig(systemClassLoader=true) import groovy.sql.Sql sql = Sql.newInstance("jdbc:h2:cities") sql.execute """ CREATE TABLE Cities (                   id INT IDENTITY PRIMARY KEY, name VARCHAR,                   population DECIMAL(10), country VARCHAR)""" cities = sql.dataSet("Cities") new File("cities.csv").splitEachLine(",") { f1, f2, f3 -> //   cities.add(name:f1, population:f2, country:f3) } assert cities.findAll{ it.country==" " && it.population>1000000 }.rows()*.name == [' ', ' = ( )', ' ', ' ', ' '] Slide #32 DevLOVE Groovy 2011.1.24
  • 56. cities = sql.dataSet("Cities") new File("cities.csv").splitEachLine(",") { f1, f2, f3 -> //   cities.add(name:f1, population:f2, country:f3) } Slide #34 DevLOVE Groovy 2011.1.24
  • 57. cities = sql.dataSet("Cities") assert cities.findAll{ it.country==" " && it.population>1000000 }.rows()*.name == [' ', ' = ( )', ' ', ' ', ' '] cities = sql.dataSet("Cities") assert cities.findAll{ it.country==" " } .findAll{ it.population>1000000 }.rows()*.name == [' ', ' = ( )', ' ', ' ', ' '] Slide #35 DevLOVE Groovy 2011.1.24
  • 58. Slide # 36 DevLOVE Groovy 2011.1.24
  • 59. update http://d.hatena.ne.jp/ksky/20090618/p1 Slide #37 DevLOVE Groovy 2011.1.24
  • 60. update ! http://d.hatena.ne.jp/ksky/20090618/p1 Slide #37 DevLOVE Groovy 2011.1.24
  • 62. http://bit.ly/g5iE0m Slide #39 DevLOVE Groovy 2011.1.24
  • 63. Slide # 40 DevLOVE Groovy 2011.1.24
  • 64. Slide #41 DevLOVE Groovy 2011.1.24
  • 65. update Slide #42 DevLOVE Groovy 2011.1.24
  • 67. Slide #44 DevLOVE Groovy 2011.1.24
  • 68. Shell Environment User Groovy Srcipt C LA SS . lin PA cm System.in TH d System.out en e v SYstem.err ar gs Ctrl-C groovyclient TCP/IP groovyserver n di st de t st dou rr JavaVM st exit status File System Authentication Cookie File Slide # DevLOVE Groovy 2011.1.24 45
  • 69. User Groovy Shell Environment Srcipt C LA System.in SS . lin PA cm System.out TH d SYstem.err en e v ar gs Ctrl-C groovy n di st de t st dou JavaVM rr st exit status File System Slide #46 DevLOVE Groovy 2011.1.24
  • 70. 19.6 normal groovy 3.041 1.0 Installer groovy 1.262 2.4 groovyclient(C ) 0.155 19.6 groovyclient(Ruby ) 0.193 15.8 •Groovy 1.7.3, GroovyServ 0.4-SNAPSHOT, WinXP SP3,Core2Duo 2GHz,JDK1 Slide # •time DevLOVE real 10 Groovy 2011.1.24
  • 71. 35.8 normal groovy 1.112 1.0 Mac Ports groovy(1.7.2) 0.321 3.5 groovyclient(C ) 0.031 35.8 groovyclient(Ruby ) 0.041 27.1 •Groovy 1.7.3, GroovyServ 0.4-SNAPSHOT, MacOSX 10.6.3, MacBook Core2duo 2.53GHz, JDK1.6.0u20 •time real 10 Slide #48 DevLOVE Groovy 2011.1.24
  • 72. for (i=0; i<1000000; i++) {}; groovy(Client VM) 593.7 groovy(Server VM) 243.8 groovyclient(Client VM) 454.6 groovyclient(Server VM) 197.0 •Groovy 1.7.3, GroovyServ 0.4, Windows XP SP3(cygwin 1.7.5),Core2duo 2.00GHz, JDK1.6.0u13 Slide #49 DevLOVE •time Groovy 2011.1.24 real
  • 73. Groovy for (i=0; i<1000000; i++) {}; scalac 6.6 1.0 fsc 1.2 5.5 scalac/GroovyServ 1.1 6.6 fsc/GroovyServ 0.4 16.5 Slide #50 DevLOVE Groovy 2011.1.24
  • 74. Slide #51 DevLOVE Groovy 2011.1.24
  • 75. Slide #52 DevLOVE Groovy 2011.1.24
  • 76. new! thanks for the great work on groovyserv! I use it everyday and enjoy its performance. I also give it lots of credit in my workshops and talks. (you may have recognized the additional hackergarten screencast.) I was thinking about maybe making GroovyServ the default way of how groovy executes a script. That sounds like a great release to me! Congratulations to the team! Great work, this thing really helps. Slide #53 DevLOVE Groovy 2011.1.24
  • 77. new! thanks for the great work on groovyserv! I use it everyday and enjoy its performance. I also give it lots of credit in my workshops and talks. (you may have recognized the additional hackergarten screencast.) I was thinking about maybe making GroovyServ the default way of how groovy executes a script. That sounds like a great release to me! Congratulations to the team! Great work, this thing really helps. Slide #53 DevLOVE Groovy 2011.1.24
  • 78. Slide #54 DevLOVE Groovy 2011.1.24
  • 79. Slide #55 DevLOVE Groovy 2011.1.24
  • 80. Slide # 56 DevLOVE Groovy 2011.1.24
  • 81. GEP ‥ Groovy Enhancement Proposal Slide #57 DevLOVE Groovy 2011.1.24
  • 82. 100 1 2 3 { ->    } 1 100 . ( ) 1 100 . ( ) { ->    + " 6 " } " " http://d.hatena.ne.jp/uehaj/20100919/1284906117 10.0 18 6 2 24 6 6 [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, : 78, 84, 90, 96] 6 6 96 6 12 6 Slide #58 DevLOVE Groovy 2011.1.24
  • 83. (100). ( ). ( ) (1). (2). (3). ( ). ( ({ ->    ( ). ( ) })) (1). (100). (( . ( ))). ( ) (1). (100). ( . ( )). ( ({ ->    ( + " 6 "). ( ) })) (" "). ( ) Slide #59 DevLOVE Groovy 2011.1.24
  • 84. new int fib (int n) { groovyc     if (n<=1) return 1     return fib(n-1) + fib(n-2) jad } Slide #60 DevLOVE Groovy 2011.1.24
  • 85. new int fib (int n) { groovyc     if (n<=1) return 1     return fib(n-1) + fib(n-2) jad } public int fib(int n) {     CallSite acallsite[] = $getCallSiteArray();     if(ScriptBytecodeAdapter.compareLessThanEqual (DefaultTypeTransformation.box(n), $const$0))         return DefaultTypeTransformation.intUnbox((Integer) ScriptBytecodeAdapter.castToType($const$0, $get$$class$java$lang$Integer()));     else         return DefaultTypeTransformation.intUnbox((Integer) ScriptBytecodeAdapter.castToType(acallsite[0].call(acallsite[1].callCurrent (this, acallsite[2].call(DefaultTypeTransformation.box(n), $const$0)), acallsite[3].callCurrent(this, acallsite[4].call (DefaultTypeTransformation.box(n), $const$1))), $get$$class$java$lang$Integer ())); } Slide #60 DevLOVE Groovy 2011.1.24
  • 86. new int fib (int n) { groovyc     if (n<=1) return 1     return fib(n-1) + fib(n-2) jad } public int fib(int n) public int fib(int n) { {     CallSite acallsite[] = $getCallSiteArray();     CallSite acallsite[] = $getCallSiteArray();     if(!ScriptBytecodeAdapter.isOrigInt())         if(ScriptBytecodeAdapter.compareLessThanEqual((Integer)     if(ScriptBytecodeAdapter.compareLessThanEqual DefaultTypeTransformation.box(n), (Integer) (DefaultTypeTransformation.box(n), $const$0)) DefaultTypeTransformation.box(1)))         return DefaultTypeTransformation.intUnbox((Integer)             return 1; ScriptBytecodeAdapter.castToType($const$0, $get$$class$java$lang$Integer()));         else     else             return DefaultTypeTransformation.intUnbox(acallsite         return DefaultTypeTransformation.intUnbox((Integer) [0].call(acallsite[1].callCurrent(this, acallsite[2].call ScriptBytecodeAdapter.castToType(acallsite[0].call(acallsite[1].callCurrent ((Integer)DefaultTypeTransformation.box(n), (Integer) DefaultTypeTransformation.box(1))), acallsite[3].callCurrent (this, acallsite[2].call(DefaultTypeTransformation.box(n), $const$0)), (this, acallsite[4].call((Integer)DefaultTypeTransformation.box acallsite[3].callCurrent(this, acallsite[4].call (n), (Integer)DefaultTypeTransformation.box(2))))); (DefaultTypeTransformation.box(n), $const$1))), $get$$class$java$lang$Integer     if(n <= 1) ()));         return 1; }     else         return fib(n - 1) + fib(n - 2); } Slide #60 DevLOVE Groovy 2011.1.24
  • 87. new int fib (int n) { groovyc     if (n<=1) return 1     return fib(n-1) + fib(n-2) jad } public int fib(int n) public int fib(int n) { {     CallSite acallsite[] = $getCallSiteArray();     CallSite acallsite[] = $getCallSiteArray();     if(!ScriptBytecodeAdapter.isOrigInt())         if(ScriptBytecodeAdapter.compareLessThanEqual((Integer)     if(ScriptBytecodeAdapter.compareLessThanEqual DefaultTypeTransformation.box(n), (Integer) (DefaultTypeTransformation.box(n), $const$0)) DefaultTypeTransformation.box(1)))         return DefaultTypeTransformation.intUnbox((Integer)             return 1; ScriptBytecodeAdapter.castToType($const$0, $get$$class$java$lang$Integer()));         else     else             return DefaultTypeTransformation.intUnbox(acallsite         return DefaultTypeTransformation.intUnbox((Integer) [0].call(acallsite[1].callCurrent(this, acallsite[2].call ScriptBytecodeAdapter.castToType(acallsite[0].call(acallsite[1].callCurrent ((Integer)DefaultTypeTransformation.box(n), (Integer) DefaultTypeTransformation.box(1))), acallsite[3].callCurrent (this, acallsite[2].call(DefaultTypeTransformation.box(n), $const$0)), (this, acallsite[4].call((Integer)DefaultTypeTransformation.box acallsite[3].callCurrent(this, acallsite[4].call (n), (Integer)DefaultTypeTransformation.box(2))))); (DefaultTypeTransformation.box(n), $const$1))), $get$$class$java$lang$Integer     if(n <= 1) ()));         return 1; }     else         return fib(n - 1) + fib(n - 2); } Slide #60 DevLOVE Groovy 2011.1.24
  • 88. new int fib (int n) { groovyc     if (n<=1) return 1     return fib(n-1) + fib(n-2) jad } public int fib(int n) public int fib(int n) { {     CallSite acallsite[] = $getCallSiteArray(); if(n <= 1)     CallSite acallsite[] = $getCallSiteArray();     if(!ScriptBytecodeAdapter.isOrigInt())          if(ScriptBytecodeAdapter.compareLessThanEqual((Integer)    return 1;     if(ScriptBytecodeAdapter.compareLessThanEqual DefaultTypeTransformation.box(n), (Integer) (DefaultTypeTransformation.box(n), $const$0)) else DefaultTypeTransformation.box(1)))         return DefaultTypeTransformation.intUnbox((Integer)             return 1;          else fib(n - 1) + fib(n - 2);    return ScriptBytecodeAdapter.castToType($const$0, $get$$class$java$lang$Integer()));     else             return DefaultTypeTransformation.intUnbox(acallsite         return DefaultTypeTransformation.intUnbox((Integer) [0].call(acallsite[1].callCurrent(this, acallsite[2].call ScriptBytecodeAdapter.castToType(acallsite[0].call(acallsite[1].callCurrent ((Integer)DefaultTypeTransformation.box(n), (Integer) DefaultTypeTransformation.box(1))), acallsite[3].callCurrent (this, acallsite[2].call(DefaultTypeTransformation.box(n), $const$0)), (this, acallsite[4].call((Integer)DefaultTypeTransformation.box acallsite[3].callCurrent(this, acallsite[4].call (n), (Integer)DefaultTypeTransformation.box(2))))); (DefaultTypeTransformation.box(n), $const$1))), $get$$class$java$lang$Integer     if(n <= 1) ()));         return 1; }     else         return fib(n - 1) + fib(n - 2); } Slide #60 DevLOVE Groovy 2011.1.24
  • 89. new long begin = System.nanoTime(); FibJava foo = new FibJava(); int result = foo.fib(32); // long end = System.nanoTime(); System.out.println("Elapsed time: " + (end - begin) + "ns"); (ns) Java 1 Groovy 1.7.5 1,639,852,000 66.46 Groovy 1.8.0 beta 3 65,497,000 2.65 Java(OpenJDK 1.7) 24,672,000 1.0 • MacOSX 10.6.3, MacBook Core2duo 2.53GHz,openjdk version "1.7.0-internal" Slide #61 DevLOVE Groovy 2011.1.24
  • 90. @Invariant({ elements != null })    class Stack {      def boolean is_empty()  {            elements.isEmpty()      private List elements      }          @Ensures({ is_empty() })      @Requires({ !is_empty() })      public Stack()  {      def last_item()  {          elements = []          elements.last()      }      }          @Requires({ preElements?.size() >      def count() { 0 })          elements.size()      @Ensures({ !is_empty() })      }      public Stack(List preElements)  {          elements = preElements      } http://github.com/andresteingress/gcontracts/wiki Slide #62 DevLOVE Groovy 2011.1.24
  • 91. update http://canoo.com/blog/2010/09/20/log-groovys-new-and-extensible-logging-conveniences/ Slide #63 DevLOVE Groovy 2011.1.24
  • 92. import groovy.util.logging.Log  @Log  class MyClass {      def invoke() {          log.info('... an info message')          log.fine('... a fine message')      }  } http://canoo.com/blog/2010/09/20/log-groovys-new-and-extensible-logging-conveniences/ Slide #64 DevLOVE Groovy 2011.1.24
  • 93. New! Slide #65 DevLOVE Groovy 2011.1.24
  • 94. http://kokucheese.com/event/index/5267/ Groovy&Grails exchange 2010@London by tyama, tamada ( ) Gradle G* by (LITERAL-ICE) Slide #66 DevLOVE Groovy 2011.1.24
  • 95. http://kokucheese.com/event/index/5267/ Groovy&Grails exchange 2010@London by tyama, tamada ( ) Gradle G* by (LITERAL-ICE) Slide #66 DevLOVE Groovy 2011.1.24
  • 96. Slide # 67 DevLOVE Groovy 2011.1.24