ãšããœãŒã1ïŒå§ãŸãã®é
次ã®ç®æšãèšå®ããŸããã
- Node.JSã§éåžžã®WEBãããžã§ã¯ããéçºããããšãããã«äŸ¿å©ããç解ããŠãã ããã
- Node.JSã§ã®éçºé床ãã䜿çšãããŠããä»ã®ãã¯ãããžãŒïŒç§ã®å Žåã¯PHPããã³JavaïŒãšæ¯èŒããŠãã ããã
- å€æ°ã®åæäŸã§ééããªãèœãšãç©ŽãèŠã€ããŠãã ããã
- å®æãããããžã§ã¯ãã®äœæ¥ãè©äŸ¡ããŸãïŒå®å®æ§ãã¹ãã¬ã¹ãžã®æµæããã®ãããªãããžã§ã¯ãã®ãµããŒããšéçºã®è€éãã
ãã¹ãŠã®ãã¬ãŒã ã¯ãŒã¯ã®ãã¡ãéžæã¯Expressã«å§ããããŸãã ã éå°ãªè² è·ãæãå°ãªãããã«æããŸããããåæã«èŠä»¶ãæãå®å šã«æºããããµãŒãããŒãã£ã®ã¢ãžã¥ãŒã«ã§ç°¡åã«è£ãããšãã§ããŸããã
ãã¬ãŒã ã¯ãŒã¯ãããç§ã¯æ¬¡ã®ãã®ã欲ããã£ãïŒ
- MVCã¢ãŒããã¯ãã£ã
- ã«ãŒãã£ã³ã°
- DBMSã䜿çšããŸãã
- ãã³ãã¬ãŒããšã³ãžã³ã
- å€èšèªäž»çŸ©ã®ãµããŒãã
- ãã«ãã¹ã¬ããã®ãµããŒãã
- æå°éã®ãªãŒããŒãããã
ãšããœãŒã2ïŒThe Way of the Samurai
ãã¹ãäŸã§Expressãå°ã䜿ã£ãŠããã®ã¢ãŒããã¯ãã£ãç解ãããœãŒã¹ã³ãŒããå匷ããã®ã§ãç§ã¯ãã¹ãŠã®ããŒãºãæºãããäžèŠãªæ©èœã§éè² è·ã«ãªããªãç¬èªã®ãã¬ãŒã ã¯ãŒã¯ãäœæããããšã«ããŸããã èªè»¢è»-ããªããèšãã çµéš-ç§ã¯èšããŸãã ã·ã¹ãã ãç解ããæè¯ã®æ¹æ³ã®1ã€ã¯ãèªåã§ã·ã¹ãã ã®é¡äŒŒç©ãéçºããããšã§ãã ãã¬ãŒã ã¯ãŒã¯ã¯éçºããããã°ããããµã€ãã®æåã®ããŒãžã§ã³ã¯ããã«åºã¥ããŠããŸããã ãµã€ããç«ã¡äžãããããããã¢ãããšã©ãŒã®ä¿®æ£ãšæ°ããæ©èœã®è¿œå ãåæã«è¡ããªããããã®åäœã芳å¯ãå§ããŸããã
ãšããœãŒã3ïŒå€§æŽªæ°Ž
åœç¶ãæåã¯ãµã€ãã®èšªåè ãéåžžã«å°ãªããå°ãªããšãäœããã®åœ¢ã§ãã®äœæ¥ã客芳çã«è©äŸ¡ããŠããŸããã ããããæ°æ¥åŸããµã€ããåãã€ããŠããããšãããããŸããã 圌ã¯éãã«åãããã°ã«ã¯çããããã®ã¯äœããããŸããã§ããããåããã®ã¯ãä»ã®èª°ãã®ããããã§ããã ãããã®èŠæ±ã¯è² è·ãšã¯åŒã°ãããå€ãã®ããããã¯ãã®ãããªé床ã§ãµã€ããã¯ããŒã«ããŸããããã®ããã«èœã¡ãã¹ãã§ã¯ãããŸããã ç§ã¯ãã®ãµã€ããåãäžããŠãSiegeãŠãŒãã£ãªãã£ã䜿çšããŠãã¹ãããŸããã ãããŠç¢ºãã«-ãã®ãµã€ãã¯ããå°æ°ã®äžŠåãªã¯ãšã¹ãã§ããåãã€ããŸããããããã¯ç§ã®æåŸ ãå®å šã«ã¯æºãããŠããŸããã§ããã ãã°ã¯é»ã£ãŠããŸããã æ²ãã¿ã¯æé·ããŸããã çºæãå§ãŸããŸããã
ãšããœãŒã4ïŒæåã®ç³
å®éšãç¹°ãè¿ããŠããµãŒããŒã§äœãèµ·ãã£ãŠããããç£èŠããåé¡ãçºèŠããŸãããããŒãããã»ã¹ã䜿çšå¯èœãªã¡ã¢ãªããã¹ãŠäœ¿ãæãããåæãŸãã¯ãã³ã°ã¢ããããŸããïŒhttpèŠæ±ã®åãå ¥ããåæ¢ããŸããïŒã ç§ã¯ãéçºäžã«ã¡ã¢ãªæ¶è²»ãç£èŠããããšããäºçŽãäœæããŸãã ããã¯ãé·æéå®è¡ãããã¢ããªã±ãŒã·ã§ã³ã§æãå±éºãªç¬éã®1ã€ã§ãã ç§ã¯äœåãªã¯ããŒãžã£ãŒãããŸããã§ãããvarã¯è² ããŸããã§ãããäžè¬çã«ç§ã¯ãã¡ããšè¡åããŸããã ããäžåºŠãã³ãŒãã䞊ã¹æ¿ããŠããšã©ãŒããã®äžã«ãªãããšã確èªããççŽã«èšã£ãŠåæºããŸããã ããã§ä¿®æ£ããã®ãæãç°¡åã§ãã Node.JSã®ãããã¬ãŒã¯ååšããŸãã ãéåžžã«äŸ¿å©ã§ãããéåææäœã®ããNode.JSã¢ããªã±ãŒã·ã§ã³ã®ãããã°ã¯ããå°é£ã§ãã ãã®ãã°ãããããŒã«ã䜿çšããŠã¬ãã«80ã«éããããã§ã¯ãªãããªãŒã¯ãèšç®ã§ããªãã£ãããšãåçœããŸãã ããã§ç§ã®äŒæã¯çµãã£ãã Node.JSã®ãã¯ãŒãç¿åŸããæéã¯ãã£ãšçããªããç§ã¯ãã®åé¡ãããè¯ãæéãŸã§å»¶æããããšã«ããŸããã çµæã«æºè¶³ãããæ¯æ¥ããã»ã¹ãåèµ·åããå°ããªãŠãŒãã£ãªãã£ãäœæããŸããã ãã®ãããªæŸèæã§ã¯ããµã€ãã¯4ã5ãæåããŸããã äžæ¹ãNode.JSã®éçºã¯æ¢ãŸããŸããã§ããã æ°ããããŒãžã§ã³ã次ã ãšç»å ŽãããµãŒãããŒãã£ã®ã¢ãžã¥ãŒã«ãéçºãããå°å æã®ç æ°ããªããªããŸããã
ãšããœãŒã5ïŒæ°ããåžæ
ãããŠä»ãããªãé·ãäŒæ©ã®åŸã Node.JSã®å€æŽãã°ã«ãä¿®æ£ãããã¡ã¢ãªãªãŒã¯ïŒããŒãžã§ã³0.6.6-0.6.7ïŒã«é¢ãããšã³ããªããããŸããã ãŸããããŒãžã§ã³0.6.0以éã ã¯ã©ã¹ã¿ãŒAPIãå®å®çãªãªãŒã¹ã«å«ãŸããäžèŠãªãã³ã¹ãæé€ããŠããã€ãã®ããŒãããã»ã¹ãéå§ã§ããããã«ãªããŸããã ããã¯ãã¹ãŠç±æãè¿œå ãããããžã§ã¯ããæ°ããè§åºŠããèŠãããŸããã ãã®æç¹ã§ããã¬ãŒã ã¯ãŒã¯ã®ã©ã®éšåã䜿çšãããŠããªãããããã«äœãæ¬ ããŠãããããããŠäŸ¿å©ã§ã¯ãªãããšããã§ã«èŠãŠããŸãã ããã«ãMySQLïŒå ã 䜿çšãããŠããïŒãMongoDBã«çœ®ãæããããšã«ããŸããã
åã³äººæ°ã®ãããã¬ãŒã ã¯ãŒã¯ãåæãããšããããã¯ãã¹ãŠãæŠããŠããç¬èªã«ãããŸããŸãªã¢ãžã¥ãŒã«ã®ã¢ã»ã³ããªãšå°ããªæ¹è¯ã§ãããã¢ããªã±ãŒã·ã§ã³ãæ§ç¯ããããã®ç¬èªã®ã«ãŒã«ãèŠå®ããŠããããšã«æ°ä»ããŸããã ããããã¹ãŠããçãããè³éã䌎ãã¿ã€ããªãã¬ãŒã ã¯ãŒã¯ã«æŒã蟌ãŸããŸãã åå¥ã®ã¢ãžã¥ãŒã«ãæŽæ°ããå¿ èŠãããããã¬ãŒã ã¯ãŒã¯ããããšç«¶åããå Žåãéçºè ã«ãã£ãŠæŽæ°ãããããŒãžã§ã³ãè¿œå ãããã®ãåŸ ã€å¿ èŠããããŸãã ãŸãã¯ããã®ãã¬ãŒã ã¯ãŒã¯ããµããŒãããŠããªãã¢ãžã¥ãŒã«ãããšãã°ããæ°ã«å ¥ãã®ãã³ãã¬ãŒããšã³ãžã³ã䜿çšããå Žåã ã©ããã ãµããŒããåå²ããŠè¿œå ãããã¬ãŒã ã¯ãŒã¯éçºè ããã«ãªã¯ãšã¹ããåãå ¥ããã®ãåŸ ã£ãŠããéã«æŽæ°ãæåã§ããŒãžããŸããïŒ ããïŒ
ã¢ãžã¥ã©ãŒã·ã¹ãã Node.JSã§ã¯ããã¬ãŒã ã¯ãŒã¯ïŒèªã¿åã-æ¢è£œã®ã¢ãžã¥ãŒã«ã¢ã»ã³ããªïŒã䜿çšããã®ã§ã¯ãªããã¢ãžã¥ãŒã«ãçŽæ¥æäœã§ããŸãã åæã«ããã¬ãŒã ã¯ãŒã¯ã§ã©ããããã®ã§ã¯ãªããè¿œå ã®æ©èœãå¥ã®ã¢ãžã¥ãŒã«ã§äœ¿çšããå¿ èŠããããŸãã ãã®ã¢ãããŒãã«ãããã·ã¹ãã ã®æè»æ§ãå€§å¹ ã«åäžããã³ãŒãã®åå©çšãåäžããŸãã
ããã§ããããžã§ã¯ãã®ãªãã¡ã¯ã¿ãªã³ã°èšç»ãåŸãŸããã 次ã®é ç®ã§æ§æãããŠããŸããã
- ãã¬ãŒã ã¯ãŒã¯ã®äœ¿çšãæåŠããã¢ãžã¥ãŒã«ã®çŽæ¥äœ¿çšã«åãæ¿ããŸãã
- ç§ã®åé¡ã解決ããã®ã«æé©ãªèšå€§ãªæ°ã®ã¢ãžã¥ãŒã«ããéžæããŠãã ããã
- MySQLãMongoDBã«çœ®ãæããŸãã
- ããã€ãã®ããã»ã¹ã®èµ·åãæŽçããããã«ãããŒã䜿çšïŒçŸåšã¯ãã€ãã£ãïŒ ã¯ã©ã¹ã¿ãŒAPI ã
ãšããœãŒã6ïŒãšããã¯ã¯ã€ã³
ãhabraeffectãã巚倧ã ã£ããšã¯èšããŸããã ãããæ°å人ãæ¥ãŸããã æ°æéåŸããµã€ããã¯ã©ãã·ã¥ããŸããããè² è·ã®ããã§ã¯ãªããç§ã®ãã¹ãåå ã§ããã ã¯ããã¯ããå±ãã«ããå Žæã§ãå€æ°åã«ã¿ã€ããã¹ãããŸãããããã倱æã®çç±ã§ããã ãã以å€ã®å Žåãåé¡ã¯çºçããŸããã§ããã ããŒãžã¯éåžžã«è¿ éã«äžããããããã»ããµã¯è² æ ãããããã¡ã¢ãªã¯æµããŸããã§ããã 1é±éãããŒããåèµ·åããŠããªãããããµã€ãã¯åŒãç¶ãå®å®ããŠåäœããŸãã ãã®ãããªçµæã¯ã以åã®æ²ããçµéšã®åŸãéåžžã«æ¥œããã§ãã
çµè«
JavaScriptã®ããã ãã«JavaScriptãæžãããšã¯ã§ããŸããã ãã£ããã/æ°ãã/人æ°ã®ããèšèªïŒé©åãªäžç·ïŒãéžæããã®ã¯ã°ãããŠããŸãã ç§ãã¡ã¯ããã¯ãããžãŒããäœãæã¿ããããç§ãã¡ã«äœãäžããããšãã§ãããããããŠãããèŠè¿ãã«äœãæ±ããã®ããæ確ã«ç解ããå¿ èŠããããŸãã ç§ã®äž»ãªä»äºã¯ãããããã¹ãŠã®ãWhatsããç¹å®ãããNode.JSã¯å¹³åçãªWebãããžã§ã¯ãã®éçºã«é©ããŠããŸããããšãã質åã«å¯ŸããçããåŸãããšã§ããã ç§ã®çãã¯ã€ãšã¹ã§ããããã§ãã ããããä»ã®æè¡ãšåæ§ã«ãçŽé¢ããªããã°ãªããªãå°é£ããããŸãã å€åããã€ãã¹ããå§ããŠãè¯å®çãªã¡ã¢ã§çµãããŸãã
ãã¥ãŒã¹ãã³ãåé¡ããããŸã
-1
Node.JSã§éçºããéã«æåã«ééããããšã¯ãããã«äœ¿çšã§ããæ¬æ ŒçãªIDEããªãããšã§ãã ãã¡ãããEclipseããã³NetBeansçšã®ãã©ã°ã€ã³ããããä»ã®IDEã§ãéšåçã«ãµããŒããããŠããŸãã ããããçŸæç¹ã§ã¯å®å šãªãœãªã¥ãŒã·ã§ã³ãšåŒã¶ããšã¯äžå¯èœã§ãã Cloud9 IDEã®éåžžã«ææãªéçºããããŸãã ãã©ãŠã¶ã§JavaScriptãçŽæ¥éçºããããã®IDEã§ãã ãã®IDEã¯æ¥éã«éçºãããŠããããã§ã«å€ãã®Node.JSéçºè ã«ãã£ãŠç©æ¥µçã«äœ¿çšãããŠããŸãããåæã«ãç§ã®äž»èŠ³çãªæèŠã§ã¯ãå°ããªã¢ãžã¥ãŒã«ãäœæããã®ã«éåžžã«äŸ¿å©ã§ããã倧èŠæš¡ãªãããžã§ã¯ãã§äœæ¥ããæºåããŸã æŽã£ãŠããŸããã ãããžã§ã¯ãã®äœæ¥äžã«ãè€æ°ã®IDEãå€æŽããŸããã ç§ã¯ã¡ã¢åž³++ããå§ããCloud9 IDEãé·ãé䜿çšããä»ã®äººãè©ŠããŸãããããã®ååã¯ããèŠããŠããŸããããæçµçã«ã¯NetBeansã«æ»ããŸããã Node.JS APIã®ãµããŒãã¯ãããŸããããçŽç²ãªJavaScriptã䜿çšãããšäŸ¿å©ã§ãã ãŸã åŸ ã£ãŠãããå®å šãªãµããŒãã®åºçŸãæåŸ ããŠããŸãã ãã®ãããªãã©ã°ã€ã³ã®éçºã¯ãã§ã«é²è¡äžã§ãã
-2
2çªç®ã®äžå¿«ãªç¬éã¯ãåå€æŽãè¡ã£ãåŸã«ã¢ããªã±ãŒã·ã§ã³ãåèµ·åããå¿ èŠãããããšã§ãã ãã®ããã»ã¹ãèªååãããŠãŒãã£ãªãã£ãååšããŸããããããè¡ãã«ã¯ãŸã æéãããããŸãã PHPã®å Žåãšåæ§ã«ãå€æŽãå ããŠããã«çµæã確èªããããšã¯ã§ããŸããã ãã ããã¢ããªã±ãŒã·ã§ã³ã¯éåžžã«è¿ éã«åèµ·åããŸã-䜿çšããã¢ãžã¥ãŒã«ã«å¿ããŠã1ãæ°ç§ã§ãã Node.JSã¯ééããªãJavaã®ããã©ãŒãã³ã¹ãäžåã£ãŠããŸããæ·±å»ãªWEBã¢ããªã±ãŒã·ã§ã³ã®åèµ·åã«ã¯ããªãé·ãæéãããããŸãã
-3
åå¿è ã®Node.JSéçºè ãçŽé¢ãã次ã®åé¡ã¯ãããããã¡ã¢ãªãªãŒã¯ã§ãã ã¡ã¢ãªã¯åžžã«ã©ãã§ãç£èŠããå¿ èŠããããŸãããé«éã§åäœããPHPã¹ã¯ãªãããŸãã¯å°ããªã¯ã©ã€ã¢ã³ãåŽã®JavaScriptã¯éåžžã«ãªã©ãã¯ã¹ã§ããŸãã ãã®ãããªã¢ããªã±ãŒã·ã§ã³ã§ã¯ãå€ãã®éçºè ã¯æ°ãããã€ãã®ã¡ã¢ãªã®æ倱ãç¹ã«è©äŸ¡ãããäžéšã®éçºè ã¯ãã®ã€ã³ãžã±ãŒã¿ããŸã£ããç£èŠããŸããã Node.JSã¯ãã®ãããªè²æ©ãè¡ããŸããã Node.JSã®ã¢ããªã±ãŒã·ã§ã³ã¯é·æéåäœãããªãŒã¯ãçºçããå Žåããµã€ããžã®åãªã¯ãšã¹ãã«ãããéåžžã«è¿ éã«çµäºããã¡ã¢ãªã®äžéšãåé€ãããæ¢ç¥ã®çµæã«ã€ãªãããŸãã JavaScriptã®ç¹ç°æ§ã¯ããã®ã¿ã€ãã®ãšã©ãŒãä¿é²ããŸãã 倧ããªã¹ã³ãŒãã§ã®1ã€ã®äœåãªç絡ãŸãã¯1ã€ã®varã®æ倱ã«ãããå¿ããããªãæéã®ãããã°ãå¯èœã«ãªããŸãã ããããããã«ã¯ãã©ã¹ããããŸã-ãã®ãããªçµéšã¯ãä»ã®èšèªã§ããã°ã©ãã³ã°ãããšãã«ãéçºè ãã¡ã¢ãªãè©äŸ¡ãããã®äœ¿çšãå¶åŸ¡ããããã«ããŸãã å人çã«ã¯ããã®æ©èœããã€ãã¹ãšã¯èããŠããŸããã
-4
äžéœåãªãã1ã€ã®æ©èœã¯ãéåæã³ãŒãããã®ãšã©ãŒæ»ãã§ãã æ¯èŒã®ããã«ãPHPã§ã¯ããã¹ãŠã®ã³ãŒããåæçã«å®è¡ããããããtry-catchã³ã³ã¹ãã©ã¯ãã䜿çšããŠãä»»æã®ãã¹ãã¬ãã«ã§ãšã©ãŒããã£ããã§ããŸãã ã³ã³ãããŒã©ãŒã®äœæ¥ãã©ããããããšãã§ããŸããäŸå€çãªç¶æ³ã®å Žåã¯ãæãããšãšã©ãŒãããããã¢ããããããŠããããåŸ ã£ãŠãããã³ãã©ãŒã«è¡šç€ºããããŠãŒã¶ãŒã«çŸããæ¥ã®ããŒãžã衚瀺ãããŸãã JavaScriptã«ã¯try-catchã³ã³ã¹ãã©ã¯ãããããšããäºå®ã«ãããããããããã¯ç§ãã¡ãå©ããŸããã ã»ãšãã©ã®ã³ãŒãã¯éåæã«åäœããŸãïŒI / OïŒã ãã®å ŽåãååãšããŠãã¡ãœãããåŒã³åºããããšãã«äŸå€çãªç¶æ³ã¯çºçããŸããããã³ãŒã«ããã¯ãæ©èœãããšãã¯ããã§ã«try-catchã³ã³ã¹ãã©ã¯ãã®å€éšã§å®è¡ãããŠããŸãã ãšã©ãŒæ å ±ãNode.JSã«æž¡ãã«ã¯ãéåžžãã³ãŒã«ããã¯é¢æ°ã®æåã®ãã©ã¡ãŒã¿ãŒã䜿çšããŸãã ã€ãŸã ãšã©ãŒãçºçããå Žåãã³ãŒã«ããã¯é¢æ°ãããããèšè¿°ãã1ã€ã®ãã©ã¡ãŒã¿ãŒã§åŒã³åºãããæåã®ãã©ã¡ãŒã¿ãŒãundefined / nullã«èšå®ãã次ã«æ©èœã®çµæãæž¡ããŸãã å®éã®ã¢ããªã±ãŒã·ã§ã³ã§ã¯ãåŒã³åºãã®ãã¹ãã¯éåžžã«å€§ãããªãå¯èœæ§ããããæ¯åãšã©ãŒãæž¡ãã®ã¯éåžžã«äžäŸ¿ã§ãã AOPãé©çšããããšã§åé¡ã¯è§£æ±ºã§ãããšæããŸããããã®ãããã¯ã¯ãã®èšäºã®ç¯å²å€ã§ãã
-5
éåžžã«é »ç¹ã«å®çšŒåãµãŒããŒã«å°éããæãåçŽãªãšã©ãŒããããªããç·åŒµãããŸãã cluser apiã䜿çšãããŠããå Žåãéåžžã«ãŸãã«å®è¡ãããã³ãŒããããã¯å ã®å€æ°åã®ã¿ã€ããã¹ã«ããããµã€ãå šäœãŸãã¯ããã»ã¹ã®1ã€ãã·ã£ããããŠã³ãããå¯èœæ§ããããŸãã ãã®ãããªãã©ãã«ãåé¿ããã«ã¯ãã¢ããªã±ãŒã·ã§ã³ãç£èŠããå¿ èŠã«å¿ããŠåèµ·åãããŠãŒãã£ãªãã£ã䜿çšã§ããŸãããå®éã®å¿è ã¯ã³ãŒããé©åã«ãã¹ãããŸãïŒãµãŒãããŒãã£ã®ã¢ãžã¥ãŒã«ã®ãšã©ãŒã«å¯ŸããŠèª°ãå®å šã§ã¯ãããŸããïŒã
-6
æåŸã«è¿œå ãããã®ã¯ãè€éãªæ°åŠçèšç®ã¯Node.JSçšã§ã¯ãªããšããããšã§ãã ãã®ãããã¯ã«ã€ããŠã¯ãããã«ã¯æ¢ã«éåžžã«çãããããªãããã¯ããããããã«æžãããŠãããã¹ãŠãç¹°ãè¿ãããšã¯æå³ããªããç§ã¯ããã«ã€ããŠã®ã³ã¡ã³ããèŠãŠããŸããã ãããã¯ã®äœæè ïŒãã¡ããã翻蚳ã§ã¯ãªãåäœè ã®äœæè ïŒãæè¡ã®éžæã«åé¡ããããããããåãªããããŒã«ã§ãããšããèšããŸããã Node.JSã§ã¯ãã€ãã³ãã«ãŒãã®æ°ã¿ãŒã³ã«ããã£ãŠå®è¡ãããçãå埩ã«ã¿ã¹ã¯ãåå²ããããšã«ãããè€éãªæ°åŠèšç®ãå®è¡ããããšã¯å¯èœã§ãããããã¯ãã§ã«åé¯ãšçä¿¡ã§ãã ãã®ãããªã¿ã¹ã¯ãã€ãã³ãã«ãŒãã®ç¯å²ããå€ããããéçºçšã«å¥ã®ãã¯ãããžãŒãéžæãããããããšãã¯ããã«ç°¡åã§ãã
ããã¯äœã®ããã§ããïŒ
ãã®æç¹ãŸã§ã«ãã®ãããªè³ªåããªãã£ãå Žåã¯ãçµéšè±å¯ãªJavaScriptéçºè ããæ€çŽ¢ããããããChuck NorrisïŒhello ChuckïŒïŒã®ã©ã¡ããã§ãã ä»ã®ãã¹ãŠã®äººã®ããã«ãNode.JSã§ã®WEBãããžã§ã¯ãã®éçºãããããã¡ãªããã説æããããšããŸãã
+1
Node.JSã®æãéèŠãªå©ç¹ã¯ãéåæã®å ¥åºåãšãããã䜿çšããäœæ¥ã®éææ§ã§ãã ã»ãšãã©ã®WEBãããžã§ã¯ãã§ã¯ãæãäžè¬çãªæäœã¯ããŒã¿ããŒã¹ããã®ããŒã¿ã®èªã¿åããšä¿åã§ãã éåžžãåãæäœãæãé ããªããŸãã ããããåžžã«é ãé¢ããŠããããã¯ãäºãã«äŸåããŠãããå察ã«ãã»ãšãã©ã®å Žåããããã¯ã¢ãããã¯ã§ãã ããšãã°ãèšäºã«æ°ããã³ã¡ã³ããè¿œå ããå Žåã次ãå¿ èŠã§ãã
- ã³ã¡ã³ãèªäœãä¿åããŸãã
- ãŠãŒã¶ãŒãæŽæ°ããŸãïŒããšãã°ããŠãŒã¶ãŒã®ã³ã¡ã³ãæ°ãšæåŸã®ã³ã¡ã³ãã®æ¥ä»ïŒã
- èšäºãæŽæ°ããŸãïŒãŠãŒã¶ãŒã®æŽæ°ãšåæ§ïŒã
- ã¯ãšãªçµæãèšé²ããŸãã
ãããã®æäœã¯ãã¹ãŠäºãã«ç¬ç«ããŠãããDBMSã¯ããããåæã«å®è¡ã§ããŸãã ããšãã°PHPã§åæçã«å®è¡ãããå Žåããããã®æäœã¯ãåã®æäœãå®äºããã®ãåŸ ã€ãã³ã«é çªã«å®è¡ãããŸãã Node.JSã§ã¯ãããã4ã€ã®ãªã¯ãšã¹ããã¹ãŠãDBMSã«ã䞊è¡ããŠãéä¿¡ããæ©äŒããããŸãã å®éããªã¯ãšã¹ãã¯åŒãç¶ãã·ãŒã±ã³ã·ã£ã«ã«éä¿¡ãããŸãïŒãã®ãããåŒçšç¬Šã§ã䞊åã«ããšããèšèãåŒçšããŸããïŒã Node.JSã¯1ã€ã®ããã»ã¹ã§åäœããŸãã ãã ããNode.JSã¯ãåã®ãªã¯ãšã¹ãã®çµæã次ã®ãªã¯ãšã¹ããéä¿¡ããã®ãåŸ ã¡ãŸããã æäœã®æéãšæ¯èŒããŠãèŠæ±ãéä¿¡ããæéã¯ç¡èŠã§ããŸãã èŠæ±ãå®è¡ããããšãã³ãŒã«ããã¯é¢æ°ãåŒã³åºãããŠçµæãåŠçãããŸãã ãããã®åŒã³åºãã¯ããªã¯ãšã¹ãã®éä¿¡ãšåæ§ã«é 次çºçãããã®çµæã¯å®è¡æéãããæ¯èŒã«ãªããªãã»ã©é«éã«åŠçãããŸãã ãããã£ãŠãããŒã¿ã䜿çšããåèšäœæ¥æéã¯ãæé·ã®ãªã¯ãšã¹ãã®äœæ¥æé+ãªã¯ãšã¹ããéä¿¡ããŠçµæãåŠçããããã®å°ããªãªãŒããŒãããã«ã»ãŒçãããªããŸãã ãã ãããããã®å Žåããã·ãŒã±ã³ã·ã£ã«åŠçäžã®ãã¹ãŠã®ãªã¯ãšã¹ãã®å®è¡æéã®åèšãããé«éã«ãªããŸãïŒãã®å Žåããªã¯ãšã¹ããéä¿¡ããŠçµæãåŠçããããã®ãªãŒããŒããããçºçããŸããïŒã
+2
2çªç®ã®éåžžã«æ¥œããæ©äŒã¯ãèŠæ±ããžãã¯å šäœã®å®äºãåŸ ããã«ãæºåãã§ã次第ãã¯ã©ã€ã¢ã³ããžã®å¿çãéä¿¡ã§ããããšã§ãã åã®äŸã«æ»ããŸãããã ã³ã¡ã³ããè¿œå ãããšããããŒã¿ããŒã¹ã«ãã°ãæžã蟌ã¿ãŸãã ãã®æäœã¯å¿ èŠã§ããããŠãŒã¶ãŒã¯å¿çãåãåãããã«ãã®æäœãå¿ èŠãšããŸããã Node.JSã䜿çšãããšãåçãçæããŠéä¿¡ããå¿ èŠãªãã®ïŒãã°ã®æžã蟌ã¿ããã£ãã·ã¥ã®ã¯ãªã¢ãªã©ïŒãå®äºã§ããŸãã ãŠãŒã¶ãŒã®ã¬ã€ãã³ã·ãŒã¯ããã«å¿ããŠæžå°ããŸãã
+3
3çªç®ã®ãã©ã¹èŠå ã¯ããµãŒããŒãšã¯ã©ã€ã¢ã³ãã§åãèšèªã䜿çšããŠããããšã§ããããã«ãããäžéšã®ã³ãŒããåå©çšã§ããŸãïŒãã©ãŒã æ€èšŒãã¯ã©ã€ã¢ã³ãã§ã®ãã³ãã¬ãŒãã®äœæãªã©ïŒã ãããŠäžè¬ã«ãç¹ã«ã¢ããªã±ãŒã·ã§ã³ã®ã¯ã©ã€ã¢ã³ãéšåãè€éã§ããã¿ã³äžã®ããã€ãã®ã€ãã³ããåŠçããã®ã§ã¯ãªããæ·±å»ãªäœæ¥ãå¿ èŠãšããå Žåãéçºãå€§å¹ ã«ç°¡çŽ åããŸãã
+4
Node.JSããã»ã¹ã¯é·æéåç¶ãããã¹ãŠã®httpèŠæ±ãå éšçã«åŠçããŸãã ããã¯ãããšãã°PHPã®ããã«ãæ°ãããªã¯ãšã¹ãããšã«åæåãå®è¡ãããªãããšãæå³ããŸãã èšå®ãèªã¿èŸŒãŸããããŒã¿ããŒã¹ãšãã£ãã·ã¥ãžã®æ¥ç¶ãéãããã³ãŒããã³ã³ãã€ã«ãããŠæºåå®äºã§ãã ãã®ã¢ãŒããã¯ãã£ãšæè»æ§ã®ãããã§ãJavaScriptã¯ããŸããŸãªæé©åææ³ã®å€§ããªç¯å²ãæäŸããŸãã ããšãã°ããã³ãã¬ãŒãã調ã¹ãããå ¥åãåãåããããã«äœ¿ããHTMLãè¿ãé¢æ°ã®åœ¢åŒã§ä¿åã§ããŸãã ãŸãã¯ãæãé »ç¹ã«äœ¿çšãããããŒã¿ã®ããŒã«ã«ïŒããã»ã¹çšïŒãã£ãã·ã¥ãç°¡åã«æŽçã§ããŸããããã«ãããmemcachedãšæ¯èŒããŠããããŒã¿ã®æäœé床ãåäžããŸãã ã¯ããPHPã«ã¯ãåæåããã»ã¹ãéšåçã«å éãããœãªã¥ãŒã·ã§ã³ããããŸã-op-codeã®APCãFastCGIã§ã®æç¶çæ¥ç¶ã®ãµããŒããªã©ã ããããå éãããåæåããã»ã¹ãååãšããŠãã®äžåšãšæ¯èŒããå Žåãã²ã€ã³ã¯åžžã«åŸè ã«ãªããŸãã
+5
Node.JSã®åšèŸºã§ã¯ããã®æ¯èŒççã寿åœã®ããã«ãæ°çŸã®ã¢ãžã¥ãŒã«ãšããã«å¿ããŠéçºè ãå«ã匷åºãªãšã³ã·ã¹ãã ãæ¢ã«åœ¢æãããŠããŸãã äž»ã«githubã®å©äŸ¿æ§ã«ãããã³ãã¥ããã£ã¯ãã®ãšã³ã·ã¹ãã ã®éçºã«åªããããŒã«ãåããŠãããããã¯å€§ããªé²æ©ãéããŠããã誰ã§ããã®éçºã«è²¢ç®ã§ããŸãã Node Toolboxãnpmãªã©ã®ããŒã«ã䜿çšãããšãå¿ èŠãªã¢ãžã¥ãŒã«ãèŠã€ããŠéžæããã€ã³ã¹ããŒã«ããããã»ã¹ãè¿ éãã€ç°¡åã«ãªããŸãã
+6
JavaScriptèšèªèªäœãšNode.JS APIã¯éåžžã«æè»ã§ç°¡æœã§ãã ããã°ã©ã ã¯ã³ã³ãã¯ãã§èªã¿ãããã§ãã ã»ãŒå®å šã«ã²ãã¿ãŒãšã»ãã¿ãŒããŸãã¯ã€ã³ã¿ãŒãã§ã€ã¹ã®èª¬æãå«ãæ°åã®ãã¡ã€ã«ã§æ§æãããã¯ã©ã¹ã衚瀺ãããããšã¯ã»ãšãã©ãããŸããã ã¯ããŒãžã£ãŒãã©ã ãé¢æ°ã®ãããªãã®ã䜿çšãããšãéåžžã«çŸããã³ãŒããæžãããšãã§ããŸãããéçºè ã®ç¹å¥ãªæèœãããã°ããããå°çã®æã«å€ããããšãã§ããŸãã
JavaãšNode.JSã®ããã©ãŒãã³ã¹ã®æ¯èŒãèŠãåŸãç§ã¯é·ãéç¬ããŸããã ããã§ã¯ãããŸããŸãªè°è«ãè°è«ãé·ãéè¡ãããšãã§ããŸãããç§ãæãã«åçŽã«èšããŸãã ã€ãã³ãã«ãŒãã§ãåæã«ããã°ã©ã ã³ãŒããæ°ååã«ãªã£ãå Žåããã®ããã©ãŒãã³ã¹ãã²ãããŸããã Java + Spring Framework + Hibernateã§å€§èŠæš¡ãªWEBãããžã§ã¯ããéçºããçµéšããããŸãã 11è¡ç®ãäœãããããããŸã説æãã10è¡ã®ã³ãŒãããããŸãã ãã¡ãã倱瀌ã§ãããããããã®ç¶æ³ãåæ ããŠããŸãã ããããããã€ãã®ã¯ã©ã¹ã®ã¿ã¹ã¯ã§ã¯ããã¯é¢é£ããŸãããå¹³åçãªWEBãããžã§ã¯ãã«ã¯é¢é£ããŸããã ãHello worldãã«é¢ãããã®ãããªæ¯èŒã¯ãå®éã®ç¶æ³ãåæ ããŠããªãããšãä»ãå ãã䟡å€ããããŸãã ããŒã¿ããŒã¹ããã£ãã·ã³ã°ãããã³ã·ã¹ãã ã®ä»ã®ã³ã³ããŒãã³ããšé£æºããã¢ããªã±ãŒã·ã§ã³ããžãã¯ã®åºçŸã«ããããã¯ãããžãŒã®äžå®å šãããããã¯ãããžãŒã®æé©ã§ãªã䜿çšã«ããããã¬ãŒãããã£ããããå¯èœæ§ãéåžžã«é«ããªããŸãã ããã«ã次ã®2ã€ã®å Žåã«ã¯ãµãŒããŒãªãœãŒã¹ãååã§ãªãå¯èœæ§ãããããšã«æ³šæããå¿ èŠããããŸãã
- ã³ãŒãã¯äžå®å šã«æžãããŠããŸãã
- ãµã€ãã®ãã©ãã£ãã¯ã¯èšå€§ã§ãã
ãããã«
Node.JSã¯éæ³ã®æã§ã¯ãããŸããã ããã¯é·æãšçæãåãã匷åãªããŒã«ã§ãããå¿ èŠãªå Žåã«ã®ã¿äœ¿çšããŠãã ããã å®éšã®çµæã«æºè¶³ããŠããŸãã ãããžã§ã¯ãã¯é«éã§ãéçºãšä¿å®ãç°¡åãªã·ã³ãã«ã§æ確ãªã³ãŒããæã£ãŠããŸãã ããã€ãã®æ¬ ç¹ã¯ãããŸãããNode.JSã¯WEBãããžã§ã¯ãã®éçºã«äŸ¿å©ã§ããããã®æ¹åã§ã®éçºãä¿¡ããŠããŸãã
ç¶ã
第2éšã§ã¯ãã¢ããªã±ãŒã·ã§ã³ã¢ãŒããã¯ãã£ã«ããã«è©³ããçŠç¹ãåœãŠãŸãã 䜿çšããã¢ãžã¥ãŒã«ãšããããã®éã®çžäºäœçšãã©ã®ããã«æ§æãããŠãããã説æããŸãã
ãããèªãã ãã¹ãŠã®äººã«æè¬ããŸãã ã³ã¡ã³ãã«ãæèŠããæèŠããåŸ ã¡ããŠãããŸãã