ãG*ã¯ã¼ã¯ã·ã§ãããVert.x+JavaOne+Groovy2.0ãªG*ã #jggugãã«åå ãã¦ãã
åå¼·ä¼ã§ãæ®ã©èããªã
Groovyã®åå¼·ä¼ããã¾ãï¼
ã©ãã§æ
å ±åéããã°ãããããããªãï¼
ããã«ã«ã¬ã³ãã¼ãï¼
JGGUG イベントカレンダー
åç¥ã足ããªãï¼
åå¼·ä¼ã«ã¬ã³ãã¼ã«ãè¼ã£ã¦ããã
ããã¡ã¼ãã§GroovyãGrailsã¿ã°ãããã
Facebookã®ã°ã«ã¼ãããMLããããã
2012/10/26ã«è¡ãããG*ワークショップ「Vert.x+JavaOne+Groovy2.0なG*」 #jggugã«åå ãã¾ããã
ãã®ã¬ãã¼ãã§ãã
G*ãªJavaOneå ±å2012ç§ ããµã³ãã©ã³ã·ã¹ã³ã®é¢¨ã«å¹ããã¦ã @gantawitter
Rasberry Pi
Rasberry Piãä¸çªçãä¸ãã£ãã
è½ã¡ãã¨ãããã»ã»ã»
Design Patterns in Groovy
åçµãã¦ã¿ãã
- Cascade
- method chaining Tarditional way
class Mailer { def to(addr) { println 'to ...' } def from(addr) { println 'from ...' } def sub(subject) { println 'sub ...' } def body(msg) { println 'body ...' } def send() { println 'send ...' } } // Tarditional way Mailer mailer =new Mailer() mailer.to('[email protected]') mailer.from('[email protected]') mailer.sub('build fixed') mailer.body('...message...') mailer.send()
to ... from ... sub ... body ... send ...
-
- method chaining
class Mailer { def to(addr) { println 'to ...'; this } def from(addr) { println 'from ...'; this } def sub(subject) { println 'sub ...'; this } def body(msg) { println 'body ...'; this } def send() { println 'send ...'; this } } // Chaining new Mailer() .to('[email protected]') .from('[email protected]') .sub('build fixed') .body('...message...') .send()
to ... from ... sub ... body ... send ...
return this ã®returnãçç¥ããã¦ãã
åèï¼return省略のルール
-
- fluency
class Mailer { def to(addr) { println 'to ...' } def from(addr) { println 'from ...' } def sub(subject) { println 'sub ...' } def body(msg) { println 'body ...' } def static send(block) { Mailer mailer = new Mailer() mailer.with block println 'send...' } } Mailer.send { to '[email protected]' from '[email protected]' sub 'build fixed' body '...message...' }
to ... from ... sub ... body ... send...
ããããæµæ¢ãªã³ã¼ãæ¸ããªããªããã
ãã£ï¼輝彩滑刀の流法ã¨å¼ã¹ï¼
Intercept, cache, and invoke pattern
class Person { def activities = ['Football', 'Tennis'] def methodMissing(String name, args) { println "interceptiong $name" if (name.startsWith('play')) { def activity = name.split('play')[1] if (activities.contains(activity)) { def impl = { Object[] tehArgs -> println "I like playing $activity" } getMetaClass()."$name" = impl return impl(args) } throw new MissingMethodException(name, this.calss, args) } } } Person sam = new Person() sam.playTennis() sam.playTennis() sam.playTennis() sam.playTennis() sam.playFootball() sam.playFootball()
interceptiong playTennis ã»ã»ã»1åç®ã§ãã£ãã·ã¥ããã¦ãªãã®ã§ãã®ã¡ãã»ã¼ã¸ãã§ã I like playing Tennisã»ã»ã»ã»ã»ã»2åç®ä»¥éã¯ãã£ã·ã¥ããã¦ãã®ã§ããinterceptiongããã®ã¡ãã»ã¼ã¸ã¯ã§ãªã I like playing Tennis I like playing Tennis I like playing Tennis interceptiong playFootballã»ã»ã»ã»1åç®ã®Footballãªã®ã§ããã®ã¡ãã»ã¼ã¸ãã§ã I like playing Football I like playing Football
methodMissingã¯ãããã°ã©ãã³ã°GROOVYã«ã¯æ¸ãã¦ãããã©ãWebã ã¨ãã³ã¾ã«èµ·ç¨¿ãã@uehajããã®è¨äºãï¼
methodMissing と invokeMethod
ãã®è¾ºã¯JavaOneã®åç»ãè¦ã¦ã¿ããã
ScirptBowl
Scala vs JRuby vs clojure vs Groovy
å»å¹´ã¯Groovyã®åªåã
ä»å¹´ã¯ãScalaã®æç¬é¨éã«ãã£ã¦åªåããã£ãããããã
JavaOneã«è¡ãGroovyistã¯æç¬ãè¦ããããã«ã
ã«ã
JavaOneã«è¡ã£ãæ¥æ¬äººã¯ã«ããé£ãã®ãç¿æ
£ãããã
ã©ããã¦ããå»å¹´ã®@nobeansã®é¡ãæãæµ®ããã§ãã¾ãã
JavaOneè³æ
è³æã¨åç»ãå ¬éããã¦ãã
- JavaOne Content Catalog
- Oracle Media Network(åç»)
éåæããã ã¤ãã³ãé§åããã ãVert.xã®ã¡ãã£ã¨ãã話ã @touchez_du_bois
ååã§ããªãã£ããä»åããã¾ãããç¶æ ã§ã¯ãªãã®ã§ããã»ã»ã»
ã¢ã¤ãã¨ããããTweetã§è³ªåãã¦ãããã°ãçãã¾ãã
æ¬é¡(ã¢ãã¡ãã¿)
ä½è«(Vert.x)
Vart.xã®èªã¿æ¹ã¯ãããã¼ããã¯ã¹ã
-
- C10Kåé¡ã¨ã¯ã
http://www.hyuki.com/yukiwiki/wiki.cgi?TheC10kProblem
- C10Kåé¡ã解決ããããã®ãã¬ã¼ã ã¯ã¼ã¯
- ã·ã³ã°ã«ã¹ã¬ããã¢ãã«
- ãã³ããããã³ã°I/O(éåæI/O)
- ã¤ãã³ãé§å (ã¤ãã³ããçºçããæç¹ã§ãµã¼ãã«ä¾é ¼)
- æåãªãã¬ã¼ã ã¯ã¼ã¯ã ã¨Node.js
- Javaçéã§ã®ãã¬ã¼ã ã¯ã¼ã¯ã ã¨
- NIO
- Netty
- G*çéã ã¨
- Gretty
- æºãæãã¦ç»å ´ããã®ãVert.x
- ãã¹ã¦ãã³ããããã³ã°
- JVMä¸ã§åä½
- å¤è¨èªå¯¾å¿
- Java
- Groovy
- JavaScript
- CoffeeScript
- Ruby
- Pythonã
- Scala(ä»å¾å¯¾å¿äºå®)
- Clojure(ä»å¾å¯¾å¿äºå®)
CloujureãScalaã¯ç¾å¨ã§ããclassãã¡ã¤ã«ã«ããã°ä½¿ç¨å¯è½
- TCPãSSLãHTTPãHTTPSãWebsocketsã¨ãã£ãå¾æ¥ã®ãããã³ã«ã«å¯¾å¿
- Vert.xãVerticleãJVMã®é¢ä¿
- Verticleã¯ãVert.xã®ã¤ã³ã¹ã¿ã³ã¹ã§ç¬ç«ãã¦åä½ãã
- 1ã¤ã®Verticleã®ã¤ã³ã¹ã¿ã³ã¹ã¯ãJVMã§åä½ãã
- è¤æ°ã®Verticleã1ã¤ã®Vert.xã®ã¤ã³ã¹ã¿ã³ã¹ã§åä½ãã
Vert.xã®ã¤ã³ã¹ã¿ã³ã¹:Verticle=1:N
JVM:Verticle=1:1
ãã£ã¦ãï¼ï¼
è³æå
¬éãããã確èªãããããã
- Verticleå士ã¯ã¤ãã³ããã¹ãéãã¦éä¿¡
- è¤æ°ã®Verticleãã¤ãã³ããã¹ãéãã¦é£æº
- å ±æããããå ±æã»ããã¯åãVert.xå ã§ã®ã¿å ±æå¯è½
- ã¯ã¼ã«ã¼Verticleã¯å¦çããããã¯ãã¦ããã
- ã¤ãã³ãã«ã¼ã
- ãã«ãã»ãªã¢ã¯ã¿ã¼ã»ãã¿ã¼ã³
- HelloWorld
- ã½ã¼ã¹
vertx.createHttpServer().requestHandler { request -> request.response.end(""" <html> <body> <h1>Hello, World!</h1> </body> </html> """) }.listen(8080, 'localhost')
- å¤æ°vertxãå¤æ°requestã¯ãvert.xã«ããèªåãã¤ã³ãããã
- Groovyã ã¨importæããããªããã ã
GroovyでVert.x - 1. インストールとHello, World!ã® ã"vertx"ã£ã¦ï¼ãã®ã¨ãã
-
- å®è¡æ¹æ³
$ vertx run HelloWorld.groovy
- Vert.xã®ããã¥ã¡ã³ãã¯å å®ãMybetabookã§çµ¶è³ç¿»è¨³ä¸ã
ããã«ãªã³ã¯è²¼ããªããã¨ãã©ãã¤ããªãæ°ãããã
jggug - 日本Grails/Groovyユーザーグループ
ã¢ã¤ã¢ã¤
@touchez_du_bois ãããè³æã©ãã§å
¬éããã¦ã¾ãããã
å
¬éããã¾ãã
Groovy 2.0ã®æ°æ©è½ ãç¾ããã¨@CompileStaticã®ãã¨ãã @uehaj
ASTå¤æ
éçGroovy
- @TypeChecked
- @CopmileStatic
ã¿ã¤ããå¤ãåã¨ãã¦ã¯ã@TypeCheckedãã¤ããã»ããããã®ãï¼
ã¡ã½ããåã®èª¤ãã«å¯¾ããææãªããIntelliJ IDEAã®è£å®ã«ä»»ããã»ãããããããªæ°ãããã
http://grails.org/products/ggts
IntelliJ IDEAã¯12ããGroovy2.0ãµãã¼ãã
ã¾ã EPAçã®ç¶æ
ãªã®ã§ãGroovy2.0ã¯ä½¿ããªãã
NetBeansã¯ã©ãã ã£ãï¼
Groovy++ ã¨éçGroovy
- @Typedã¢ããã¼ã·ã§ã³ããGroovy2.0ã®@TypeChecked éçåãã§ãã¯ã@CompileStatic éçã³ã³ãã¤ã«ã¸
- ãã ããã½ã¼ã¹ã®ç¶ç¶æ§ã¯ãªã
- mixedã¢ã¼ãã³ã³ãã¤ã«ãæ«å°¾æé©åãtraitsãªã©ã¯æªå¯¾å¿
- ããããããå®è£ ããã¨èãã¦
æ§è½
Groovy++ã£ã¦æ©ãã£ããã ãª
JVM言語BOFベンチマーク20120402
ã§ããGroovy++ããã°ã£ã¦ããã ããªã¼ãGroovy2.0ã ã¨ã©ããªãã ããã
ããããã ããããï½ indy
æ親ä¼ã§JRubyã¯indy対å¿çã®æ¹ãæ©ããindyã«ãã¾ã対å¿ãã¦ãã¨èããã
Groovyãä»å¾ã®indy対å¿ã§ã®é度Upã«æå¾
ã©ã¤ãã©ãªå¼·å
- åæå¤ç¡ãinject
ãä¸è©±ã«ãªãããªï¼
- Matcher#matchesPartially()
ããªãã¼ã·ã§ã³ãã§ãã¯ä»¥å¤ã§ä½¿ç¨ç¨éãåéä¸ã
http://yamkazu.hatenablog.com/entry/2012/07/06/153541
- takeWhile{}ãdropWhile{}
ã¯ããã«falseãtrueã«ãªã£ã以éã®è¦ç´ ãããã以éã®å¤ã¯åããã«åãåºã
è³æã®å³ãããããããããããããè³æãè¦ãæ¹ãããã
ã¢ã¸ã¥ã¼ã«å
æ¡å¼µã¢ã¸ã¥ã¼ã«ã¯ãã«ã¹ã¿ã æ¡å¼µã¡ã½ããããæä¾ã§ãã
AdventCalendarãGhelloã®ãããªã¤ãã³ãã§ä½¿ãé»éè¡çãªãã®ãå¢ããã¨ãããã¨ãã(é
Groovyã®ä»å¾
2012å¹´ã®æ®ãã§Groovy2.1ã2013å¹´ãGroovy3.0ã¸ã®é²åã¯ç¶ãã
@gantawitter ããã@touchez_du_bois ããã@uehaj ãã çºè¡¨ãããã¨ããããã¾ããã
ã¬ãã¼ãã«ã礼ãããã¦ã
座å¸è¡¨
ãã£ã¡ã¾ã£ããã»ã»ã»ç·¨é権ã¤ããã®å¿ããã
çµäºééã«ã追å ãããã©ã»ã»ã»
æ°ãã人å¢ãã¦ãå³å´ãåããããè¯ãã£ããã編集ãã¦ãã ããã
[twitter:@uehaj]
[twitter:@tikeda123]
[twitter:@nobusue]
[twitter:@earu]
[twitter:@gantawitter]
[twitter:@bopperjp]
[twitter:@toby55kij]
[twitter:@kimukou2628]
[twitter:@anonaka]
[twitter:@kimza]
[twitter:@yamap_55]
[twitter:@_y_u_]
[twitter:@kazuchika]
[twitter:@literalice]
[twitter:@shinyaa31]
[twitter:@touchez_du_bois]
[twitter:@yamkazu]
[twitter:@nyankofinish]
[twitter:@tkdysk]
[twitter:@ykmc09_dev]
[twitter:@hiranasu]
[twitter:@yotama]
[twitter:@yamadamasaki]
[twitter:@nemo_kaz]
[twitter:@jin_kojima]
[twitter:@tetsuonatom]
[twitter:@grimrose]
[twitter:@mike_neck]
[twitter:@_siosio_]
[twitter:@kazkawamura]
[twitter:@orange_clover]
[twitter:@ecaze]
[twitter:@kaminami]
[twitter:@tyama]
[twitter:@kiy0taka]
[twitter:@mkawax]
[twitter:@tamatamatamata]
[twitter:@notexy]
[twitter:@nobeans]
[twitter:@geek_duck]
[twitter:@kaakaa_hoe_prog]
[twitter:@KanSAKAMOTO]
[twitter:@kazuyoshihayase]
[twitter:@kara_d]
[twitter:@tetsurokitahara]
[twitter:@foobardam]
é¢é£ããã°
G*Workshop「Groovy2.0の新機能」を発表してきました
ãã®æ¥ã®ãã¡ã«ã¬ãã¼ããããã人ã¯ã»ã¨ãã©ããªãããªã»ã»ã»