Clojureæ´¾ãPythonãé ·è©
Clojureã§é£ã£ã¦ããã¨ããè ãPythonãfunctional programmingãconcurrencyã®è¦³ç¹ããæ¹è©ãPythonã¯è²ã ãªãã©ãã¤ã ããµãã¼ããããã¨ãããã¦ä½ããã¾ãã§ããªãå¹¼ç¨ãªè¨èªã«ãªã£ã¦ãã¾ã£ãã¨ããçµè«ã
http://blog.bestinclass.dk/index.php/2009/10/python-vs-clojure-evolving/
Functional Programming
ç°¡åãªã¢ã«ã´ãªãºã ãªãclojureã¨pythonã®è¡¨ç¾åã¯ãã»ã©å¤ããªãããè¤éãªãã®ã«ãªã£ã¦ããã¨å¤§éãããããprojecteulr(http://projecteuler.net/)ããã®å®ä¾ã§ç¤ºãã¦ãããeuler4ã®çã ã¨Pythonã4以ä¸ã®ã³ã¼ããµã¤ãºã«ãªã£ã¦ãã¾ãã ãEuler 4: Finding Palindromsããåç §ã
Concurrency
ãããã¡ã¼ã«ã¼ãGhzã®å¢å¤§ãã§ããªãªããªã£ãä»ã並åå¦çãããããã®å¤§ããªèª²é¡ã«ãªãããPythonã«ã¯å¯¾çããªããPythonã¯è¤æ°ã®ã¹ã¬ããã§ãGILãããã¯ã¨ãªã£ã¦ãã«ãã³ã¢ãã·ã³ã§ã並åå¦çãéããªããªããGuidoã¯GIL(Global Interpreter Lock)åé¡ãå æããã¤ããããªãã¨ãããã ããå¼ç¨ãã¦ããã
Clojureã¨Pythonã®ä¸¦åå¦çãç°¡åãªã«ã¦ã³ã¿ã¼ã®å®ä¾ã§æ¤è¨¼ãã¦ãããäºã¤ã®è¨èªã®ãã¶ã¤ã³ãèããã¨ãããã¾ãã®çµæ(2cpu使ã£ã¦4å以ä¸ã®å·®)ãåºããã ãããã¯ãç®ã®å½ããã«ã³ã¼ãã¨æ°åãè¦ãã¨ãããã«ãã³ã¢æ代ã«Closureãã!ããæãç¥ãããããä¸æ¹ãPythonã¯ãå çã£æããAn exampleããåç §
çµè«ã¨ãã¦ãPythonã¯ã©ã¤ãã©ãªãå å®ãã¦ãã¦ãã¨ã£ã¤ããããã大ããªã¦ã¼ã¶ã³ãã¥ããã£ã¼ãå©ç¹ã ããå¾æãªãã®ããªãã並åå¦çåé¡ããéããããã«ããã°ã©ãã®é è³ãåºæ¿ãããã®ãç¡ãåç´ãªè¨èªã¨ãã¦ãããæå¾ã«ããGuidoã俺ã®ã½ã¼ã¹ã®ç©ºç½ç®¡çãããã®ã¯ããããããã¨ã·ã³ã¿ãã¯ã¹ã«æå¥ãã¤ãã¦ããã
ãã³ã°ã¯æè¿ãã£ã±ãPythonã§ããã°ã©ãã³ã°ããã¦ãããä¸ã®æ¹è©ã¯çããã¦ããã¨æããPythonããæ¬å¼§ã®ãªãLispãã ã¨ããFunctiona Programmingããµãã¼ããã¦ãããã¨ãè¨ãæ¹ã ãããããå¤åããã¯lispã«è§¦ãããã¨ã®ç¡ã人éã ãããé¢æ°ã®æå¾ã®è¡¨ç¾ã®å¤ãè¿ããreturnãæ¸ããã¨ãå¼·è¦ããããexpressionã¨statementã¨ã«éããlambdaãä¸è¡ã ãã«å¶ç´ããã¦ãããããpythonã§Functionalã£ã½ãã³ã¼ããæ¸ããã¨ããã¨ã¹ãã¬ã¹ããã¾ããPaul Grahamãè¨ã£ã¦ãããPerlã®æ¹ããã£ã½ã©functionalã ãä»ã§ã¯å²åã£ã¦ãside-effectã®ãªã表ç¾ãä½ããã¨ã¯ãããããããã¨statementãæ¸ãç¶æ å¤åãããã¢ã¼ãã§ã³ã¼ãã£ã³ã°ããããã«ãã¦ãããpythonã¯functionalã¹ã¿ã¤ã«ãå«ãimparativeãªã¹ã¿ã¤ã«ã奨å±ãã¦ãããããã¨éã£ã¦ãããããªãã
ãã¨ãä¸ã§å©ç¹ã«ããã£ã¦ããã©ã¤ãã©ãªã¨ã³ãã¥ããã£ã¼ã ãããããPerlã«ã¯ããªããªããcpanã®ã©ã¤ãã©ãªã®è±å¯ããAPIãã¶ã¤ã³ãããã¥ã¡ã³ãã¼ã·ã§ã³ãããã±ã¼ã¸ç®¡çã使ãæããã©ããåã£ã¦ãperlã«å£ãã¨æãã
ããããperlã®ãã©ããã¯ã¹ãã ãã³ã¢è¨èªãæ» è¶è¦è¶ã§ã³ã¼ããä½ããªãã ããããããªãPerlã ãããã®(ããã«ã)ãµãã¼ãä½å¶ã¯é常ã«æ´çæ´é ããã¦ãã¦åãããããã®ã¨ãªã£ã¦ããã
ããã«å¤§ãã¦ãPythonãã©ããã¯ã¹ãããããPythonã¯èªåã§è¨ãã»ã©ãã¨ã¬ã¬ã³ãã§ãªããä¸è²«æ§ããªãã
ããã¾ã§æ¹å¤çãªã®ã«ä½æ pythonã使ãã®ããããã¯ã·ã³ã¿ãã¯ã¹ã好ãã ããã ãä»ã®è¦ç´ ãå£ã£ã¦ãã¦ããããè£ã£ã¦ãé£ããããããã·ã³ã¿ãã¯ã¹ãããããã ãããããpythonã¯è²ã ãããã ãã©ã·ã³ã¿ãã¯ã¹ããã¼ãä¸è«ã¨æ£å対ãªã¨ããã ããã»ã©functionalã§ããªããå¾ææããªããconcurrencyãé§ç®ãªpythonãã§ããã¾ã¼ã³ãã«å ¥ãããããã¦ãããã·ã³ã¿ãã¯ã¹ãããã®ã§ããã¨ãã!