1. Clojureãšã¯
Clojureã¯ãJava Virtual MachineïŒJVMïŒäžã§åäœããã¢ãã³ãªãåçãªé¢æ°åããã°ã©ãã³ã°èšèªã§ãããªããã»ããããŒã«ãã2007幎ã«èšèšãããäžè²«ãããã¶ã€ã³ãšåŒ·åãªæ©èœãæäŸããŠããŸãã
Clojureã¯ãè€éããæå°éã«æããéçºè ãçŽæçã«ã³ãŒããæžãããšãã§ããããã«èšèšãããŠããŸãããŸããJavaãšã®çµ±åã«ãããJavaããŒã¹ã®ã·ã¹ãã ãšç°¡åã«é£æºã§ããŸãã
ãŸããClojureã¯é«åºŠãªäžŠè¡æ§ãšåæ£ã³ã³ãã¥ãŒãã£ã³ã°ã®æ©èœããµããŒãããŠããŸããããã«ãããClojureã¯å€§èŠæš¡ãªããŒã¿åŠçãšåæã«é©ããŠããŸãã
1.1 Clojureã®ç¹åŸŽãšçšé
Clojureã¯ãLispã®äžæŽŸã§ããããã®ã·ã³ã¿ãã¯ã¹ãšãã¯ãã·ã¹ãã ãç¶æ¿ããŠããŸããããã«ãããClojureã¯ã³ãŒããããŒã¿ã§ããïŒãã¢ã¢ã€ã³ããã¯æ§ïŒãšããLispã®äž»èŠãªç¹æ§ãä¿æããŠããŸãã
Clojureã¯åŒ·åãªå€éæ§ã®æ©èœãæã¡ãé¢æ°åããã°ã©ãã³ã°ã«éç¹ã眮ããŠèšèšãããŠããŸããããã¯ãããŒã¿å€æŽãå±æåããããããããã©ãŒãã³ã¹ãåäžãããã°ã®æ°ãæžå°ãããšããã¡ãªãããæäŸããŸãã
ãŸããClojureã¯è±å¯ãªã©ã€ãã©ãªãæäŸããŠãããWebéçºãããŒã¿åæãAIãæ©æ¢°åŠç¿ãªã©ãå€ãã®çšéã§äœ¿ãããŠããŸãã
1.2 Clojureã®åºæ¬çãªæ§æ
Clojureã®æ§æã¯ã·ã³ãã«ã§ãLispã®ç¹åŸŽãåŒãç¶ãã§ããŸããæ¬åŒ§ã倧éã«äœ¿ããããŒã¿æ§é ãšã³ãŒããåãæ§æãå ±æãããã®ç¹æ§ã¯ãåå¿è ã«ã¯éŠŽæã¿ããªããããããŸããã
ãããäžåºŠç解ããã°ããã®ã·ã³ãã«ãã¯åŒ·åãªããŒã«ã«ãªããŸããã³ãŒããããŒã¿ã§ãããšããååã¯ãèŠèŠçãªäžè²«æ§ãšã³ãŒãåå©çšãä¿ããŸãããŸããã·ã³ã¿ãã¯ã¹è§£æã容æã§ããããªãããªã¡ã¿ããŒã¿æ©èœãæäŸããŸãã
åºæ¬çã«ãClojureã®ãã¹ãŠã®æŒç®åãšæã¯ãæåã«é¢æ°ãŸãã¯ãã¯ãåãæ¥ãŠããã®åŸã«åŒæ°ãç¶ãæ¬åŒ§ã§å²ãŸãããªã¹ããšããŠè¡šçŸãããŸããããã«ãããClojureã®ã³ãŒãã¯ã¹ã¿ãã¯ã®ãããªæ§é ïŒLispå±€ïŒã§ã¬ã€ã€ãŒåãããŸãã
1.3 Clojureã䜿ãã¡ãªãã
Clojureã®æ倧ã®ã¡ãªããã®äžã€ã¯ãJavaãšã³ã·ã¹ãã ãšã®äºææ§ã§ããããã«ãããæ¢åã®Javaã©ã€ãã©ãªã容æã«å©çšããããšãã§ããJavaãã©ãããã©ãŒã ã®ããã©ãŒãã³ã¹ãšç¢ºå®æ§ã®æ©æµãåããããšãã§ããŸãã
ãŸããClojureã¯é¢æ°åããã°ã©ãã³ã°ãéèŠããŠãããå¯äœçšãé¿ããå¯å€ç¶æ ãå¶éããããšã§å®å šæ§ãšäºæž¬å¯èœæ§ãæäŸããŸããããã«ããããã°ã®æ°ãæžãããä¿å®æ§ãåäžãããããšãã§ããŸãã
ããã«ãClojureã¯é«åºŠãªäžŠè¡æ§ãšåæ£ã³ã³ãã¥ãŒãã£ã³ã°ã®ãµããŒããæäŸããŠããŸããããã«ããã倧èŠæš¡ãªããŒã¿åŠçãšåæã®ã¿ã¹ã¯ãå¹ççã«åŠçããããšãã§ããŸãã
1.4 ClojureãåŠã¶ããã®ãªãœãŒã¹
Clojureã®åŠç¿ãªãœãŒã¹ãšããŠã¯ãClojureã®å ¬åŒãŠã§ããµã€ããæãä¿¡é Œæ§ããããŸããããã«ã¯ãClojureã®æŠèŠãå§ãæ¹ãAPIããã¥ã¡ã³ããŒã·ã§ã³ãã³ãã¥ããã£ãªãœãŒã¹ãªã©ãå«ãŸããŠããŸãã
ãŸããbooks, tutorials, online-coursesçã®åœ¢ã§æäŸãããŠããå€æ°ã®è³æããClojureãåŠã¶ããšãå¯èœã§ãããããã¯åå¿è ããäžçŽè ãŸã§å¹ åºãã«ããŒããŠããŸãã
å ããŠãã¹ã¿ãã¯ãªãŒããŒãããŒãClojureã«ç¹åãããã©ãŒã©ã ãªã©ã®ãªã³ã©ã€ã³ã³ãã¥ããã£ãååšããèªåã®åé¡ã«ã€ããŠè³ªåããããä»ã®éçºè ã®åé¡ã«åçãããããããšã§åŠã¶ããšãå¯èœã§ãã
2. Clojureã©ã€ãã©ãªã®çš®é¡ãšéžå®åºæº
2.1 Clojureã©ã€ãã©ãªã®çš®é¡
ãŸãåãã«ãClojureã©ã€ãã©ãªã®çš®é¡ã«ã€ããŠæ¢ããŸããããClojureã¯è±ããªã©ã€ãã©ãªãšã³ã·ã¹ãã ãæã£ãŠããŸãããããã¯åŸã ã«ããŠãæ§ã ãªããã°ã©ãã³ã°èª²é¡ã®è§£æ±ºãå©ããå€çš®å€æ§ãªãŠãŒãã£ãªãã£ãæäŸããŸãã
ããšãã°ããRingãã¯HTTPãµãŒããŒãšã¯ã©ã€ã¢ã³ããæ§ç¯ããããã®åºæ¬çãªã©ã€ãã©ãªã§ããLeiningenãã¯ãããžã§ã¯ã管çãšãã«ãã«åœ¹ç«ã€ããŒã«ããããŠãCompojureãã¯ã«ãŒãã£ã³ã°ã®ããã®èšå®ãå©ããŸãããããã¯å šãŠãæè»ã§èœççãªClojureéçºã®ããã®å ·äœçãªã©ã€ãã©ãªã®äŸã§ãã
ããã«ããQuilãã¯ã¯ãªãšã€ãã£ãã³ãŒãã£ã³ã°ãã¢ãã¡ãŒã·ã§ã³ããããŠã°ã©ãã£ãã¯ãçšæããŠããŸãããã®ããã«Clojureã®ã©ã€ãã©ãªã¯ãWebéçºããããŒã¿è§£æãUIèšèšããããžã§ã¯ã管çãšãã£ãå€å²ã«æž¡ã£ãŠããŸãã
2.2 ã©ã€ãã©ãªã®éžå®åºæº
次ã«ãå®éã«ã©ã€ãã©ãªãéžå®ããéã®åºæºã«ã€ããŠè§£èª¬ããŸãããŸããã©ã€ãã©ãªãéžã¶éã«ã¯ãã©ã€ãã©ãªãã©ã®çšåºŠã¢ã¯ãã£ãã«éçºãããŠãããããããŠã³ãã¥ããã£ããã®ãµããŒããã©ãã ãåŸãããããšããèŠå ãéèŠã§ãã
ããã«ãèªåã解決ãããåé¡ã«å¯ŸããŠãã©ã€ãã©ãªãã©ãã»ã©å¹ççãªè§£æ±ºçãæäŸããŠããããå€æåºæºã®äžã€ã§ãã䜿çšã容æã§ãåŠç¿æ²ç·ãç·©ãããªã©ã€ãã©ãªãéžã¶ããšããç¹ã«ååŠè ã«ãšã£ãŠã¯éèŠãšèšããŸãã
ãŸãã©ã€ã»ã³ã¹ã«ã€ããŠãéžå®åºæºã«å«ããã¹ãã§ãããªãŒãã³ãœãŒã¹ãããžã§ã¯ããèªåã®è£œåã«çµã¿èŸŒãéã¯ãåæ³çã«äœ¿çšã§ããããšãæéèŠã§ãããã®ããã該åœã©ã€ãã©ãªã®ã©ã€ã»ã³ã¹ã䜿çšç®çã«é©åãããã©ããããã£ãããšç¢ºèªããŸãããã
2.3 æéãç¯çŽããããã®ã©ã€ãã©ãªéžå®æ³
ã©ã€ãã©ãªéžå®ã«ã¯æéãæè³ããå¿ èŠããããŸãããå¹ççãªæ¹æ³ãæ¡çšããããšã§æéãç¯çŽããããšãå¯èœã§ããäžã€ã¯ãåçš®ã®ã©ã€ãã©ãªãæ¯èŒæ€èšŒããããšã§ããåã©ã€ãã©ãªã®æ©èœãããã©ãŒãã³ã¹ãã³ãã¥ããã£ã«ãããè©å€ãªã©ããã§ãã¯ããããšã§ãæé©ãªã©ã€ãã©ãªãããæ©ãèŠã€ããããŸãã
å ããŠããªã³ã©ã€ã³ã§å©çšã§ãããAwesome Clojureãã®ãããªãªãœãŒã¹ã䜿çšãããšãClojureã®ã©ã€ãã©ãªã«ã€ããŠã®æ å ±ãå¹çããåŸãããšãã§ããŸãããŸããç¹å®ã®åé¡ã解決ããããã«ã©ã®ã©ã€ãã©ãªãçšããããããšãã£ãäºäŸç 究ãåèã«ãªããŸãã
ãããŠæåŸã«ãéçºéçšã§çŽé¢ããåé¡ã解決ããããã®å¿ èŠãªã©ã€ãã©ãªãèŠã€ããããã«ãèªèº«ã®ãããã¯ãŒã¯ã«ã¢ããã€ã¹ãæ±ããããšãäžã€ã®æ段ã§ãã
2.4 ã©ã€ãã©ãªéžå®æã®æ³šæç¹
ã©ã€ãã©ãªéžå®ãããäžã§æ³šæãã¹ãç¹ãšããŠã¯ãäŸåé¢ä¿ãæããããŸããã©ã€ãã©ãªãä»ã®ã©ã€ãã©ãªã«äŸåããŠããå Žåããã®äŸåã©ã€ãã©ãªãåé¡ãåŒãèµ·ããå¯èœæ§ããããŸãããã®ãããäŸåé¢ä¿ãæã€ã©ã€ãã©ãªãéžå®ããéã¯ãäŸåå ã®ã©ã€ãã©ãªãè©äŸ¡ããå¿ èŠããããŸãã
ãŸããããžã§ã¯ãã®èŠæš¡ãšã©ã€ãã©ãªã®èŠæš¡ãšãäžèŽããŠããããšãéèŠãªæ³šæç¹ã§ããå°èŠæš¡ãªãããžã§ã¯ãã«å·šå€§ãªã©ã€ãã©ãªãå°å ¥ãããšããã®è€éããèŠæš¡ãéçºãé ãããå¯èœæ§ããããŸãã
æåŸã«ãã¡ã³ããã³ã¹æ§ã«ã泚ç®ãå¿ èŠã§ããæŽæ°é »åºŠãé«ããã³ãã¥ããã£ããã®ãµããŒããå å®ããã©ã€ãã©ãªãéžã¶ããšã§ãé·æçãªã¡ã³ããã³ã¹ããããããªããŸãã
3. Clojureã§ãã䜿ãããã©ã€ãã©ãªæŠèŠ
Clojureã®åŒ·åãªãšã³ã·ã¹ãã ã¯ããã®è±å¯ãªã©ã€ãã©ãªã®ååšã«ãã£ãŠæ¯ããããŠããŸãã ãããã®ã©ã€ãã©ãªã¯ãããŒã¿ããŒã¹æäœããWebéçºããã¹ããã¬ãŒã ã¯ãŒã¯ãéåæåŠçã»äžŠè¡åŠçãªã©ãããŸããŸãªç®çã§äœ¿çšã§ããŸãã
以äžã§ã¯ãClojureã§ãã䜿ãããããããã®ã«ããŽãªã®ã©ã€ãã©ãªã«ã€ããŠã¿ãŠãããŸãããã
3.1 ããŒã¿ããŒã¹æäœã©ã€ãã©ãª
ClojureãçšããããŒã¿ããŒã¹æäœã«ã¯”Hiccup”ã”Korma”ãªã©ã®ã©ã€ãã©ãªãããããã§ãã“Hiccup”ã¯SQLã«ããæäœãå¯èœã§ãææ³ãçŽæçãªããèŠããããç¹åŸŽããããŸãã
äžæ¹ãKormaãã¯ãSQLãæœè±¡åããDSLãæäŸããŠããããã¡ãã¯SQLãçŽæ¥æžããã«ããŒã¿æäœãè¡ãããšãå¯èœã§ãã
ãããã®ã©ã€ãã©ãªã¯ãClojureã掻çšããŠããŒã¿ããŒã¹ãæäœããéã®åŒ·åãªããŒã«ãšãªãã§ãããã
3.2 Webéçºã©ã€ãã©ãª
次ã«Webéçºã«äŸ¿å©ãªClojureã©ã€ãã©ãªãããã€ã玹ä»ããŸããããããšãã°“Ring”ã”Compojure”ãªã©ããã䜿ãããŸãã
“Ring”ã¯HTTPãµãŒããŒãšWebã¢ããªã±ãŒã·ã§ã³ã®éã®ä»²ä»åœ¹ãšããŠæ©èœãã”Compojure”ã¯URIã«ãŒãã£ã³ã°ãç°¡åã«äœæã§ããã©ã€ãã©ãªã§ãã
ãããã®ã©ã€ãã©ãªã¯ãClojureã«ããWebéçºãå¹ççã«é²ããããã«å¿ èŠäžå¯æ¬ ãªãã®ãšèšããã§ãããã
3.3 ãã¹ããã¬ãŒã ã¯ãŒã¯ã©ã€ãã©ãª
ãœãããŠã§ã¢éçºã«ãããŠãã¹ãã¯éåžžã«éèŠã§ããClojureã«ãã“clojure.test”ã”Midje”ã®ãããªçŽ æŽããããã¹ããã¬ãŒã ã¯ãŒã¯ã©ã€ãã©ãªããããŸãã
“clojure.test”ã¯Clojureã«æšæºæ·»ä»ãããŠããã©ã€ãã©ãªã§ãåºæ¬çãªãŠããããã¹ããå¯èœã§ãã
äžæ¹ã”Midje”ã¯ããã€ãã¢é§åéçº(BDD)ã«éç¹ã眮ãããã¬ãŒã ã¯ãŒã¯ã§ããã人éããããã¹ããæžãããšãã§ããŸãã
3.4 éåæåŠçã»äžŠè¡åŠçã©ã€ãã©ãª
æåŸã«ãéåæåŠçã䞊è¡åŠçãå¹ççã«è¡ãããã®Clojureã©ã€ãã©ãªã“core.async”ã”Quasar”ãæããŠãããŸãã
“core.async”ã¯CSP(Communicating Sequential Processes)ã¹ã¿ã€ã«ã®éåæåŠçãå¯èœã«ããã©ã€ãã©ãªã§ããã䞊è¡ããã°ã©ãã³ã°ãçŽæçã«æ±ããŸãã
ãã㊔Quasar”ã¯ã”core.async”ãåºã«ãããã¬ãŒã ã¯ãŒã¯ã§ããã€ããã©ãŒãã³ã¹ãªäžŠè¡åŠçãå®çŸããŸãã
4. Clojureã©ã€ãã©ãªã®è©³çŽ°è§£èª¬
ãã®ç« ã§ã¯ãæ§ã ãªClojureã©ã€ãã©ãªã®è©³çŽ°ã«ã€ããŠè§£èª¬ããŸãããã®ã€ã³ã¹ããŒã«æ¹æ³ãåºæ¬çãªäœ¿çšæ¹æ³ãå¿çšçãªäœ¿çšæ¹æ³ããŸããã©ã€ãã©ãªå©çšæã®ãã©ãã«ã·ã¥ãŒãã£ã³ã°ãªã©ãå¹ççã«ã©ã€ãã©ãªã掻çšããããã®ç¥èãæäŸããŸãã
4.1 ã©ã€ãã©ãªã®ã€ã³ã¹ããŒã«æ¹æ³
LeiningenãBootãªã©ã®ããŒã«ãçšããŠãClojureã©ã€ãã©ãªã®ã€ã³ã¹ããŒã«ãç°¡åã«è¡ãããšãã§ããŸãããããã®ããŒã«ã¯ããããžã§ã¯ãã®ã©ã€ããµã€ã¯ã«å šäœã§äœ¿çšããããããã©ã€ãã©ãªç®¡çã容æã«ããŸãããã®ããããŸããããã®ããŒã«ãã€ã³ã¹ããŒã«ãããã®åŸã§ç¹å®ã®ã©ã€ãã©ãªãã€ã³ã¹ããŒã«ããŸãã
å ·äœçãªæé ã¯ããŸã Leiningen ãŸã㯠Boot ã®å ¬åŒãŠã§ããµã€ãããããŠã³ããŒãããèšå®ãè¡ããŸãããã®åŸããããžã§ã¯ãå ã§:dependenciesããŒã¯ãŒãã«ã©ã€ãã©ãªã®ååãšããŒãžã§ã³ãè¿œå ããããšã§ãã©ã€ãã©ãªã®ã€ã³ã¹ããŒã«ãå¯èœãšãªããŸãã
次ã«ããããžã§ã¯ã.cljãbuild.bootãæŽæ°ããããšã§ããããžã§ã¯ãå šäœã§ã©ã€ãã©ãªãå©çšããããšãã§ããŸãããããã®æé ãèžãããšã§ãå¿ èŠãªã©ã€ãã©ãªãç°¡åã«ã€ã³ã¹ããŒã«ããClojureããã°ã©ãã³ã°ãåæ»ã«é²ããããšãã§ããŸãã
4.2 ã©ã€ãã©ãªã®åºæ¬çãªäœ¿çšæ¹æ³
ã©ã€ãã©ãªã®åºæ¬çãªäœ¿çšæ¹æ³ã«ã€ããŠèª¬æããŸããã€ã³ã¹ããŒã«ããã©ã€ãã©ãªãå©çšããã«ã¯ããŸãrequireé¢æ°ãçšããŠã©ã€ãã©ãªãèªã¿èŸŒãå¿ èŠããããŸããrequireé¢æ°ã¯åŒæ°ãšããŠã©ã€ãã©ãªåãåãããã®ã©ã€ãã©ãªãå©çšã§ããç¶æ ã«ããŸãã
èªã¿èŸŒãã ã©ã€ãã©ãªã®é¢æ°ãå©çšããã«ã¯ãé¢æ°åã®åã«ã©ã€ãã©ãªåãã€ããŠåŒã³åºããŸãããã®ææ³ã«ãããã©ã€ãã©ãªå ã®ç¹å®ã®é¢æ°ãåãåºããã³ãŒãå ã§äœ¿çšããããšãå¯èœãšãªããŸãã
ããã«ãuseé¢æ°ã䜿ãããšã§ãã©ã€ãã©ãªåãã€ããã«é¢æ°ãåŒã³åºãããšãå¯èœãšãªããŸãããã ãããœãŒã¹ã³ãŒããèŠãéã«ã©ã®ã©ã€ãã©ãªããã®é¢æ°ãã¯ã£ããããªããããéåžžã¯äœ¿çšãæ§ããããšãæšå¥šãããŸãã
4.3 ã©ã€ãã©ãªã®å¿çšçãªäœ¿çšæ¹æ³
ãã®ç¯ã§ã¯ãã©ã€ãã©ãªã®å¿çšçãªå©çšæ¹æ³ãåãäžããŸããå ·äœçã«ã¯ãè€æ°ã®ã©ã€ãã©ãªãçµã¿åãããŠå©çšããæ¹æ³ããèªåèªèº«ã§ã©ã€ãã©ãªãäœæããŠæŽ»çšããæ¹æ³ãªã©ããããŸãã
è€æ°ã®ã©ã€ãã©ãªãçµã¿åããããšãã¯ãåã©ã€ãã©ãªã®ç¹æ§ãç解ããããããã®ã©ã€ãã©ãªã®é¢æ°ãå¿ èŠã«å¿ããŠåŒã³åºãããã«ããŸããããããããã®ã©ã€ãã©ãªã¯ã察å¿ããåé¡é åã«é©ãã解決çãæäŸããŠããŸãã
ãŸããèªäœã®ã©ã€ãã©ãªãäœãå Žåã¯ããŸãã¯æ¢åã®ã©ã€ãã©ãªãåèã«ããå¿ èŠãªæ©èœãå®è£ ããããšããå§ããŠã¿ãŠãã ãããèªåèªèº«ã§ã©ã€ãã©ãªãäœãããšã¯ãæ·±ãç解ãšå®ååäžã«ã€ãªãããŸãã
4.4 ã©ã€ãã©ãªå©çšæã®ãã©ãã«ã·ã¥ãŒãã£ã³ã°
æåŸã«ãã©ã€ãã©ãªå©çšæã«çºçããå¯èœæ§ãããåé¡ãšãã®è§£æ±ºçã«ã€ããŠèª¬æããŸããäžéšã®åé¡ã¯ã誀ã£ãã©ã€ãã©ãªã®ããŒãžã§ã³ãã€ã³ã¹ããŒã«ãããŠãããã©ã€ãã©ãªã®äŸåé¢ä¿ã解決ã§ããŠããªããªã©ãããŸããŸãªåå ã§çºçããŸãã
ãã©ãã«ã·ã¥ãŒãã£ã³ã°ã®ç¬¬äžæ©ã¯ããšã©ãŒã¡ãã»ãŒãžããã£ãããšèªãããšã§ãããšã©ãŒã¡ãã»ãŒãžã¯ãåé¡ã®åå ãçªãæ¢ããããã®éèŠãªæããããæäŸããŸãããšã©ãŒã¡ãã»ãŒãžã§è§£æ±ºã§ããªãå Žåã¯ãéçºè ã®ã³ãã¥ããã£ã«åãåãããããšãæå¹ãªæ段ã§ãã
ãŸããé©åãªã©ã€ãã©ãªã®ããŒãžã§ã³ã䜿çšãããããŒã«ã®èšå®ãæ£ããè¡ããé©åãªæé ã§ã©ã€ãã©ãªãã€ã³ã¹ããŒã«ãããšãã£ãåºæ¬çãªäºé ã確èªããããšã§ãå€ãã®åé¡ãé²ãããšãã§ããŸãã
5. Clojureã©ã€ãã©ãªã®æŽ»çšäŸ
ç¡æ°ã«ååšããClojureã®ã©ã€ãã©ãªãã©ã®ããã«æŽ»çšããããšã§ãäœãããããããšãã§ããã®ãïŒå ·äœçãªæŽ»çšäŸã«ã€ããŠã¿ãŠãããŸãããã
5.1 ããŒã¿åæ
äžã€ç®ã®æŽ»çšäŸãšããŠããŒã¿åæãæããŸããIncanterã¯Clojureã®ããã®åŒ·åãªããŒã¿åæã©ã€ãã©ãªã§ãããRèšèªã®æ©èœãæã£ãŠããŸãããã®ã©ã€ãã©ãªã«ãã£ãŠãããŒã¿ã®çµ±èšåæãæ§ã ãªçš®é¡ã®ã°ã©ãã®äœæãããŒã¿ã®å¯èŠåãå¯èœãšãªããŸãã
ãŸãããã·ã³ã©ãŒãã³ã°ã«ãããŠã¯clj-mlã©ã€ãã©ãªã圹ç«ã¡ãŸãããã®ã©ã€ãã©ãªã¯Javaã®ãã·ã³ã©ãŒãã³ã°ã©ã€ãã©ãªã§ããWekaãšçµã¿åãããŠäœ¿çšããããŒã¿ã®ååŠçããåé¡ãååž°ãã¯ã©ã¹ã¿ãªã³ã°çã®æ©èœã掻çšã§ããŸãã
äžèšã®ã©ã€ãã©ãªã¯ClojureãããŒã¿åæã«æŽ»çšããéã«ã¯å¿ é ãšèšããã§ãããããããã®ã©ã€ãã©ãªã掻çšããããšã«ãã£ãŠãããŒã¿åæã®å¹ ãšæ·±ããå€§å¹ ã«åºãããŸãã
5.2 WebãµãŒãã¹éçº
Clojureã®Webéçºã©ã€ãã©ãªã®äžå¿çååšã§ããRingã¯ãHTTPãµãŒããŒãšãŠã§ãã¢ããªã±ãŒã·ã§ã³éã®ã€ã³ã¿ãŒãã§ãŒã¹ãšãªããŸããããã«ãããHTTPãªã¯ãšã¹ããšHTTPã¬ã¹ãã³ã¹ãç°¡æçã«æ±ãããšãã§ããŸãã
ã¬ã¹ãã³ã¹çæãæå©ãããCompojureãšãããã€ã¯ãWebãã¬ãŒã ã¯ãŒã¯ã¯ãURLã«ãŒãã£ã³ã°ãçŽæçãã€ç°¡åã«è¡ãããšãã§ããŸãã
ãŸãããã³ãã¬ãŒããšã³ãžã³ãšããŠã¯Hiccupããã䜿ãããHTMLãClojureã®ããŒã¿æ§é ãšããŠè¡šçŸããããšãå¯èœãšãªããŸããããã«ãããHTMLçæãããã°ã©ã å¯èœãªãã®ãšããããšãã§ããŸãã
5.3 ãã€ã¯ããµãŒãã¹ã®æ§ç¯
ãã€ã¯ããµãŒãã¹ã®æ§ç¯ã«ã¯ãCompojure-apiãLiberatorãªã©ã®ã©ã€ãã©ãªã䟿å©ã§ãããããã¯RESTful APIã®æ§ç¯ãå©ããŸãã
ãŸããMountãComponentã¯ã·ã¹ãã ã®ç¶æ 管çã«äœ¿çšããããµãŒãã¹éã§ã®äŸåé¢ä¿ã管çããŸãã
ãããã®ã©ã€ãã©ãªãçµã¿åãããããšã§ãåæ£ç°å¢äžã§ã®é«åºŠãªãã€ã¯ããµãŒãã¹ãå¹çè¯ãæ§ç¯ããããšãã§ããŸãã
5.4 倧èŠæš¡ããŒã¿åŠç
倧èŠæš¡ããŒã¿åŠçã«ã¯ãClojureã®äžŠåããŒã¿åŠçã©ã€ãã©ãªãæçšã§ãããããã¯ãé«éã§äžŠåçãªããŒã¿æäœãæäŸãã倧åããŒã¿ã»ãããå¹çè¯ãæ±ãããšãã§ããŸãã
ãã®ãããªã©ã€ãã©ãªã«ã¯ãClojure.core.reducersãJavaã®äžŠååŠçã©ã€ãã©ãªãªã©ããããClojureããã°ã©ã ããç°¡åã«å©çšã§ããŸãã
ãããã®ã©ã€ãã©ãªã掻çšããããšã§ã倧èŠæš¡ãªããŒã¿åŠçãçæéã§å¹ççã«å®è¡ããããšãå¯èœãšãªããŸãã
6. ãŸãšãïŒClojureã©ã€ãã©ãªãæ倧éã«æŽ»çšããã
ä»åã®èšäºã§ã¯ãClojureã®ããŸããŸãªã©ã€ãã©ãªã«ã€ããŠè©±ãé²ããŠããŸãããããã§ããã®å šãŠãç¶²çŸ ããäºã¯å°é£ã§ãããèå¿ãªãã€ã³ãã¯ã©ã€ãã©ãªã®æŽ»çšæ¹æ³ãšãã®éžå®ã®ä»æ¹ã§ãã
ããããããå ·äœçãªåé¡ã解決ããããã®ããŒã«ã§ããããã®éžæã¯ããªãã®éçºå¹çãšãããžã§ã¯ãã®æåãå·Šå³ããŸããããããã¯ãããããã®ããŒããäžå¿ã«ãã®èšäºããŸãšããŠãããŸãããã
6.1 é©åãªã©ã€ãã©ãªã®éžå®ãéèŠæ§
ã©ã€ãã©ãªã®éžå®ã¯éåžžã«éèŠã§ãç¹ã«Clojureã®äžçã§ã¯å€ãã®éžæè¢ãååšããŸããé©åãªã©ã€ãã©ãªãéžã¶ããšã§ããããšãã£ã·ã§ã³ãã«ã³ãŒããæžãããšãå¯èœã«ãªããŸãã
äžã€ã®ã¢ãããŒãã¯ããããžã§ã¯ãã®ããŒãºã«å®å šã«ãããããã©ã€ãã©ãªãèŠã€ããããšã§ãããããåæã«ããã°ã®å°ãªããããã¥ã¡ã³ããŒã·ã§ã³ã®è³ªãä¿å®æ§ãªã©ãéèŠãã¹ããã€ã³ãã§ãã
ãããŠäœããããã©ã€ãã©ãªã¯è§£æ±ºãããåé¡ã«å¯Ÿããæè¯ã®çããè©°ãŸã£ãŠããã¹ãã§ãããã®ããã«ã¯è©äŸ¡ãšçããã¹ããå¿ èŠã«ãªããŸãã
6.2 åŠç¿ãéããŠç解ãæ·±ãã
éžå®ããã©ã€ãã©ãªãç解深ããããã«ã¯ãåŠç¿ãæ¬ ãããŸãããå ¬åŒã®ããã¥ã¡ã³ããŒã·ã§ã³ã¯ãã¡ãããã³ãŒãã®èªã¿è§£ãæ¹ããããžã§ã¯ããžã®é©çšæ¹æ³ã«ã€ããŠç解ãæ·±ããããšã倧åã§ãã
ãã®ããããŸãã¯èªèº«ã®ç®ã§ã©ã€ãã©ãªã®ãœãŒã¹ã³ãŒãã確èªããã©ã®ãããªãããã«åäœããŠããã®ãåºæ¬çãªç解ãããããšãéèŠã§ãããã®äžã§ãããã¥ã¡ã³ããŒã·ã§ã³ãã§ããã ã詳现ã«èªãäºã匷ãæšå¥šããŸãã
ãããŠæåŸã«ãå®éã®èªèº«ã®ãããžã§ã¯ãã«å¿çšããŠããã®æ©èœãèªåã®ãã®ã«ããããšãå¿ èŠã§ãã
6.3 å®è·µãéããŠã¹ãã«ã¢ãããå³ã
çè«çãªåŠç¿ã ãã§ãªããå®è·µãéããŠã¹ãã«ã¢ãããå³ãããšãéèŠã§ããããã¯ç°¡åãªãã¹ããããžã§ã¯ãããå§ããããšãã§ããŸãããæ¥åžžã®ã¿ã¹ã¯ã«åãçµãäžã§æ°ããªã©ã€ãã©ãªãå©çšãããªã©ãæ§ã ãªåœ¢ã§è¡ãããšãã§ããŸãã
ãªããªãããããã¯ãŒã«ãªæ©èœãåããŠããŠãããããæ¥åžžçã«äœ¿ãããªããã°æå³ããªãããã§ããæçµçãªç®æšã¯ã©ã€ãã©ãªã掻çšããŠæéãç¯çŽããããé«å質ãªãããã¯ããäœæããããšã§ãã
ãããã£ãŠãæ¥ã ã®ã¿ã¹ã¯ã«ãããŠå¹ççã«ã©ã€ãã©ãªã掻çšããããã«ãã£ãŠã¹ãã«ã¢ãããç®æãããšãéèŠãšãªããŸãã
6.4 ãããªãæ å ±åéãšä»åŸã®åŠç¿ã«ã€ããŠ
æåŸã«ãä»åŸãæ å ±åéãšåŠç¿ãç¶ããããšãéèŠã§ãããã¯ãããžãŒã¯æ¥ã é²åããŠãããæ°ããã©ã€ãã©ãªãæ°ããªäœ¿ãæ¹ãçãŸããå¯èœæ§ã¯ãã€ããããŸãã
ãŠãŒã¶ãŒãã©ãŒã©ã ãGitHubã®ãããžã§ã¯ãããŒãžãé¢é£ããã°ãªã©ãããæ°ããæ å ±ãåŸãããšãã§ããŸããããã«ãå®æçãªãªãªãŒã¹ããŒããå€æŽãã°ã®ãã§ãã¯ãå¿ããªãããã«ããŸãããã
æ å ±åéãšåŠç¿ã¯çµããããªãæ ã®ãããªãã®ã§ãåžžã«ææ°ã®ç¥èãšã¹ãã«ãç¶æããèªåèªèº«ãã¢ããããŒãããŠããããšãå¿ èŠã§ããããããããæè¡è ãšããŠæ±ããããæ倧ã®ã¹ãã«ã§ããããããéæããããã®æè¯ã®éãšãããã§ãããã