Sanya
ingspree ãSergey
Joes ãRoma
rofhãšãšãã«Clojure Cup 2013ã«åå ããŸããã ãããããããªãã¯
ã«ãããèŠããããããŸããããkloskurscriptãšãªã¢ã¯ãã£ãããã°ã©ãã³ã°ã«ã€ããŠã®ãµã
ã«ããå®å
šãªãã¬ãŒã³ããŒã·ã§ã³ãèŠããããããŸããã ããã§ããããã®æè¡ãè©ŠããŠã¿ãæ©äŒãçãŸããŸããã
競äºã®äž»é¡ã¯ãClojureãŸãã¯ClojureScriptã䜿çšããŠ48æé以å
ã«äœããæåºããããšã§ãã ããŸããŸãªãªãã·ã§ã³ã®äžã§ãç¹ã«æ¢åã®ã¢ããªã±ãŒã·ã§ã³ã¯ãã¹ãŠãFlashã§æžãããã€ã³ã¿ãŒãã§ãŒã¹ãããã«æªãããšã«SilverlightããŸãã¯ä»ã®æ¹æ³ã§åš¯æ¥œãå°ç¡ãã«ããã€ã³ã¿ãŒãã§ãŒã¹ã«ãã£ãŠç Žå£ãããããããã©ãŠã¶ãŒã®
Riskãåæžããããšã決å®ãããŸããã
ãŠã©ãŒãã°ããããšããè¯ãååããŸãšããŠæãã€ããã
ããèããããšãªããå
±éã®ã³ãŒãã䜿çšããŠãClojureã§ãµãŒããŒãšClojureScriptã§ã¯ã©ã€ã¢ã³ãã®äž¡æ¹ãäœæããããšã«ããŸããã 4人ã®åå è
ã®ãã¡ãå°ãªããšãæé¢ã§æžãçµéšããã£ãã®ã¯Saniã®ã¿ã§ãæ®ãã¯
4clojureã§æ°ååã®åé¡ã解決ããçµéšãããããŸãã
ã§ãã ã
ãµãŒããŒ
ãµãŒããŒåŽã«ã€ããŠã¯ããŸãèªããŸããã競äºã®å
šæéãéããŠããµãŒããŒåŽã«äžåºŠã觊ããããšã¯ãããŸããã ããŒã¿ããŒã¹ãšããŠã2ã€ã®ãªãã·ã§ã³ããéžæããŸããã
ClojureãšãããŒã¿ããŒã¹ããšããåèªãçµã¿åããããšãã«æåã«é ã«æµ®ãã¶ã®ã¯ã
Datomicã§ãã è©ŠããŠã¿ãã®ã¯éåžžã«èå³æ·±ãã§ãããç§ãã¡ã®èª°ããæ°æéãããªãã§ãã¢ãããã¯ã®çµéšããŸã£ãããããŸããã§ããããŸãããããžã§ã¯ãã®å¥ã®ãŸã£ããæ°ããã³ã³ã»ãããã€ãã·ã¢ãããå°ç¡ãã«ããæåããŸããã
ãã®ãããããæ°å¹Žã§æããã¡ãã·ã§ããã«ãªããŒã¿ããŒã¹ã§ããPostgreSQLãéžæããŸããã
圌ãã¯
si14ã®ã¯ããŒããŒãã¯ãŒã¯ããŒã¹ãšããŠäœ¿çšããããšããŸããããç§ãã¡ã«ãšã£ãŠé£ããããããšãããããŸããã éå§ããåæ¥åŸã圌ãã¯ã¯ããŒã³ãªãã§æ°ãããªããžããªãäœæããããã§ãã¹ãŠã®äœæ¥ãè¿
éã«è»¢éããŸããã
ãµãŒããŒã§äœ¿çšããã©ã€ãã©ãªãcompojureãringãkormaãfriendãcheshireãhttp-kitããªã¹ãããŸãã ç§ã®è³ããã¯ãè¹å°Ÿã«ã€ããŠäžå¿«ãªã³ã¡ã³ããèããã®ã§ãã»ã«ã²ã€ã¯ãã®äž»é¡ã«é¢ããä»ã®ãã¹ãŠã®è©³çŽ°ã圌ã®
ããã°ã§èª¬æããããšãçŽæããŸããã
ã客æ§
ã¯ã©ã€ã¢ã³ãã§äœ¿çšãããã¯ãããžãŒãéžæããŸãã æ°ãã
ã§ããcore.asyncããããŸããããã¹ãŠã®
ãã¥ãŒããªã¢ã«ãšããã¥ã¢ã«ãããŒã¿ã管çããã®ãããã«
çŽ æŽãããããæžããŠãããšããäºå®ã®ããã«æ¶ãã
ã»ã¬ã¯ã¿ãŒã«ãã£ãŠDOMã«OMãããŸãã ããã¯æ¬ é¥ã®ããæŠå¿µã§ãããšããæèŠããããŸãããHTMLãã€ã³ã¿ãŒãã§ãŒã¹ãæ§ç¯ããæ¹æ³ã§ããããšãåãå
¥ããªããã°ãªããŸããã ãããŠãã»ã¬ã¯ã¿ãŒã«åå ããå Žåãç§ãã¡ã¯ãããšåãããã«ããã®åŽã§äœæ¥ããŠããŸããã€ã³ã¿ãŒãã§ãŒã¹ã®æ§é ãå€æŽãããããããããã®ã»ã¬ã¯ã¿ãŒãéåžžã«æ
éã«éå±ã«èŠãªããã°ãªããŸããã
ClojureScriptçšã®æ Œå¥œè¯ã
åå¿ã©ã€ãã©ãªããããŸã-
ãžã£ããªã³ãš
ããããã³ã®æã§ãã æŠå¿µçãªèŠ³ç¹ããã¯åªããŠããŸãããæé©åã«ã¯èª°ãé¢äžããŠããªããããéåžžã«é
ããªããŸããæãåçŽãª
Todoã®äŸã¯ ããã¹ã¯ãããFirefoxã§ãé¡èã«é
ããªããŸãã ããè€éãªã¢ããªã±ãŒã·ã§ã³ã®éçºã¯ãã€ã³ã¿ãŒãã§ãŒã¹ã®çµ¶ãéãªããã¬ãŒãã®ããã«çã¿ã«å€ããã圌ãã¯æåŠããããšã«ããŸããã
ææ°ã®ãããžã§ã¯ãã§ã¯ãSanyaãšRomaã¯Facebook
Reactãã³ãŒããŒã¹ã¯ãªãããšçµã¿åãããŠäœ¿çšââããŠããã圌ãã¯æ¬åœã«æ°ã«å
¥ã£ãŠããŸãã 圌ãã¯åœŒãé£ããŠè¡ããŸããã 競äºãå§ãŸãåã®éææ¥ã«ãç§ã¯Reactãå°ããã€æ±ãå§ãã圌ã®ããã«ãã€ã³ãã£ã³ã°
ã©ã€ãã©ãªãæžãå§ããŸããã æåã®ããŒãžã§ã³ã¯ãåææ¥ã«ååŸ1æã«å®æããŸããã
ããã¯ãReactã®å€èŠ³ã§ãã
var HelloMessage = React.createClass({ displayName: 'HelloMessage', componentWillMount: function() { ... }, render: function() { return <div class="smth">{'Hello ' + this.props.name}</div>; } });
ãã®XMLã«äŒŒãæ§æã¯äŸ¿å©ã§ãããjavascriptã§ç解ã§ããŸãã ããããClojureã«çµ±åããããšããèããŠããŸããã§ããã
ããã£ããæ§æã«è§ŠçºãããŠããã®ãªãã·ã§ã³ãäœæããŸããã
(defr HelloMessage :component-will-mount (fn [] ...) [this props state] [:div.smth (str "Hello " (:name props))])
ã¹ã¯ãªãããšãªã¢ã¯ã·ã§ã³ã®äº€å·®ç¹ã§ããã€ãã®åé¡ãçºçããŸããã ããšãã°ãæåã«ClojureScript'ovyeããŒã¿æ§é ãç¶æ
ãšããŠçŽæ¥äœ¿çšããããšããŸãããããããã¿ã€ãã転éããã«èªåèªèº«ã®å
éšã§ã®åå¿ãæµ
ãã³ããŒãäœæãããã¹ãŠãå£ããŸããã æŸèæãšããŠã圌ãã¯
state.state
ãã£ãŒã«ãã«ç§ãã¡ã®ç¶æ
ãè¿œå ãå§ããŸããã
ãã¡ãããã©ã€ãã©ãªã«ã¯é ãããŠããŸããããã®ãããç¶æ
ãå€æŽããããã«äœ¿çšããå¿
èŠããã
assoc-in-state
ãã«ããŒãš
assoc-in-state
ãã«ããŒãäœæããå¿
èŠããããŸããã Reactéçºè
ã®1人ã§ããircã®Pete Huntã¯ãåãåé¿çãææ¡ããŸããã ã©ãããããã圌ãã¯ããé©åãªæ¹æ³ã§å人ãäœãããšãã§ããã§ãããã
äžè¬ã«ãã¯ã©ã€ã¢ã³ãã§ã¯ãç¶æ
å
šäœã1ã€ã®ã¢ãã ã1ã€ã®ããŒã¿æ§é ã«æ ŒçŽããå¿
èŠãªéšåã§ããã«æ·±ãã³ã³ãããŒã©ã«è»¢éããŸãã javascriptãããã°ãããŒã«ã«ã®é»ç€ºé²ããã£ãã¯ãã§ãããã€ã³ãã©ã¹ãã©ã¯ãã£å
ã®ããŒã¿æ§é ã¯äžå®å®ã§ãããããåé¡ã¯ãããŸããã§ããã
ãµãŒããŒãšã¯ã©ã€ã¢ã³ãéã®éä¿¡ã«jsonã䜿çšããŸãããããã¯ãã¯ã©ã€ã¢ã³ãã®ã¯ãŒã«ãª
ednã¬ã€ã¢ãŠã圢åŒã®ãã·ãªã¢ã©ã€ãºãçŽ1æ¡é
ããªããéå±€æ§é ãä¿åãã
cljsonã銬鹿ããŠç解ãã«ããããã«èŠããããã§ãã ãããŠããã¯ééãã§ããããšãå€æããŸããïŒ
ãã®åŸã
:keyword
ãããŒã¯ãŒãããšããŠã·ãªã¢ã«åãã
:keyword
ãšããäºå®ã«åé¡ãçããŸããã
:keywordize-keys
èšãããšãã§ã
:keywordize-keys
ããèŸæžããããŒã¯ãŒããäœæããŸãã ããããããã¯ãã¹ãŠã®åé¡ã解決ããããã§ã¯ãããŸãã-ãã¹ãŠã®ããŒã¯ãŒããèŸæžã®ããŒã§ã¯ãªããä»ã®ãã®ãäœæããŸã-èŸæžã®ãã¹ãŠã®ããŒãããŒã¯ãŒãã§ã¯ãããŸããã§ããã æ°å€ã§ã¯ç¹ã«äžå¿«ã§ããããšãå€æããŸãã-ãµãŒããŒåŽã®Clojureã¯ãŸã£ããå®è¡ã§ãã
(keyword 1)
ã
nil
ãè¿ããClojureScriptã¯
:1
ãè¿ããŸãããç¹å¥ãªãªãã·ã§ã³ã§éã·ãªã¢ã«åãããjsonã®ããŒã«ã¯ãæ°å€ã§ã¯ãªãæååãå«ãŸããŠããããšãããããŸãã
(keyword "1")
ã
æ¥ææ¥ã®åŸåãããç§ãã¡ã¯ãã®åé¡ã§å°ãªããšã1æéåã倱ããä»ã§ã¯æŸèæããã¡ãã¡ã«çœ®ãããŠããŸãã æåã¯cljsonã䜿çšããå¿
èŠããããŸãããããããã䜿çšããããã«ããçŽããŸãã
ãã®ãŠã£ã³ããŠã®ã³ãŒãã¯æ¬¡ã®ãšããã§ãã
(defr Attack [C {:keys [attacker attacking defender defending attack!]} S] (let [[aname {:keys [coordinates]}] attacker [dname dmap] defender [xy] (xy-for-popover coordinates)] [:div.popover {:style {:display "block" :left x :top y}} [:div.popover-content [:table [:thead [:tr [:th (name aname)] [:th (name dname)]]] [:tbody [:tr [:td attacking] [:td defending]]]] [:div.btn-group [:button.btn.btn-warning {:on-click #(attack! 1 aname dname)} "Attack"] [:button.btn.btn-danger {:on-click #(attack! (dec attacking) aname dname)} "Blitz"]]]]))
ç§ã®æèŠã§ã¯ãããã§èµ·ããããšã¯ãã¹ãŠæ確ã§ãã ãããŠã誰ããããã®æ¬åŒ§ã®æ°ã«æ©ãŸãããŠããå Žåãå®éã®HTMLã«ã¯ããã«2åããããšã«æ³šæããŠãã ããïŒ
<div></div>
ã
[:div]
ã ããã«ãç·šéæã«pareditãéåžžã«åœ¹ç«ã¡ãŸããæ¬åŒ§ã§æ··ä¹±ããããšã¯ãŸã£ãããããŸããã
äžè¬çã«ãClojureScriptãšReactã¯umatã®æã§ãããšæããŸããã䜿çšããããšãã§ãã䜿çšããå¿
èŠããããŸãã
競äº
Sanyaã¯2é±éåã«Clojure Cupã«åå ããããšã«ã€ããŠå«ã³ããã®åŸã圌ãã¯ç§ãã¡ãäœããããããããŠã©ã®ãã¯ãããžãŒã䜿çšãããã«ã€ããŠåæããŸããã ãããããã€ãã®ããã«ãèªåèªèº«ãåå¿ãžã®çŽæã«ããããããããã®ãããªç«¶æã®æºåãããŠãã人ã¯ã»ãšãã©ããŸãããç§ãã¡ãäŸå€ã§ã¯ãããŸããã éææ¥ã®å€ã«ã©ã€ãã©ãªãäœæãå§ããŸãããïŒããã¯ã«ãŒã«ã§èš±å¯ãããŠããŸãïŒïŒ
Clojurecupèªäœã¯ãåææ¥ã®00:00 UTCããæææ¥ã®00:00 UTCãŸã§ãé±æ«ã®ã¡ããã©48æéç¶ããŸããã ç§ãã¡ã®æéã§ã¯ãåå3æã§ãã
åææ¥ã®æã«ãªãã£ã¹ã«éãŸã£ãŠãç§ãã¡ã¯çŽåæ¥ããããŠãå³æžé€šãããããçš®é¡ã®ã»ããã¢ãããããã³ãã®ä»ã®åŽåæ¡ä»¶ã®æ§ç¯ã«è²»ãããŸããã
åææ¥ã«ãMozillaã®
Person ïŒçŽ æŽãããããšïŒïŒãä»ããŠæ¿èªãåŸãŸãããWebãœã±ãããä»ããŠã¯ã©ã€ã¢ã³ããšãµãŒããŒéã§ã¡ãã»ãŒãžãéä¿¡ããã¯ã©ã€ã¢ã³ããšãµãŒããŒéã®ãããã³ãŒããå°ããããŒã¿ããŒã¹ã«ã¯ãŠãŒã¶ãŒãã²ãŒã ãã€ãã³ããã°ãå«ãã¿ãã¬ããããããŸãã ã¯ã©ã€ã¢ã³ãäžã§ããããªããªãŒãå«ãåŸæ¥ã®ãªã¹ã¯ããããæç»ããå§ãããããŒã§äœããã®åœ¢ã§åŒ·èª¿è¡šç€ºãããŸããã æçµã³ãããã¯22:30ã§ãã
æ¥ææ¥ã®æãç§ã¯ç§ãã¡ã«çŽ æµãªããŽãæããŠãããããç§ã¯æ¥ææ¥ãã¹ãŠã1ã€ã®é£ç¶ããããã«ã³ãŒãã«å¡ãã€ããŸããã ã²ãŒã ã«ãŒããšãµãŒããŒã®ãªã³ã¯ã移åãæ»æãè£å
ãªã©ã¯ãå®éã«ã¯æåŸã«æ®ããŸããã
å€æ¹ãŸã§ãããã¯ãŸã å解ãããç¶æ
ã§ã8æãŸã§ã«ãããã®èšè¿°åœ¢åŒããããã«å€æŽãããµãŒããŒã«åããŠããŒãããŸããã ã²ãŒã ãæå°éã®äœæ¥ç¶æ
ã«ä»äžããæéããããã©ããã¯ãŸã å®å
šã«ç解ã§ããªãã®ã§ãäœãããããã£ã³ã¹ãšæ¬²æ±/èœåãèŠãããŸã§ç¶ããããšã«ããŸããã
8æã9æãããç§ãã¡ã¯å¥ã®éšå±ã«ç§»åããŸãããããã§ã¯ãç
§æãããè¯ãã涌ããããè¶ãšã³ãŒããŒã®ããã³ãŒããŒã«è¿ã¥ããŠããŸãã:)äœæ¥ããŒãžã§ã³ãäœãæ©äŒãåžžã«ãããååãªãšãã«ã®ãŒãšç±æããããç§ãã¡ã¯èŠããç· ãåããŸã§åœŒãèŠãã
åäœäžã®ã²ãŒã ãšã移åãçµäºããããã¿ã³ã§ã³ãããããŸãã
2013幎9æ30æ¥æææ¥02:59:54 GMT + 0300ïŒEESTïŒ
æ®å¿µãªãããæ¬çªããŒãžã§ã³ã§ã¯ããã¡ã€ã«ãããããããŒã¿ãèªã¿èŸŒãéã«ãã°ãå
¥ã蟌ã¿ãŸããã ããŒã«ã«ã§åäœããŸãããuberjarã§ããã±ãŒãžåããå Žå-ãããããªãœãŒã¹ããããŒãããå¿
èŠããããŸãã ãããä¿®æ£ããã³ãããã¯çµäºã®5ååã§ãããã倱æããããšãå€æããåçã§ããªãããŒãžã§ã³ãæçš¿ããŸããã æåéã15åã§ã¯äžååã§ãã
ã«ãŒã«ã«åŸã£ãŠãç§ãã¡ã¯äœããä¿®æ£ããããå¥ã®ããŒãžã§ã³ãã©ããã«æçš¿ããæš©å©ã¯ãããŸããã ããã§æ祚ãè¡ãããæšææ¥ã«çµäºããéææ¥ã«å®å
šã«æ©èœããããšãæŽæ°ããŠè¡šç€ºããããšãå¯èœã«ãªããŸãã
åèšã§ã90以äžã®ããŒã ãç»é²ãããŸããã ãã¹ãŠã®ããŒã ã®åèšã³ãããæ°ã®ã³ãããã®6.5ïŒ
ãååŸããŸãããããã«1ã€ä»¥äžã®ããŒã ãããã9.15ïŒ
ã®ããã§ãã
42ããŒã ãæ祚ã®ããã«éžã°ããŸããã äœããã®çç±ã§ãFirefoxã§ã¯ã圌ãã®ãµã€ãã¯å®éã«ã¯æ©èœããŸããã ã¯ãã ã§åäœããŸãã
éææ¥ã«ã¯ããããã«ããäœæ¥ããŒãžã§ã³ãæçš¿ããããšããçŽæããŸãããä»ã®ãšããã¯ããŒã ã®ããŒãžã§
æ祚ããŠãã ããïŒ