ãã¥ãŒãªã³ã°ãã·ã³ãèšç®å¯èœãªãã¹ãŠãèšç®ã§ãããšããäžè¬çãªèª€è§£ããããŸãã ãã¥ãŒãªã³ã°ãã·ã³ã䜿çšããŠèšç®ã§ããåé¡ã®ã¯ã©ã¹ïŒããšãã°ã åæ¢ã®åé¡ãªã© ïŒãããã€ããããŸãã ãã®ããã¹ãã§ãèšç®å¯èœããšããèšèã䜿çšãããŠããå Žåãããã¥ãŒãªã³ã°ãã·ã³ã«ããèšç®å¯èœããšããæå³ã§ãã
ã©ã ãèšç®ã¯ããããããŠã³ããŒã¹ã§èšç®ã«é¢æ°ãé©çšããã¢ãããŒãã瀺ããŠããŸãã ãã¥ãŒãªã³ã°ããŒããã·ã³ã¯ãããã ã¢ããããŒã¹ã§å®è£ ããããã³ã³ãã¥ãŒãã£ã³ã°ãžã®äžå¯æ¬ ãªïŒã¹ããããã€ã¹ãããïŒã¢ãããŒãã§ãã
ãã·ã³ã³ãŒããã¢ã»ã³ãã©ãªã©ã®äœã¬ãã«ããã°ã©ãã³ã°èšèªã¯1940幎代ã«ç»å Žãã1950幎代ã®çµããã«ã¯ãæ©èœçã¢ãããŒããšåœä»€åã¢ãããŒãã®äž¡æ¹ãå®è£ ããæåã®äººæ°ã®é«ã¬ãã«èšèªãç»å ŽããŸããã ãã®ãããClojureãSchemeãAutoLispãªã©ãLispèšèªã®æ¹èšã¯ãŸã åºã䜿çšãããŠããŸãã 50幎代ã«ã¯ãFORTRANãCOBOLãªã©ã®èšèªãç»å ŽããŸããã ãããã¯ããŸã çããŠããåœä»€åã®é«ã¬ãã«èšèªã®äŸã§ãã Cãã¡ããªãŒã®èšèªã¯ãã»ãšãã©ã®åéã§ãCOBOLãšFORTRANã®äž¡æ¹ã眮ãæããããšã«æ³šæããå¿ èŠããããŸãã
åœä»€åããã°ã©ãã³ã°ãšé¢æ°åããã°ã©ãã³ã°ã®ã«ãŒãã¯ãã³ã³ãã¥ãŒãã£ã³ã°ã®æ£åŒãªæ°åŠã«ãããããžã¿ã«ã³ã³ãã¥ãŒã¿ãŒã®åã«ç»å ŽããŸããã ãªããžã§ã¯ãæåããã°ã©ãã³ã°ïŒOOPïŒã¯åŸã«ç»å ŽããŸãã;ããã¯ãåäžçŽã®60幎代ãš70幎代ã«èµ·ãã£ãæ§é ããã°ã©ãã³ã°é©åœã«ç±æ¥ããŸãã
ç§ãç¥ã£ãŠããæåã®ãªããžã§ã¯ãã¯ã1961幎ãã1962幎ã®éã«äœæããã圌ã®éåœçãªã¢ããªã±ãŒã·ã§ã³Sketchpadã§Ivan Sutherlandã«ãã£ãŠäœ¿çšãããŸããã ãªããžã§ã¯ãã¯ããªã·ãã¹ã³ãŒãç»é¢ã«è¡šç€ºãããã°ã©ãã£ãã¯ãã£ã©ã¯ã¿ãŒã§ããïŒãããããã°ã©ãã£ã«ã«ã³ã³ãã¥ãŒã¿ãŒã¢ãã¿ãŒã䜿çšããå²äžåããŠïŒããã€ãããã¯ããªã²ãŒããä»ããç¶æ¿ããµããŒãããŠããŸããIvanSutherlandã¯ã圌ã®äœåã§ããã¹ã¿ãŒããšåŒã³ãŸããã ä»»æã®ãªããžã§ã¯ãããã¹ã¿ãŒãªããžã§ã¯ãã«ãªãå¯èœæ§ãããããªããžã§ã¯ãã®è¿œå ã®ã€ã³ã¹ã¿ã³ã¹ã¯ãçºçããšåŒã°ããŸããã ããã«ãããSketchpadã·ã¹ãã ã¯ãããã¿ã€ãç¶æ¿ãå®è£ ããæåãªããã°ã©ãã³ã°èšèªã®æåã®ææè ã«ãªããŸããã
äžè¬ã«ããªããžã§ã¯ãæåããšããŠç¥ãããæåã®ããã°ã©ãã³ã°èšèªã¯Simulaèšèªã§ããã®ä»æ§ã¯1965幎ã«éçºãããŸããã ã¹ã±ããããããšåæ§ã«ãSilmulaã¯ãªããžã§ã¯ãã®æäœçšã«æäŸãããŠããŸããããã¯ã©ã¹ãã¯ã©ã¹ããŒã¹ã®ç¶æ¿ããµãã¯ã©ã¹ãä»®æ³ã¡ãœãããå«ãŸããŠããŸããã
ä»®æ³ã¡ãœããã¯ããµãã¯ã©ã¹ãåå®çŸ©ããããã«èšèšãããã¯ã©ã¹ã§å®çŸ©ãããã¡ãœããã§ãã ä»®æ³ã¡ãœããã䜿çšãããšãããã°ã©ã ã¯ãåçãã£ã¹ãããã䜿çšããŠå®è¡æã«åŒã³åºãç¹å®ã®ã¡ãœããã決å®ããããšã«ãããã³ãŒãã®ã³ã³ãã€ã«æã«ååšããªãå¯èœæ§ã®ããã¡ãœãããåŒã³åºãããšãã§ããŸãã JavaScriptã«ã¯åçãªåããããå§ä»»ãã§ãŒã³ã䜿çšããŠåŒã³åºãã¡ãœããã決å®ããããããã®èšèªã§ã¯ããã°ã©ããŒã«ä»®æ³ã¡ãœããã®æŠå¿µãå°å ¥ããå¿ èŠã¯ãããŸããã ã€ãŸããJavaScriptã®ãã¹ãŠã®ã¡ãœããã¯å®è¡æã«ãã£ã¹ãããã䜿çšããããããã®æ©èœããµããŒãããããã«JavaScriptã®ã¡ãœããããä»®æ³ããšå®£èšããå¿ èŠã¯ãããŸããã
OOPã«ã€ããŠã®OOPç¶èŠªã®æèŠ
ããªããžã§ã¯ãæåããšããçšèªãäœãåºããŸããããC ++ãæå³ãããã®ã§ã¯ãªãã£ããšèšããŸããã ã¢ã©ã³ã»ã±ã€ãOOPSLA Conferenceã1997ã
Alan Kayã¯ãããã°ã©ãã³ã°èšèªSmalltalkïŒ1972ïŒãæãããªããžã§ã¯ãæåããã°ã©ãã³ã°ããšããçšèªãçã¿åºããŸããã ãã®èšèªã¯ãDynabookããã€ã¹ãããžã§ã¯ãã®äžç°ãšããŠãAlan KayãDan Inglesãããã³Xerox PARC Research Centerã®ä»ã®åŸæ¥å¡ã«ãã£ãŠéçºãããŸããã Smalltalkã¯Simulaããããªããžã§ã¯ãæåã§ããã Smalltalkã§ã¯ãã¯ã©ã¹ãæŽæ°ããããã¯ïŒã¯ããŒãžã£ïŒãªã©ããã¹ãŠããªããžã§ã¯ãã§ãã èšèªã®åæå®è£ ã§ããSmalltalk-72ã«ã¯ããµãã¯ã©ã¹åããæ©èœããããŸããã§ããã ãã®æ©èœã¯Smalltalk-76ã§ç»å ŽããŸããã
Smalltalkã¯ã¯ã©ã¹ããµããŒããããã®çµæããµãã¯ã©ã¹åãè¡ããŸããããSmalltalkã¯ãããã®ã¢ã€ãã¢ãæåç·ã«çœ®ããŸããã§ããã LispãSimulaãšåãããã圱é¿ãäžããé¢æ°åèšèªã§ããã Alan Kayã«ãããšãã¯ã©ã¹ãã³ãŒãåå©çšã¡ã«ããºã ãšããŠæ±ãã®ã¯ééãã§ãã ããã°ã©ãã³ã°æ¥çã¯ããµãã¯ã©ã¹ã®äœæã«å€å€§ãªæ³šæãæã£ãŠããããªããžã§ã¯ãæåããã°ã©ãã³ã°ã®çã®å©ç¹ããéžããŠããŸãã
JavaScriptãšSmalltalkã«ã¯å€ãã®å ±éç¹ããããŸãã JavaScriptã¯ãOOPã®æŠå¿µã誀解ããããšã«å¯ŸããSmalltalkã®äžçãžã®åŸ©geãšèšããŸãã ãããã®èšèªã¯äž¡æ¹ãšãã次ã®æ©èœããµããŒãããŠããŸãã
- ãªããžã§ã¯ã
- ãã¡ãŒã¹ãã¯ã©ã¹ã®é¢æ°ãšã¯ããŒãžã£ãŒã
- åçã¿ã€ãã
- é 延ãã€ã³ãã£ã³ã°ïŒé¢æ°ãšã¡ãœããã¯ããã°ã©ã å®è¡äžã«çœ®ãæããããšãã§ããŸãïŒã
- ã¯ã©ã¹ããŒã¹ã®ç¶æ¿ã·ã¹ãã ã®ãªãOOPã
ãç§ã¯ããã®çŸè±¡ã®çšèªããªããžã§ã¯ãããæãã€ããã®ã¯ããªãåã§ãããªããªãããã®äœ¿çšã¯ãå€ãã®äººã ãäž»èŠãªãã®ã»ã©éèŠã§ã¯ãªãã¢ã€ãã¢ãäž»ã«éèŠèŠãããšããäºå®ã«ã€ãªããããã§ãã äž»ãªã¢ã€ãã¢ã¯ã¡ãã»ãŒãžã³ã°ã§ããã ã¢ã©ã³ã»ã±ã€
2003幎ã®é»åã¡ãŒã«é信㧠ãã¢ã©ã³ã±ã€ã¯ãSmalltalkãããªããžã§ã¯ãæåèšèªããšåŒãã ãšãã«åœŒã念é ã«çœ®ããŠããããšãæ確ã«ããŸããã
ãç§ã«ãšã£ãŠãOOPãšã¯ãã¡ãã»ãŒãžã³ã°ãããŒã«ã«ã¹ãã¬ãŒãžãä¿è·ãé衚瀺ç¶æ ãããã³éåžžã«é ããã€ã³ãã£ã³ã°ã®ã¿ãæå³ããŸããã ã¢ã©ã³ã»ã±ã€
èšãæããã°ãã¢ã©ã³ã±ã€ã®ã¢ã€ãã¢ã«æ²¿ã£ãŠãæãéèŠãªOOPæåã¯æ¬¡ã®ãšããã§ãã
- ã¡ãã»ãŒãžã³ã°
- ã«ãã»ã«åã
- åçãªã³ã¯ã
ãOOPããšããçšèªãçºæããŠå€§è¡ã«æã¡èŸŒãã ã¢ã©ã³ã»ã±ã€ã¯ãç¶æ¿ãšå€åãOOPã®æãéèŠãªèŠçŽ ãšã¯èããŠããªãã£ãããšã«æ³šæããããšãéèŠã§ãã
OOPã®æ¬è³ª
ã¡ãã»ãŒãžã³ã°ãšã«ãã»ã«åã®çµã¿åããã¯ãããã€ãã®éèŠãªç®çãæãããŸãã
- ç¶æ ãã«ãã»ã«åããç¶æ ã®ããŒã«ã«ãªå€æŽããä»ã®ãªããžã§ã¯ããåé¢ããããšã«ããããªããžã§ã¯ãã®å ±æå¯èœãªå¯å€ç¶æ ãåé¿ããŸãã å¥ã®ãªããžã§ã¯ãã®ç¶æ ã«åœ±é¿ãäžããå¯äžã®æ¹æ³ã¯ãïŒã³ãã³ããäžããã®ã§ã¯ãªãïŒåœŒã«ã¡ãã»ãŒãžãéä¿¡ããŠå€æŽããããäŸé Œããããšã§ãã ç¶æ ã®å€åã¯ããŒã«ã«ã®ã»ã«ã¬ãã«ã§å¶åŸ¡ãããç¶æ ã¯ä»ã®ãªããžã§ã¯ãããã¯å©çšã§ããŸããã
- ãªããžã§ã¯ãã®çžäºåé¢ã ã¡ãã»ãŒãžã®éä¿¡è ã¯ãã¡ãã»ãŒãžã³ã°APIãä»ããŠåä¿¡è ã«ççµåãããŸãã
- é 延ãã€ã³ãã£ã³ã°ã«ããããã°ã©ã å®è¡äžã®å€æŽã«å¯Ÿããé©å¿æ§ãšæµæã ããã°ã©ã ã®å®è¡äžã«å€æŽã«é©å¿ãããšãAlan KayãOOPã«ãšã£ãŠéåžžã«éèŠã ãšèããå€ãã®éèŠãªå©ç¹ãåŸãããŸãã
ãããã®ã¢ã€ãã¢ãè¡šæããã¢ã©ã³ã±ã€ã®ã€ã³ã¹ãã¬ãŒã·ã§ã³ã®æºã¯ãçç©åŠã«é¢ããç¥èãšãARPANETïŒããã¯ã€ã³ã¿ãŒãããã®åæããŒãžã§ã³ã§ãïŒã«ã€ããŠç¥ã£ãŠããããšã§ãã ã€ãŸããç§ãã¡ã¯çäœçŽ°èãšããããã¯ãŒã¯ã«æ¥ç¶ãããåã ã®ã³ã³ãã¥ãŒã¿ãŒã«ã€ããŠè©±ããŠããã®ã§ãã ããã§ããAlan Kayã¯ããã°ã©ã ã巚倧ãªåæ£ã³ã³ãã¥ãŒã¿ãŒïŒã€ã³ã¿ãŒãããïŒäžã§ã©ã®ããã«åäœããããæ³åããŸããããåã ã®ã³ã³ãã¥ãŒã¿ãŒã¯çç©çŽ°èã®ããã«æ¯ãèããç¬ç«ããç¬èªã®ç¶æ ã§åäœããã¡ãã»ãŒãžãéä¿¡ããŠä»ã®ã³ã³ãã¥ãŒã¿ãŒãšããŒã¿ã亀æããŸã
ãç§ã¯ã现èãŸãã¯ã³ã³ãã¥ãŒã¿ãŒã®ã¡ã¿ãã¡ãŒãããŒã¿ã®é€å»ã«åœ¹ç«ã€ããšãèªèããŸãã[...]ãã ã¢ã©ã³ã»ã±ã€
ãããŒã¿ã®åé€ã«åœ¹ç«ã€ããšèšããšãAlan Kayã¯ãã¡ãããå ±æå¯èœãªå¯å€ç¶æ ã«èµ·å ããåé¡ãšãããŒã¿å ±æã«èµ·å ãã匷åãªæ¥ç¶æ§ãèªèããŠããŸããã ä»æ¥ããããã®ãããã¯ã¯åºãèãããŠããŸãã ãããã1960幎代åŸåãARPANETããã°ã©ããŒã¯ãããã°ã©ã ãéçºããåã«ãããã°ã©ã ã®ããŒã¿ã¢ãã«è¡šçŸãéžæããå¿ èŠæ§ã«äžæºã§ããã éçºè ã¯ãäºåã«ããŒã¿ã®è¡šç€ºã«ãã£ãŠå®çŸ©ããããã¬ãŒã ã¯ãŒã¯ã«èªåèªèº«ãè¿œã蟌ãã ãããå°æ¥äœããå€æŽããããšã¯ããå°é£ã§ããããããã®ãã©ã¯ãã£ã¹ããéããããšèããŠããŸããã
åé¡ã¯ãããŒã¿ã«ã¢ã¯ã»ã¹ããããã®ããŸããŸãªæ¹æ³ãããŒã¿ãžã®ã¢ã¯ã»ã¹ãããæç¹ã§äœ¿çšãããããã°ã©ãã³ã°èšèªã®ç°ãªãã³ãŒãããã³ç°ãªãæ§æãå¿ èŠãšããããšã§ããã ããã§ã®èæ¯ã¯ãããŒã¿ã«ã¢ã¯ã»ã¹ããŠç®¡çããæ®éçãªæ¹æ³ã§ãã ãã¹ãŠã®ããŒã¿ãããã°ã©ã ã§åãã«èŠããå Žåãããã°ã©ã ã®éçºãšä¿å®ã«é¢ããéçºè ã®å€ãã®åé¡ã解決ããŸãã
ã¢ã©ã³ã»ã±ã€ã¯ãããæå³ã§ãã©ã®ããŒã¿ãšããã°ã©ã ãç¬ç«ãããšã³ãã£ãã£ã§ãããã«ãã£ãŠãã¢ã€ãã¢ããåãæããããšããŸããã ãããã¯ããªã¹ããŸãã¯Smalltalkã§ã¯ãã®ãããªãã®ãšã¯èŠãªãããŸããã ããŒã¿ïŒå€ãå€æ°ãããŒã¿æ§é ãªã©ïŒã䜿çšããŠå®è¡ã§ããããšãšãé¢æ°ã®ãããªãœãããŠã§ã¢æ§æãšã®éã«ã¯åé¢ããããŸããã é¢æ°ã¯ãäžæµã®åžæ°ãã§ãããããã°ã©ã ã¯å®è¡äžã«å€æŽã§ããŸãã èšãæãããšãSmalltalkã¯ããŒã¿ãšç¹å¥ãªç¹æš©é¢ä¿ãæã¡ãŸããã
ããã«ãã¢ã©ã³ã±ã€ã¯ããªããžã§ã¯ãã代æ°çæ§é ãšèŠãªãããªããžã§ã¯ãã®åäœã«ã€ããŠæ確ã§æ°åŠçã«èšŒæå¯èœãªä¿èšŒãäžããŸããã
ãæ°åŠçãªèæ¯ãããåãªããžã§ã¯ãã«ã¯è€æ°ã®ä»£æ°ã¢ãã«ãé¢é£ä»ããããšãã§ããé¡äŒŒããã¢ãã«ã®ã°ã«ãŒãå šäœãååšããéåžžã«æçšã§ããããšãç解ã§ããŸãããã ã¢ã©ã³ã»ã±ã€
ãããããã§ããããšã蚌æããããããçŽæãã¬ã³ãºãªã©ã®ãªããžã§ã¯ãã®åºç€ã圢æããããã«ãã«ããŽãªãŒçè«ã¯äž¡æ¹ã®åœ±é¿ãåããŸããã
Alan Kayããªããžã§ã¯ããèŠãæ¹æ³ã®ä»£æ°çæ§è³ªã¯ã代æ°ã¢ãã«ãæ¬è³ªçã«æ¹çšåŒã®åœ¢ã§ããã€ãã®èŠåã«åŸãæäœã§ããããããªããžã§ã¯ãã圢åŒçãªæ€èšŒã決å®è«çãªåäœãæäŸãããã¹ã容ææ§ãæ¹åããããšãå¯èœã«ããŸãã
ããã°ã©ãã®å°éçšèªã§ã¯ãã代æ°ã¢ãã«ãã¯ãç¹å®ã®ã«ãŒã«ã䌎ãé¢æ°ïŒæäœïŒããäœæãããæœè±¡åã§ããããããã®é¢æ°ããã¹ããå¿ èŠã®ããåäœãã¹ãïŒè»žãæ¹çšåŒïŒã«ãã£ãŠå®æœãããŸãã
ãããã®ã¢ã€ãã¢ã¯ãC ++ãJavaãCïŒãªã©ãå«ãCãã¡ããªã®ã»ãšãã©ã®ãªããžã§ã¯ãæåèšèªã§äœå幎ãå¿ããããŠããŸããã ãããããããã®ã¢ã€ãã¢ã¯ãæãåºã䜿çšãããŠãããªããžã§ã¯ãæåèšèªã®æè¿ã®ããŒãžã§ã³ã§ããªã¿ãŒã³ãžã£ãŒããŒã®æ€çŽ¢ãéå§ããŸãã
ãã®æ©äŒã«ãããã°ã©ãã³ã°ã®äžçã¯é¢æ°åããã°ã©ãã³ã°ã®å©ç¹ãåçºèŠãããªããžã§ã¯ãæåèšèªã®ã³ã³ããã¹ãã§åççãªè°è«ãæäŸãããšèª°ããèšãããšãã§ããŸãã
以åã®JavaScriptãSmalltalkã®ããã«ãã»ãšãã©ã®ææ°ã®ãªããžã§ã¯ãæåèšèªã¯ãŸããŸãããã«ããã©ãã€ã ãã«ãªãã€ã€ãããŸãã é¢æ°åããã°ã©ãã³ã°ãšOOPãéžæããçç±ã¯ãããŸããã ãããã®ã¢ãããŒãã®ããããã®æŽå²çæ¬è³ªãèŠããšããããã¯äºææ§ãããã ãã§ãªããè£å®çãªã¢ã€ãã¢ãšããŠãèŠããŸãã
ã¢ã©ã³ã±ã€ã®èãã«ãããšãPLOã§æãéèŠãªããšã¯äœã§ããïŒ
- ã«ãã»ã«åã
- ã¡ãã»ãŒãžã³ã°
- åçãã€ã³ãã£ã³ã°ïŒããã°ã©ã ãå®è¡äžã«å€æŽãéçºããããã«é©å¿ããèœåïŒã
OOPã§ç¡èŠã§ãããã®ã¯äœã§ããïŒ
- ã¯ã©ã¹ã
- ã¯ã©ã¹ããŒã¹ã®ç¶æ¿ã
- ãªããžã§ã¯ããé¢æ°ããŸãã¯ããŒã¿ãšã®ç¹å¥ãªé¢ä¿ã
- ããŒã¯ãŒã
new
ã - å€åã
- éçåä»ãã
- ãã¿ã€ãããšããŠã®ã¯ã©ã¹ã«å¯Ÿããæ 床ã
JavaãŸãã¯CïŒãç¥ã£ãŠããå Žåãéçåä»ããŸãã¯ããªã¢ãŒãã£ãºã ãOOPã®æãéèŠãªèŠçŽ ã§ãããšèãããããããŸããããAlan Kayã¯ä»£æ°åœ¢åŒã®æ®éçãªåäœãã¿ãŒã³ãæ±ãããšã奜ã¿ãŸãã Haskellã§æžãããäŸã次ã«ç€ºããŸãã
fmap :: (a -> b) -> fa -> fb
ããã¯ãæªå®çŸ©ã®ã¿ã€ã
a
ããã³
b
ã§æ©èœããæ±çš
map
ãã¡ã³ã¯ã¿ã®ã·ã°ããã£ã§ããããã¡ã³ã¯ã¿
b
ã®ã³ã³ããã¹ãã§é¢æ°
b
ãã
b
ãé©çšããŠãã¡ã³ã¯ã¿
b
ãäœæããŸãã ããã¡ã³ã¯ã¿ãŒãã¯æ°åŠã®å°éçšèªããã®èšèã§ããããã®æå³ã¯ã衚瀺æäœã®ãµããŒããã«éå®ãããŸãã JavaScriptã®
[].map()
ã¡ãœããã«ç²ŸéããŠããå Žåã¯ããããäœãæå³ãããæ¢ã«ç¥ã£ãŠããŸãã
以äžã«JavaScriptã®äŸãããã€ã瀺ããŸãã
// isEven = Number => Boolean const isEven = n => n % 2 === 0; const nums = [1, 2, 3, 4, 5, 6]; // map `a => b` `a` ( `this`) // `b` // `a` `Number`, `b` `Boolean` const results = nums.map(isEven); console.log(results); // [false, true, false, true, false, true]
.map()
ã¡ãœããã¯ã
b
ãš
b
ãä»»æã®ã¿ã€ãã§ãããšããæå³ã§æ®éçã§ãããé åã¯ãã¡ã³ã¯ã¿ãŒã®ä»£æ°åãå®è£ ããããŒã¿æ§é ã§ããããããã®ã¡ãœããã¯åé¡ãªããã®ç¶æ³ã«å¯ŸåŠããŸãã
.map()
ã®ã¿ã€ãã¯éèŠã§ã¯ãããŸããããã®ã¡ãœããã¯å¯Ÿå¿ããå€ãçŽæ¥åŠçããããšããªãããã§ãã 代ããã«ãã¢ããªã±ãŒã·ã§ã³ã®èŠ³ç¹ããæ£ãã察å¿ããåã®å€ãæåŸ ããŠè¿ãé¢æ°ã䜿çšããŸãã
// matches = a => Boolean // `a` , const matches = control => input => input === control; const strings = ['foo', 'bar', 'baz']; const results = strings.map(matches('bar')); console.log(results); // [false, true, false]
ãŠãããŒãµã«ã¿ã€ãã®é¢ä¿ã¯ãTypeScriptã®ãããªèšèªã§æ£ç¢ºãã€å®å šã«è¡šçŸããã®ãé£ããå ŽåããããŸãããHaskellã§äœ¿çšãããHindley-Milnerã¿ã€ãã·ã¹ãã ã§è¡ãã®ã¯éåžžã«ç°¡åã§ãã
ã»ãšãã©ã®åã·ã¹ãã ã¯ãé¢æ°ã®æ§æããªããžã§ã¯ãã®èªç±ãªæ§æãããã°ã©ã å®è¡äžã®ãªããžã§ã¯ãã®æ¡åŒµãã³ã³ãããŒã¿ãŒãã¬ã³ãºãªã©ã®äœ¿çšãªã©ãåçã§æ©èœçãªã¢ã€ãã¢ã®èªç±ãªè¡šçŸãå¯èœã«ããã»ã©åŒ·åãªå¶éã課ããŸãã èšãæããã°ïŒ éçåã¯ãå€ãã®å Žåããã«ãã¡ãœããã䜿çšãããœãããŠã§ã¢ã®äœæãå°é£ã«ããŸãã
åã·ã¹ãã ã«å¶éãå€ãããå ŽåïŒTypeScriptãJavaãªã©ïŒãããèªç±ãªã¢ãããŒãã§èšèªã䜿çšããå Žåãããåãç®æšãéæããããã«ãããè€éãªã³ãŒããèšè¿°ããå¿ èŠããããŸãã ããã¯ãéçåã®äœ¿çšãäžå¹žãªèãã§ããããšããéçåã®ãã¹ãŠã®å®è£ ã«åãå¶éãããããšãæå³ãããã®ã§ã¯ãããŸããã ããšãã°ãHaskellåã·ã¹ãã ã§ã®äœæ¥ã§çºçããåé¡ã¯ã¯ããã«å°ãªããªã£ãŠããŸãã
ããªããéçã¿ã€ãã®ãã¡ã³ã§ãããå¶éã«å察ããŠããªãå Žåãç§ã¯ããªãã«ããŒã«ã®äžã«7ãã£ãŒããæã¿ãŸãã ããããä»ã®é¢æ°ãšè€å代æ°æ§é ãåæããããšã«ãã£ãŠåŸãããé¢æ°ãå ¥åããã®ã容æã§ã¯ãªããšããäºå®ã®ããã«ãããã§è¡šçŸãããã¢ã€ãã¢ã®ããã€ããå®è£ ããã®ãé£ãããšããã£ãå Žåãã¢ã€ãã¢ã§ã¯ãªãåã·ã¹ãã ãéé£ããŠãã ããã ãã©ã€ããŒã¯ããã¬ãŒã ãã¬ãŒã SUVãæäŸããå¿«é©ãã奜ãããé£è¡ããªããšæå¥ãèšã人ã¯ããªãã é£ã¶ã«ã¯ãããèªç±åºŠã®é«ãä¹ãç©ãå¿ èŠã§ãã
å¶éã«ããã³ãŒããã·ã³ãã«ã«ãªãå Žå-ãã°ãããïŒ ããããå¶çŽãããè€éãªã³ãŒããæžãããšã匷å¶ããå Žåããããããããã®å¶çŽã«äœãåé¡ããããŸãã
ããªããžã§ã¯ãããšã¯äœã§ããïŒ
ããªããžã§ã¯ãããšããèšèã¯ãæéã®çµéãšãšãã«ãæå³ã®å€ãã®äºæ¬¡çãªæå³åããç²åŸããŠããŸãã JavaScriptã§ããªããžã§ã¯ãããšåŒã¶ãã®ã¯ãã¯ã©ã¹ããŒã¹ã®ããã°ã©ãã³ã°ãAlan Kayã®ã¡ãã»ãŒãžããã·ã³ã°ã®ã¢ã€ãã¢ã®ãã³ããäžåæããªãåãªãè€åããŒã¿åã§ãã
JavaScriptã§ã¯ããããã®ãªããžã§ã¯ãã¯ãã«ãã»ã«åãã¡ãã»ãŒãžã®åãæž¡ããã¡ãœããã«ããåäœã®åé¢ãããã«ã¯ãµãã¯ã©ã¹ã䜿çšããããªã¢ãŒãã£ãºã ïŒã¿ã€ãããŒã¹ã®ãã£ã¹ãããã§ã¯ãªãå§ä»»ãã§ãŒã³ã䜿çšïŒããµããŒãã§ããŸãã
Alan Kayã¯ãããã°ã©ã ãšãã®ããŒã¿ã®éããåãé€ããããšèããŠããŸããã JavaScriptã¯ãããŒã¿ãæ ŒçŽããããããã£ãšåãå Žæã«ãªããžã§ã¯ãã¡ãœãããé 眮ããããšã§ãããçšåºŠãã®ç®æšãéæããŸãã ããšãã°ãä»»æã®ããããã£ã«ä»»æã®æ©èœãå²ãåœãŠãããšãã§ããŸãã ãªããžã§ã¯ãã®åäœãåçã«æ§ç¯ããããã°ã©ã ã®å®è¡äžã«ãªããžã§ã¯ãã®ã»ãã³ãã£ãã¯ã³ã³ãã³ããå€æŽã§ããŸãã
ãªããžã§ã¯ãã¯åãªãè€åããŒã¿æ§é ã§ããããªããžã§ã¯ããšèŠãªãããããã«ç¹å¥ãªãã®ã¯å¿ èŠãããŸããã ãã ããé¢æ°ã䜿çšããŠãã³ãŒãããæ©èœãããããã§ã¯ãªãã®ãšåæ§ã«ããªããžã§ã¯ãã䜿çšããããã°ã©ãã³ã°ã§ã¯ããã®ãããªã³ãŒããããªããžã§ã¯ãæåãã§ãããšããäºå®ã«ã¯ã€ãªãããŸããã
OOPã¯å®éã®OOPã§ã¯ãªããªããŸãã
çŸä»£ã®ããã°ã©ãã³ã°èšèªã®ããªããžã§ã¯ããã®æŠå¿µã¯ã¢ã©ã³ã±ã€ãæå³ãããã®ãããã¯ããã«å°ãªãããšãæå³ããããããã®OOPã®ã«ãŒã«ã説æããããã«ããªããžã§ã¯ãããšããèšèã®ä»£ããã«ãã³ã³ããŒãã³ãããšããèšèã䜿çšããŸãã å€ãã®ãªããžã§ã¯ãã¯ããµãŒãããŒãã£ã®JavaScriptã³ãŒãã«ãã£ãŠçŽæ¥ææããã³ç®¡çãããŸãããã³ã³ããŒãã³ãã¯ç¬èªã®ç¶æ ãã«ãã»ã«åããå¶åŸ¡ããå¿ èŠããããŸãã
å®éã®OOPãšã¯æ¬¡ã®ãšããã§ãã
- ã³ã³ããŒãã³ãã䜿çšããããã°ã©ãã³ã°ïŒAlan Kayã¯ããªããžã§ã¯ãããšåŒã³ãŸãïŒã
- ã³ã³ããŒãã³ãã®ç¶æ ãã«ãã»ã«åããå¿ èŠããããŸãã
- ãšã³ãã£ãã£éã®éä¿¡ã«ã¯ãã¡ãã»ãŒãžã³ã°ã䜿çšãããŸãã
- ã³ã³ããŒãã³ãã¯ãå®è¡æã«è¿œå ãå€æŽãããã³çœ®æã§ããŸãã
ã»ãšãã©ã®ãªããžã§ã¯ãã®åäœã¯ã代æ°çããŒã¿æ§é ã䜿çšããŠæ®éçãªæ¹æ³ã§æå®ã§ããŸãã ç¶æ¿ã®å¿ èŠã¯ãããŸããã ã³ã³ããŒãã³ãã¯ãããŒã¿ãå ¬éããã«ããããªãã¯é¢æ°ããã®åäœãåå©çšããã¢ãžã¥ãŒã«ãã€ã³ããŒãã§ããŸãã
JavaScriptã§ãªããžã§ã¯ããæäœããããã¯ã©ã¹ããŒã¹ã®ç¶æ¿ã䜿çšãããããããšã¯ã誰ããOOPããã°ã©ãã³ã°ã«é¢äžããŠãããšããæå³ã§ã¯ãããŸããã ãããããã®ãããªæ¹æ³ã§ã®ã³ã³ããŒãã³ãã®äœ¿çš-ãæå³ããŸãã ããããçšèªã«é¢ãã確ç«ãããã¢ã€ãã¢ãåãé€ãã®ã¯éåžžã«é£ããã®ã§ããããããOOPããšããçšèªãæ®ããŠãäžèšã®ãã³ã³ããŒãã³ããããã¡ãã»ãŒãžæåããã°ã©ãã³ã°ïŒMOPïŒããšããŠäœ¿çšããå¿ èŠããããŸãã ã¡ãã»ãŒãžæåããã°ã©ãã³ã°ã«ã€ããŠã¯ã以äžã®ãMOPããšããçšèªã䜿çšããŸãã
ããŸããŸãè±èªã®åèªãmopãã¯ãmopããšç¿»èš³ãããŠããããåãã®ããã«ãé åºã埩å ããããã«äœ¿çšãããŠããŸãã
è¯ãMOPã¯ã©ã®ããã«èŠããŸããïŒ
ææ°ã®ããã°ã©ã ã®ã»ãšãã©ã«ã¯ããŠãŒã¶ãŒãšã®ããåããæ åœããç¹å®ã®ãŠãŒã¶ãŒã€ã³ã¿ãŒãã§ã€ã¹ïŒãŠãŒã¶ãŒã€ã³ã¿ãŒãã§ã€ã¹ãUIïŒãã¢ããªã±ãŒã·ã§ã³ã®ç¶æ ïŒãŠãŒã¶ãŒããŒã¿ïŒã®ç®¡çã«å¿ããã³ãŒããããã³ã·ã¹ãã ã§åäœããããããã¯ãŒã¯ãšã®ããŒã¿äº€æãæ åœããã³ãŒãããããŸãã
ãããã®åã·ã¹ãã ã®åäœããµããŒãããã«ã¯ãã€ãã³ããªã¹ããŒãªã©ã®é·æéæå¹ãªããã»ã¹ãå¿ èŠã«ãªãå ŽåããããŸãã ããã§ã¯ãã¢ããªã±ãŒã·ã§ã³ã®ç¶æ ãå¿ èŠã«ãªããŸã-ãããã¯ãŒã¯æ¥ç¶ã«é¢ããæ å ±ãã€ã³ã¿ãŒãã§ãŒã¹ã³ã³ãããŒã«ã®ç¶æ ãã¢ããªã±ãŒã·ã§ã³èªäœã«é¢ããæ å ±ãªã©ãä¿åããããã«ã
åªããMOPãšã¯ããã®ãããªãã¹ãŠã®ã·ã¹ãã ãçžäºã®ç¶æ ã«ã¢ã¯ã»ã¹ããŠçŽæ¥å¶åŸ¡ã§ããã®ã§ã¯ãªããã¡ãã»ãŒãžãä»ããŠçžäºäœçšããããšãæå³ããŸãã ãŠãŒã¶ãŒããä¿åããã¿ã³ãã¯ãªãã¯ãããšã
"SAVE"
ã¡ãã»ãŒãžãéä¿¡ã§ããŸãã ç¶æ 管çã¢ããªã±ãŒã·ã§ã³ã³ã³ããŒãã³ãã¯ããã®ã¡ãã»ãŒãžã解éããç¶æ ããã®æŽæ°ãæ åœããããã»ããµïŒçŽç²ãªã¬ãã¥ãŒãµãŒé¢æ°ãªã©ïŒã«ãªãã€ã¬ã¯ãã§ããŸãã ãããããç¶æ ãæŽæ°ããåŸãç¶æ ã®ç®¡çãæ åœããã³ã³ããŒãã³ãã¯ãã¡ãã»ãŒãž
"STATE_UPDATED"
ãŠãŒã¶ãŒã€ã³ã¿ãŒãã§ã€ã¹ã³ã³ããŒãã³ãã«ãã£ã¹ãããããŸã
"STATE_UPDATED"
ãŠãŒã¶ãŒã€ã³ã¿ãŒãã§ã€ã¹ã³ã³ããŒãã³ãã¯ãç¶æ ã解éããã€ã³ã¿ãŒãã§ã€ã¹ã®ã©ã®éšåãæŽæ°ããå¿ èŠããããã決å®ããæŽæ°ãããç¶æ ãæäœãããµãã³ã³ããŒãã³ãã«è»¢éããŸãç¹å®ã®ã€ã³ã¿ãŒãã§ãŒã¹èŠçŽ ã
äžæ¹ããããã¯ãŒã¯æ¥ç¶ãæ åœããã³ã³ããŒãã³ãã¯ããããã¯ãŒã¯äžã®å¥ã®ã³ã³ãã¥ãŒã¿ãŒãžã®ãŠãŒã¶ãŒã®æ¥ç¶ãç£èŠããã¡ãã»ãŒãžããªãã¹ã³ããç¶æ ã®æŽæ°ããããã¥ãŒããã£ã¹ãããããŠãªã¢ãŒããã·ã³ã«ä¿åã§ããŸãã åæ§ã®ã³ã³ããŒãã³ãã¯ããããã¯ãŒã¯ã¡ã«ããºã ã®æäœãæ åœããæ¥ç¶ãæ©èœããŠãããã©ãããèªèããŠããŸãã
åæ§ã®ã¢ããªã±ãŒã·ã§ã³ã·ã¹ãã ã¯ãä»ã®éšåã®è©³çŽ°ãç¥ããªãã¯ãã§ãã 圌ãã¯èªåã®åé¡ã解決ããããšã ãã«æ³šæãæãã¹ãã§ãã ã·ã¹ãã ã³ã³ããŒãã³ãã¯ãã³ã³ã¹ãã©ã¯ã¿ãŒãšããŠå解ããã³ã¢ã»ã³ãã«ã§ããŸãã ãããã¯æšæºåãããã€ã³ã¿ãŒãã§ãŒã¹ãå®è£ ããŸããã€ãŸããçžäºã«ããåãããããšãã§ããŸãã ã³ã³ããŒãã³ãã®ã€ã³ã¿ãŒãã§ãŒã¹ã«é¢ããããç¥ãããèŠä»¶ãæºããããŠããéãããã®ãããªã³ã³ããŒãã³ãã¯åãã€ã³ã¿ãŒãã§ãŒã¹ãæã€ä»ã®ã³ã³ããŒãã³ãã«çœ®ãæããããšãã§ããŸãããåãæ¹æ³ã§å¥ã®æ¹æ³ã§å®è¡ããããåãã¡ãã»ãŒãžãåä¿¡ãããããŸã£ããç°ãªãäœããå®è¡ãããã§ããŸãã ããã°ã©ã ã®å®è¡äžã§ã1ã€ã®ã³ã³ããŒãã³ããå¥ã®ã³ã³ããŒãã³ãã«å€æŽã§ããŸããããã«ããããã®åäœãäžæãããããšã¯ãããŸããã
ãœãããŠã§ã¢ã·ã¹ãã ã®ã³ã³ããŒãã³ãã¯ãåãã³ã³ãã¥ãŒã¿ãŒäžã«ããå¿ èŠãããããŸããã ã·ã¹ãã ã¯åæ£åã§ããŸãã ãããã¯ãŒã¯ã¹ãã¬ãŒãžã¯ã IPFSãªã©ã®åæ£ããŒã¿ã¹ãã¬ãŒãžã·ã¹ãã ã«ããŒã¿ãé 眮ã§ããŸãããã®çµæããŠãŒã¶ãŒã¯ç¹å®ã®ãã·ã³ã®ç¶æ ã«äŸåãããããŒã¿ã®å®å šæ§ã確ä¿ãããŸãã ãã®ã¢ãããŒãã«ãããããŒã¿ã¯ç¢ºå®ã«ä¿åãããäŸµå ¥è ããä¿è·ãããŸãã
PLOã¯ãäžéšãARPANETã®ã¢ã€ãã¢ã®åœ±é¿ãåãããã®ãããžã§ã¯ãã®ç®æšã®1ã€ã¯ãæ žæ»æã®ãããªæ»æã«èããåæ£ãããã¯ãŒã¯ãäœæããããšã§ããã
åªããMOPã·ã¹ãã ã¯ãã¢ããªã±ãŒã·ã§ã³ã®å®è¡äžã«ãããã¹ã¯ããããµããŒãããã³ã³ããŒãã³ãã䜿çšããåæ§ã®ã¬ãã«ã®å®å®æ§ã«ãã£ãŠç¹åŸŽä»ããããŸãã ãŠãŒã¶ãŒãæºåž¯é»è©±ããããã䜿çšãããã³ãã«ã«å ¥ã£ããšããäºå®ã®ããã«ãããã¯ãŒã¯ç¯å²å€ã«ããå Žåãæ©èœãç¶ç¶ã§ããŸãã ããªã±ãŒã³ããµãŒããŒãèšçœ®ãããŠããããŒã¿ã»ã³ã¿ãŒã®ããããã®é»æºãé®æããå Žåããæ©èœãç¶ããŸãã
ãœãããŠã§ã¢ã®äžçãã倱æããã¯ã©ã¹ããŒã¹ã®ç¶æ¿å®éšããèªç±ã«ãªããOOPã®æåç·ã«ãã£ãæ°åŠçããã³ç§åŠçååãæ¡çšããæã§ãã
éçºè ã¯ãMOPãšé¢æ°åããã°ã©ãã³ã°ã®èª¿åã®ãšããçµã¿åããã䜿çšããŠãããæè»ã§å®å®ããçŸããããã°ã©ã ãäœæãããšããæ¥ãŸããã
ãšããã§ããMOPããšããé åèªã¯ãã§ã«äœ¿çšãããŠããããæåããã°ã©ãã³ã°ã®ç£èŠãã説æããŠããŸããããã®æŠå¿µã¯ãOOPãšã¯ç°ãªããéãã«æ¶ããŠããŸããŸãã
ãããã£ãŠããMOPããšããçšèªãããã°ã©ãã®å°éçšèªã®åèªã®ããã«èŠããªãå Žåã¯ãèœèããªãã§ãã ããã äžèšã®MOPååã«åŸã£ãŠãOOPãæŽé ããŠãã ããã