1. F#ã®æŠèŠãšç¹åŸŽ
F#ïŒãšãã·ã£ãŒãïŒã¯Microsoftãéçºããäžçš®ã®é¢æ°åããã°ã©ãã³ã°èšèªã§ããæ§ã ãªãã©ãã€ã ã楜ã«æ±ãããã«ããã©ãã€ã èšèªãšããŠãèªèãããŠããŸãã
ãã®äž»ãªç¹åŸŽãšããŠãF#ã¯åŒ·åãªåæšè«ã·ã¹ãã ãšREPLãµããŒããæããŠããŸããããã«ããããã°ã©ã ã®ãè©Šãå®è¡ããããã°äœæ¥ãããçšäŸ¿æ§è¯ãè¡ãããšãã§ããŸãã
äžæ¹ã§ãF#ã®æ¬ ç¹ãšããŠã¯ãéçºè ã®ã³ãã¥ããã£ãæ¯èŒçå°ãããã¢ãã€ã«ã¢ããªã±ãŒã·ã§ã³åãã®ã©ã€ãã©ãªããã¬ãŒã ã¯ãŒã¯ããŸã å å®ããŠããªãããšãæããããŸãã
1.1 F#ãšã¯äœã
F#ã¯ããã©ãã€ã ããã©ãããã©ãŒã ã«ãŸãããæ±çšæ§ã®é«ãããã°ã©ãã³ã°èšèªã§ãããããã¯ãé¢æ°åããã°ã©ãã³ã°ã ãã§ãªãããªããžã§ã¯ãæåããã°ã©ãã³ã°ãæç¶ãåããã°ã©ãã³ã°ãéåæããã°ã©ãã³ã°ãªã©ã«ã察å¿ããŠããŸãã
ãŸãããã€ã¯ããœãããéçºãã.NETãã¬ãŒã ã¯ãŒã¯ã«åºã¥ããŠäœãããããã°ã©ãã³ã°èšèªã§ãããWindowsã ãã§ãªããLinuxãmacOSã§ãå©çšããããšãã§ããŸãã
F#ã¯ãªãŒãã³ãœãŒã¹ã§ããããã®ã³ãŒãã¯GitHubã§å ¬éãããŠããŸãããã®ããã誰ã§ãF#ã®ã³ãŒããèªç±ã«å©çšãæ¹åãå ±æããããšãã§ããŸãã
1.2 F#ã®æŽå²
F#ã®åçã¯2005幎ã«ãªãªãŒã¹ãããŸãããããã¯ãé¢æ°åããã°ã©ãã³ã°ãšåå®å šãåé¢ã«æã¡åºããèšèªãšããŠããã®ç¹åŸŽã泚ç®ãããŸããã
2010幎以éã«æ¬æ ŒçãªããŒãžã§ã³ã¢ãããè¡ãããããå€ãã®æ©èœãè¿œå ãããå¹ åºãã¢ããªã±ãŒã·ã§ã³éçºã«å¯Ÿå¿å¯èœã«ãªããŸããã
ãã®åŸãããŒãžã§ã³ã¢ãããç¶ããããçŸåšã«è³ã£ãŠããŸãã
1.3 F#ã®ç¹åŸŽãšã€ã³ãã¯ã
F#ã¯ããã®åŒ·åãªåæšè«ã·ã¹ãã ãšREPLãµããŒãã«ãããéçºè ã¯ããå¹ççã«ã¢ããªã±ãŒã·ã§ã³ãéçºããããšãã§ããŸãã
ãŸããF#ã¯çµ±èšåæãæ©æ¢°åŠç¿ãããŒã¿ãµã€ãšã³ã¹ãã¯ã©ãŠããœãªã¥ãŒã·ã§ã³ãªã©ãå€å²ã«ãããåéã§æŽ»çšãããŠããŸãã
ãã®ãããF#ãåŠç¿ããããšã§ããããã®åéã§ã®éçºåã身ã«ã€ããããšãã§ããããå€æ§ãªãããžã§ã¯ãã«å¯Ÿå¿ããããšãã§ããŸãã
1.4 F#ã®ãã«ããã©ãããã©ãŒã 察å¿
F#ã¯éèŠã®é«ããã«ããã©ãããã©ãŒã èšèªã§ãWindowsãLinuxãmacOSãJavaScriptãªã©ãæ§ã ãªãã©ãããã©ãŒã ã§åäœããŸãã
ããã«ãããF#ãçšããŠäžåºŠã¢ããªã±ãŒã·ã§ã³ãéçºããã ãã§ãæ§ã ãªãã©ãããã©ãŒã ã«å¯Ÿå¿ããããšãã§ãããã®çµæãéçºã³ã¹ããå€§å¹ ã«åæžããããšãå¯èœã§ãã
ãŸããWebã¢ããªã±ãŒã·ã§ã³ã®éçºã«ãããŠããF#ã¯å€§èŠæš¡ãªWebã¢ããªã±ãŒã·ã§ã³ã®éçºã«ãå°èŠæš¡ãªWebã¢ããªã±ãŒã·ã§ã³ã®éçºã«ã察å¿ããŠããããã®æè»æ§ãé«ãè©äŸ¡ãããŠããŸãã
2. F#ã®é¢æ°åèšèªãšããŠã®å©ç¹
é¢æ°åããã°ã©ãã³ã°èšèªã¯ããã°ã©ã ã®èšè¿°ãæ°åŠçãªé¢æ°ã®è©äŸ¡ãšããŠæããããšã§ããªããžã§ã¯ãæåãªã©ãšã¯ç°ãªãèŠç¹ã§ãœãããŠã§ã¢ãèšèšã»éçºããããšãã§ããŸããä»åã¯ããã®äžã§ãç¹ã«å©çšãåºãã£ãŠããF#ã«ã€ããŠããã®é¢æ°åèšèªãšããŠã®ç¹æ§ãã¡ãªããã«ã€ããŠæ€èšŒããŸãã
2.1 é¢æ°åèšèªã®æŠèŠ
é¢æ°åããã°ã©ãã³ã°èšèªã¯ãããã°ã©ã ã®å®è¡ãé¢æ°ã®è©äŸ¡ãšããŠã¢ãã«åãããã©ãã€ã ãæ¡çšããŠããŸããå ·äœçã«ã¯ããã°ã®åå ãšãªãå¯äœçšãéããªãæé€ããã¹ããŒãã®å€æŽãè¡ããªãããã°ã©ã ãèšè¿°ããŸãããã®ããã䞊åæ§ãã¹ã±ãŒã©ããªãã£ïŒã·ã¹ãã ã®æ¡åŒµæ§ïŒãšãã£ãçŸä»£ã®ããã°ã©ãã³ã°ã«ãããèŠæ±ãããŸãæºããããšãå¯èœã§ãã
2.2 F#ã®éçŽç²é¢æ°åèšèªãšããŠã®åŽé¢
F#ã¯äžéšããªããžã§ã¯ãæåãåœä»€åããã°ã©ãã³ã°ã®èŠçŽ ãæã€éçŽç²é¢æ°åèšèªã§ããããã«ãããF#ã¯æ¢åã®.NETã©ã€ãã©ãªãšäžäœçã«åãããšãå¯èœãšãªããæ¥çã§åºãåãæ±ãããŠãã.NETã©ã³ã¿ã€ã ãšèŠªåæ§ã匷ããªã£ãŠããŸãããã®èåæ§ãF#ã®å€§ããªé åãšãªã£ãŠãããå€ãã®éçºè ãã¡ãF#ãéžãã§ããŸãã
2.3 é¢æ°åããã°ã©ãã³ã°ã®ã¡ãªãã
é¢æ°åããã°ã©ãã³ã°ã¯ããã°ã©ã ãããŒã¿ãããŒã®èŠç¹ããèããããã䞊ååãåå©çšæ§ããã¹ããããããšãã£ãèŠçŽ ãèªç¶ãšçµã¿èŸŒãŸããŸãããŸãããã°ãçºçãã«ãããèªã¿ãããã³ãŒããæžãããããã¡ã³ããã³ã¹ã³ã¹ããåæžãããŸãã
2.4 F#ã®åæšè«ã·ã¹ãã
ãŸãF#ã¯åŒ·åãªåæšè«ãæã£ãŠããŸããããã«ãã£ãŠãå宣èšãçç¥ã§ãããããé¢åãªå宣èšãããããšãªãå ·äœçãªããžãã¯ã«å°å¿µããããšãã§ããŸãããŸãããã®åæšè«ã·ã¹ãã ã«ãã£ãŠã³ã³ãã€ã«æã«ãã°ãæªç¶ã«é²ãããšãå¯èœã§ãå質ã®é«ãã³ãŒããå¹çããäœãåºãããšãã§ããŸãã
3. F#ã§ã§ããããš
F#ã¯ãã®å€åœ©ãªæ©èœãšãé å¥ãªèšèšã®ãããã§ãå¹ åºãçšéã«å¯ŸããŠå©çšããããšãå¯èœãšãªã£ãŠããŸããããã§ã¯ãF#ã®äž»ãªäœ¿çšæ¹æ³ã«ã€ããŠæŠèŠ³ããŸãã
3.1 Windowsãã¹ã¯ãããã¢ããªã±ãŒã·ã§ã³ã®éçº
F#ã¯Windowsãã¹ã¯ãããã¢ããªã±ãŒã·ã§ã³ã®éçºã«ç©æ¥µçã«æŽ»çšã§ããŸããå ·äœçã«ã¯ãMicrosoftãæäŸããŠããé«åºŠãªUIãã¬ãŒã ã¯ãŒã¯WPFïŒWindows Presentation FoundationïŒãçšããŠãå¹ççã«æ¥åããŒã«ãããªãŒãœãããäœãããšãå¯èœã§ãã
WPFãçšããããšã§ããã¶ã€ãããªãã£ãé«ãããŠãŒã¶ãŒãã¬ã³ããªãŒãªUIãå®çŸããããšãå¯èœã§ãããã®ãããF#ãšWPFãçšããŠäœæãããã¢ããªã±ãŒã·ã§ã³ã¯ããŠãŒã¶ãŒã«ãšã£ãŠäœ¿ãããããã®ãšãªããŸãã
ãŸããF#èªäœã®åŒ·åãªæ©èœãšçžãŸã£ãŠãããçãã³ãŒãã§å¹ççãªã¢ããªã±ãŒã·ã§ã³ã®éçºãå¯èœã«ãªããŸããè€éãªæ¥åãããŒãF#ãªãã°ã·ã³ãã«ã«å®è£ ããããšãã§ããã§ãããã
3.2 Webã¢ããªã±ãŒã·ã§ã³ã®éçº
F#ã¯Webã¢ããªã±ãŒã·ã§ã³ã®éçºã«ã察å¿ããŠããŸãã倧èŠæš¡ãªWebã¢ããªã±ãŒã·ã§ã³ã®éçºã«ãããŠãå ç¢æ§ãšå¹çæ§ãå Œãåãããã®èšèªã¯éåžžã«é åçã§ãã
F#補ã®ãã€ã¯ãWebãã¬ãŒã ã¯ãŒã¯ïŒäŸïŒGiraffeãSuaveãSaturnãBoleroïŒã«ãã£ãŠãããŸããŸãªWebã¢ããªã±ãŒã·ã§ã³éçºãè¡ãããšãã§ããŸãã
ãããã®ãã¬ãŒã ã¯ãŒã¯ã¯ãF#ã®ç¹æ§ãçããã匷åãªåç §éææ§ãšå¹æçãªéåæåŠçãæäŸããŠããŸããããã«ãããF#ã¯ããã©ãŒãã³ã¹ãšæ¡åŒµæ§ãå ŒãåããWebã¢ããªã±ãŒã·ã§ã³éçºã«æé©ãªéžæè¢ãšãªããŸãã
3.3 åçš®ããã°ã©ãã³ã°ãã©ãã€ã ã®é©çš
å€ãã®ããã°ã©ãã³ã°èšèªãç¹å®ã®ãã©ãã€ã ã«è¿œåŸããŸãããF#ã¯ãã®èŠåããå€ããŠããŸããé¢æ°åããã°ã©ãã³ã°ãæç¶ãåããã°ã©ãã³ã°ããªããžã§ã¯ãæåããã°ã©ãã³ã°ãéåæããã°ã©ãã³ã°ã䞊åããã°ã©ãã³ã°ãšãã£ãæ§ã ãªãã©ãã€ã ããã€ãªãæ±ããããããã®é·æã掻ããããšãã§ããŸãã
ããã«ãããF#éçºè ã¯èªèº«ã®ãããžã§ã¯ããŸãã¯ã¿ã¹ã¯ã«æé©ãªããã°ã©ãã³ã°ã¹ã¿ã€ã«ãèªç±ã«éžæã§ããŸããããã¯å¹ççãªéçºããã»ã¹ãä¿é²ãããããžã§ã¯ãã®æåã«å¯äžããŸãã
ããã«ãããã€ãã®ããã°ã©ãã³ã°ãã©ãã€ã ã䜿ãåããããšã§ãF#ã®éçºè ã¯ãã€ãããã¯ãªããã°ã©ã ãéçºããããšãå¯èœã§ããããã«ãããF#ã¯ããžãã¹ããŒãºã®å€åãæ°ããªæè¡ã®ç»å Žã«è¿ éã«å¯Ÿå¿ããããšãå¯èœãšãªããŸãã
3.4 ããŒã¿ãµã€ãšã³ã¹ãšAIéçºã§ã®å©çš
F#ã¯çµ±èšåæãããŒã¿è§£æããããŠAIãæ©æ¢°åŠç¿é åã§ã®éçºã«åŒ·åãªèœåãçºæ®ããŸããé«åºŠãªæ°åŠæ©èœã匷åãªåæšè«ã·ã¹ãã ãæèŒããŠããããšãããããŒã¿åæã®æå©ããšãªããŸãã
ãŸããéåæããã°ã©ãã³ã°ã䞊åããã°ã©ãã³ã°ã®ãµããŒããããã倧éã®ããŒã¿ãåŠçããäºãå¯èœã§ããããã«ãããF#ã¯å€§å®¹éã®ããŒã¿ãæ±ãããŒã¿ãµã€ãšã³ã¹ãAIéçºããŒã ã«ãšã£ãŠçæ³çãªéžæè¢ãšãªããŸãã
ããã«ãæ§ã ãªããŒã¿ãµã€ãšã³ã¹ã®ãã¬ãŒã ã¯ãŒã¯ãã©ã€ãã©ãªãžã®å¯Ÿå¿ãå å®ããŠãããããããŒã«éžã³ã®èªç±åºŠãå¢ããéçºã®å¹çåã«å¯äžããŸãã
4. F#ãšä»èšèªïŒC#ïŒã®æ¯èŒ
4.1 C#ãšF#ã®çžéç¹
ã¯ããã«ãF#ãšC#ã®äž»ãªçžéç¹ã«ã€ããŠè§£èª¬ããŸãããŸãF#ã¯ããã«ããã©ãã€ã ã®èšèªã§ãããé¢æ°åãæç¶ãåããªããžã§ã¯ãæåãéåæã䞊åããã°ã©ãã³ã°ã®è€æ°ã®ããã°ã©ãã³ã°ã¹ã¿ã€ã«ãçµã¿åãããŠäœ¿çšããããšãå¯èœã§ãã
äžæ¹ãC#ããªããžã§ã¯ãæåãåºæ¬ãšãããã«ããã©ãã€ã èšèªã§ããããã¡ãã¯F#ãšæ¯ã¹ããšé¢æ°åããã°ã©ãã³ã°ã®ãµããŒãã匱ãç¹ãç¹åŸŽã§ãããŸããF#ã¯åŒ·åãªåæšè«ã·ã¹ãã ãæã£ãŠããŠãéçºè ãå宣èšãçç¥ããããšããã°ãã°å¯èœãªã®ã«å¯ŸããŠãC#ã§ã¯æ瀺çãªå宣èšãå¿ èŠãªå Žåãå€ãã§ãã
ããã«F#ã¯REPLãµããŒãããããã³ãŒããçæéã§ãè©Šãå®è¡ããããã¹ãããããšã容æã§ããããããC#ã§ã¯ãããã®æ©èœãæäŸãããŠããŸããããã®ããã«ãF#ãšC#ã¯ããããç¹æã®ç¹åŸŽãšå©ç¹ããããããå ·äœçãªéçºå 容ãç®çã«ãã£ãŠé©ããèšèªãéžæããããšãéèŠã§ãã
4.2 F#ã§å®çŸããããæ©èœãåŠç
次ã«ãF#ã§ç¹ã«å®çŸã容æãªæ©èœãåŠçã«ã€ããŠèª¬æããŸããF#ã¯åŒ·åãªãã¬ãŒãã³ã°ããã³åæšè«ã·ã¹ãã ããããéçºè ãã³ãŒãã®èª€ããæ©æã«èŠã€ãåºãããšãå¯èœã§ããããã«ããããã°ã®çºèŠãšä¿®æ£ã容æã«ãªããçç£æ§ãåäžããŸãã
F#ã§ã¯ãäžå¯§ãªèšèšãšé«åºŠãªæé©åãè¡ãããšãªãé«æ§èœãªã³ãŒããæžãããšãå¯èœã§ãããŸããéåæããã°ã©ãã³ã°ã䞊åããã°ã©ãã³ã°ã®ãããªè€éãªåŠçãç°¡åã«èšè¿°ã§ããŸãã
ããã«ãF#ã¯ä»ã®.NETèšèªãšäºææ§ãé«ããä»ã®.NETã©ã€ãã©ãªããã¬ãŒã ã¯ãŒã¯ãšé£æºããŠéçºãè¡ãããšãå¯èœã§ããããã«ãããæ¢åã®è³ç£ã掻çšãã€ã€æ°ããéçºãè¡ãããšãã§ããŸãã
4.3 ã³ãŒãã®èšè¿°éãšå¯èªæ§ã®æ¯èŒ
F#ã®é åã®äžã€ã«ãã³ãŒãã®èšè¿°éãå°ãªãç¹ããããŸããå°ãªãã³ãŒãè¡æ°ã§å¿ èŠãªæ©èœãå®çŸã§ãããããéçºå¹çãåäžããŸãããŸããã³ãŒããã·ã³ãã«ã«ãªãããšã§ãã¡ã³ããã³ã¹æ§ãå¯èªæ§ãé«ãŸããŸãã
C#ãšæ¯èŒãããšãF#ã¯åã®æšè«ã匷åãªãããå宣èšãçç¥ããããæŒç®åã䜿çšããŠã³ãŒããç°¡æœã«èšè¿°ããããšãå¯èœã§ããããã«ãããåãæ©èœãå®çŸããã®ã«C#ãããF#ã®ã»ããã³ãŒãã®è¡æ°ãå°ãªããªãåŸåããããŸãã
ãŸããF#ã¯é¢æ°åèšèªã®ç¹æ§äžãå¯èªæ§ã®é«ãã³ãŒããæžãããšã容æã§ããã¯ã³ã©ã€ããŒã§è¡šçŸã§ããåŠçãå€ããããåŠçã®æµããææ¡ããããã®ãç¹åŸŽã§ãã
4.4 åèšèªã§é©ãããœãããŠã§ã¢éçºé åã®æ¯èŒ
æåŸã«ãF#ãšC#ã®é©ãããœãããŠã§ã¢éçºé åã«ã€ããŠã¿ãŠãããŸããããF#ã¯ãæ©æ¢°åŠç¿ãããŒã¿ãµã€ãšã³ã¹ãã¯ã©ãŠããœãªã¥ãŒã·ã§ã³éçºãªã©ã«åããŠããŸãã
C#ã¯ãWindows FormsãWPFãªã©ã®UIãã¬ãŒã ã¯ãŒã¯ãå©çšãããã¹ã¯ãããã¢ããªã±ãŒã·ã§ã³éçºã«åŒ·ãã§ãããF#ã§ãWindowsã¢ããªã±ãŒã·ã§ã³éçºã¯ååã«å¯èœã§ãã
äžæ¹ãF#ã¯æåããé¢æ°åèšèªãšããŠèšèšãããŠãããããé¢æ°åããã°ã©ãã³ã°ã«ã¯ããåããŠããŸããããã¯ã䞊ååŠçãéåæåŠçããããããšããç¹æ§ããã倧èŠæš¡ã§è€éãªããŒã¿åŠçãè¡ãã·ã¹ãã ã®éçºã«åããŠããŸãã
5. F#ããã°ã©ãã³ã°ã®ã¡ãªãããšãã¡ãªãã
ããã°ã©ãã³ã°èšèªã«ã¯ããããåŸæãšããåéãç¹æ®æ§ããããŸããéžã¶ã¹ãèšèªã¯ãåãçµãããšããŠããã¿ã¹ã¯ããããžã§ã¯ãã®å ·äœçãªèŠä»¶ã«ãããŸããããã§ã¯F#ããã°ã©ãã³ã°ãæã€é·æãšçæã«ã€ããŠè§£èª¬ããŸãããã
5.1 F#ããã°ã©ãã³ã°ã®å©ç¹
å€ãã®éçºè ãF#ã®åŒ·åãªåæšè«ã·ã¹ãã ãè©äŸ¡ããŠããŸããåæšè«ãã§ãããšãã³ãŒãã®èšè¿°éãå°ãªããªãããŸãã³ã³ãã€ã©ãåãšã©ãŒãé²ãããšã§ãã°ã®å°ãªãã¢ããªã±ãŒã·ã§ã³éçºãå¯èœãšãªããŸãã
ãŸããF#ã¯éçºè ã®ããã°ã©ãã³ã°æè¡åäžã«å¯äžãããšé«ãè©äŸ¡ãããŠããŸããF#ã¯é¢æ°åããã°ã©ãã³ã°ã®åŒ·ã¿ãçãããããã¹ãã¬ãŒãžã®ç¶æ ãçŽæ¥å€æŽããä¿å®çãªæç¶ãåããã°ã©ãã³ã°ãå¿ èŠãšããªãããã°ã©ã ã®äœæãå¯èœã§ãã
ããã«ãREPLããµããŒãããŠãããæ°ããªã³ã³ã»ãããã³ãŒãã¹ããããããã¹ããããããããã°ãããããã®ã容æã§ããããã«ãããäžéšã®ã³ãŒããäºæãã¬çµæãåŒãèµ·ãããªããã©ããã容æã«èª¿æ»ã§ããŸãã
5.2 F#ããã°ã©ãã³ã°ã®é£ç¹
F#ããã°ã©ãã³ã°ã«ã¯ããã®åŒ·åããšæ¯èŒããŠè¥å¹²ã®éçããããŸããäžã€ã¯éçºè 人å£ãå°ãªãç¹ã§ããå°ãªãéçºè 人å£ã«ãããF#é¢é£ã®è³æºãéãããŠããã®ãçŸç¶ã§ãã
ãŸããæºåž¯ã¢ããªã±ãŒã·ã§ã³åãã®éçºãµããŒãäœå¶ã匱ãç¹ãæããããŸããããã¯ãF#èšèªã®ç¬èªæ§ãããããã®ã§ãããäžéšã®éçºè ã«ãšã£ãŠã¯å³ããå¶çŽãšãªãåŸãŸãã
ãã®ãããªæ¬ ç¹ã¯èªèãã¹ãäºé ã§ãããªãããããããããªãã®ãããžã§ã¯ããã¿ã¹ã¯ã«å€§ããªåœ±é¿ãäžãããã®ã§ãªããã°ãF#ã®é·æãäžåãå¯èœæ§ããããŸãã
5.3 F#ã®éçºè 人å£ãšã³ãã¥ããã£
F#ã®éçºè 人å£ã®å°ãªãã¯äžèŠãããšçæã®ããã«æãããããããŸãããããããäžæ¹ã§F#ãæã€ç¬ç¹ãªç¹æ§ãç解ããŠããç±å¿ãªã³ãã¥ããã£ãååšããŸãã
ãããã®ã³ãã¥ããã£ã¯ãããã°ã©ãã³ã°ã«ãããåé¡è§£æ±ºããã¹ããã©ã¯ãã£ã¹ã®å ±æãšãã£ãæ å ±äº€æã®å Žãšãªã£ãŠããŸãããã®çµæãF#ã³ãã¥ããã£ã¯ã¹ãã«ã¬ãã«ãå°éæ§ã®é«ããã®ãå€ããšèšããŸãã
ããããå°éçãªèæ¯ã®ããããäžéšã§ã¯F#éçºè ãå šäœçã«ä»ã®è±èªåãããé«çµŠäžãåŸãŠãããšããå ±åããããŸãã
5.4 F#ã®åŠç¿ãªãœãŒã¹ãšãµããŒã
F#ã®åŠç¿ãªãœãŒã¹ã¯å¿ èŠã«å¿ããŠéžæããããšãã§ããŸããããšãã°ããããäžã®ããã¥ã¡ã³ããŒã·ã§ã³ãæ°å€ããããŸãããè±èªã®æžç±ãè±å¯ã§ãã
ãŸããF#ã¯Microsoftãæ¯æããŠãããããåªããããã¥ã¡ã³ããŒã·ã§ã³ãšããŒã«ã®ãµããŒããåããããšãã§ããŸããããã¯ãç¹ã«å€§äŒæ¥ã§ã¯éèŠãªèæ ®äºé ã§ãããŸãã
ããã«ãF#ã³ãã¥ããã£ãç©æ¥µçã«æŽ»åããŠãããããäœãåé¡ã解決ã§ããªãæã§ãããªã³ã©ã€ã³ã§ä»ã®éçºè ããååãåããããšãã§ããŸãã
6. F#ã®åºç€åŠç¿ãšå®è·µãã©ã€ã¢ã«
F#ã¯çŽæçã§ããã«ããã©ãã€ã ã®èšèªãå©çšãããããã°ã©ã ã®éçºãå¯èœã§ãããã®ç« ã§ã¯ãF#ããã°ã©ãã³ã°ã®åºç€ãããã®å¹æçãªåŠç¿æ¹æ³ã«ã€ããŠè§£èª¬ããŸãã
F#ã®æ§æããã®è©Šè¡é¯èª€ããªãœãŒã¹ãæ§èœã®æé©åçã«ã€ããŠå ·äœçã«è§£èª¬ããŸãã
åŠç¿è ã®åœé¢ã®èª²é¡ã¯ãããã®æŠå¿µãç解ãããã®äžã§èªå·±åŠç¿ããããšã«å°œããŸãã
6.1 F#ããã°ã©ãã³ã°ã®äž»èŠæ§æãšã³ãŒãèšè¿°ã®å ·äœçãªæ¹æ³
F#ã¯éåžžã«è¡šçŸåãè±ããªããã°ã©ãã³ã°èšèªã§ããããã®äž»èŠæ§æãç¿åŸããããšããšãŠãéèŠã§ãã
äŸãã°ãå€æ°ã®å®çŸ©ã¯’let’ããŒã¯ãŒããçšããŠè¡ããŸãããŸããé¢æ°åèšèªã§ãããããé¢æ°ã¯ç¬¬äžçŽã®ååšãšããŠæ±ãããé¢æ°ã®å®çŸ©ã«ã’let’ããŒã¯ãŒããçšããããŸãã
ããã«ãF#ã§ã¯ãã¿ãŒã³ãããã³ã°ãšåŒã°ãã匷åãªå¶åŸ¡æ§æãæäŸãããŠãããããã«ããéåžžã«èªç±åºŠã®é«ãã³ãŒãèšè¿°ãå¯èœã«ãªããŸãã
6.2 F#ã®å®çšçè©Šè¡ãšãšã©ãŒãã³ããªã³ã°
F#ããã°ã©ãã³ã°ã«ãããŠã¯ãã³ãŒãã®è©Šè¡é¯èª€ãéããåŠç¿ãéåžžã«å€§åã§ããF#ã¯REPLïŒRead-Eval-Print LoopïŒããµããŒãããŠãããå³åº§ã«ã³ãŒãã®å®è¡çµæã確èªããããšãã§ããŸãã
ãŸããF#ã§ã¯’option’åã’match’æ§æãçšããŠããšã©ãŒãã³ããªã³ã°ãè¡ãããšãã§ããŸããããã«ãããå®å šæ§ãšæè»æ§ãé«ããã³ãŒãã®èšè¿°ãå¯èœãšãªããŸãã
ãã®ãããªç¹æ§ã掻çšããããšã§ãå®çšçãªè©Šè¡ãšãšã©ãŒãã³ããªã³ã°ãè¡ããããé«å質ã®ãœãããŠã§ã¢ãéçºããããšãå¯èœã«ãªããŸãã
6.3 èªå·±åŠç¿ã®ããã®F#ãªãœãŒã¹æšå¥šãªã¹ã
F#ã®åŠç¿ãé²ããäžã§ãã€ã³ã¿ãŒãããäžã«æ°å€ãã®è³æãã³ã³ãã³ããååšããŸãã
ç¹ã«ããF# for fun and profitããšãããŠã§ããµã€ãã¯åå¿è ã«ç解ããããå 容ãè±å¯ã«æã£ãŠãããåºãæšå¥šãããŠããŸãã
ãŸããå ¬åŒã®F#ããã¥ã¡ã³ããŒã·ã§ã³ãéåžžã«å å®ããŠãããåºæ¬çãªæ§æããé«åºŠãªæŠå¿µãŸã§å¹ åºãã«ããŒããŠãããããäžèªããŠããããšã匷ãããããããŸãã
6.4 F#ã®ã³ãŒãããã©ãŒãã³ã¹ãšæé©åææ³
F#ããã°ã©ãã³ã°ã§ã¯ãããã©ãŒãã³ã¹ã¯éèŠãªé¢å¿äºã®1ã€ã§ãããé«å¹çãªã³ãŒããæžãããšãæ±ããããŸãããã«ããã©ãã€ã ã®ç¹æ§ãç解ããé©åãªå¯Ÿå¿ãå¿ èŠã§ãã
äžäŸãšããŠãéåæI/OãCPUå¯éåã®ã¿ã¹ã¯ãå®è¡ããéã«ã¯ãasyncã¢ãžã¥ãŒã«ã®å©çšãæšå¥šãããŠããŸããããã«ãããå¹ççãªãã«ãã¹ã¬ããã³ãŒãã®èšè¿°ãå¯èœãšãªããŸãã
ãŸããPerformant F# (F#ã®ããã©ãŒãã³ã¹)ãšãããããžã§ã¯ãã¯ãF#ã«ãããæé©åæè¡ã«é¢ãã倧éã®ãã³ããšããªãã¯ãæäŸããŠããã詳现ãªèª¿æ»ãšå°å ¥ã«æ¯é䜿ã£ãŠã¿ãŠãã ãããäžè¬çã«ãF#ã®ã³ãŒãã¯å°ãªããªãœãŒã¹ã§ãé«éãªã¬ãŒãã§åäœããŸãã
7. F#ã®æŽ»çšäºäŸãšæåè«
ããã°ã©ãã³ã°èšèªã®éžæã¯ãéçºãããžã§ã¯ãã®æåã«çŽæ¥çãªåœ±é¿ãäžããŸããä»åã¯ãF#ãéžæãæåãåããäºäŸããããžã§ã¯ãã«ã€ããŠçŽ¹ä»ããŸãã
7.1 F#掻çšäºäŸã®çŽ¹ä»
F#ã¯ãå€ãã®æ¥çãšäŒæ¥ã§å¹ åºã掻çšãããŠããŸããäžã€ã®é¡èãªäºäŸã¯ãé»ååååŒã®ãžã£ã€ã¢ã³ããJet.comã§ãã圌ãã¯ãµãŒããŒãµã€ãã®éçºã«F#ãæ¡çšãã倧èŠæš¡ã§è€éãªWebã¢ããªã±ãŒã·ã§ã³ãæ§ç¯ããŠããŸãã
ãŸããéèæ¥çã§ãF#ã¯ããæ¡çšãããŠããŸãããã®çç±ãšããŠãF#ã®ç¹æ§ãè€éãªéèååŒãèšç®ã¢ãã«ã®éçºã«åããŠããããã§ããå®éãå€ãã®æè³éè¡ãšãããžãã¡ã³ãã¯ããªã¹ã¯ç®¡çãååŒæŠç¥ã®éçºã«F#ã䜿çšããŠããŸãã
F#ã¯AIãæ©æ¢°åŠç¿ã«ã䜿ãããŠããŸãããšããããããŒã¿åæã®èŠ³ç¹ããã¿ããšãF#ã¯ãã®åŒ·åãªåæšè«ã·ã¹ãã ãšäžè²«æ§ã®ããæ§æã«ãããããŒã¿åæå°é家ã«ãšã£ãŠçæ³çãªèšèªãšãªãã§ãããã
7.2 F#ã®å ·äœçå©çšäŸ
çŸå®çãªå©çšäŸãšããŠãæ¢åã®ãŠã£ã³ããŠãºãã¹ã¯ãããã¢ããªã±ãŒã·ã§ã³ã®éçºã§F#ããã䜿ãããŠããŸãããŠãŒã¶ãŒã€ã³ã¿ãŒãã§ãŒã¹ãã¬ãŒã ã¯ãŒã¯ãšããŠWPFïŒWindows Presentation FoundationïŒã䜿çšããããšã§ãç»é²ç®¡çã·ã¹ãã ãåšåº«ç®¡çã·ã¹ãã ãªã©ãæ¥åå¹çãåäžãããããã®åçš®ããŒã«ãéçºããããšãå¯èœã§ãã
ãŸããWebã¢ããªã±ãŒã·ã§ã³ã®çŸå Žã§ãF#ã¯æŽ»èºããŠããŸããWebãã¬ãŒã ã¯ãŒã¯GiraffeãSuaveãšçµã¿åãããããšã§ãã¹ã±ãŒã©ãã«ã§å ç¢ãªWebã¢ããªã±ãŒã·ã§ã³ã®éçºãå¯èœã«ãªããŸãã
F#ã¯ãŸããã²ãŒã éçºã«ã䜿ãããŠããŸããUnityã®ãã©ã°ã€ã³ãšããŠåäœããF#ã®èšèªãã€ã³ãã£ã³ã°ã«ãããã²ãŒã ããžãã¯ã®éçºãUIã®ã¹ã¯ãªããã£ã³ã°ãå¯èœãšãªããŸãã
7.3 F#éçºè ããã®å£°
F#éçºè ã®éã§ã¯ãF#ããã°ã©ãã³ã°ã®ç¶ºéºããšè¡šçŸåããŸãåå®å šæ§ãé«ãè©äŸ¡ãããŠããŸãããŸããäžéšã®éçºè ã«ãšã£ãŠã¯ãF#ãé¢æ°åããã°ã©ãã³ã°ãšãªããžã§ã¯ãæåããã°ã©ãã³ã°ã®æŠå¿µãé©åã«æ··ãåãããŠããããšãé åçãšæããããŠããŸãã
F#ã®éçºè ã¯ãŸããF#ã®åªããããŒã«ã»ãããšãšã³ã·ã¹ãã ã«ã€ããŠãèšåããŠããŸããIDEãã©ã€ãã©ãªããã¬ãŒã ã¯ãŒã¯ãªã©ãéçºã容æã«ããããŒã«ãè±å¯ã«æäŸãããŠãããšæããŠããŸãã
ããããäžæ¹ã§ãF#ã®éçºè 人å£ãå°ãªãããšãæããããããšããããŸããããã¯ã質åãµã€ããæ²ç€ºæ¿ãªã©ã§æ å ±ãåŸãã®ãé£ããããšããåé¡ã瀺ããŠããŸãã
7.4 F#ã䜿ã£ãŠæåãããããžã§ã¯ã
ãtachyusããšãããšãã«ã®ãŒç£æ¥ã®ã¹ã¿ãŒãã¢ããäŒæ¥ããã®1ã€ã§ãã圌ãã¯ç³æ²¹æåäºã®æé©åæè¡ãéçºãããã®èåŸã®æè¡ãšããŠF#ãæ¡çšããŸãããF#ã®é«ãè¡šçŸåãšçç£æ§ãå®å šæ§ã«ããã圌ãã®ã·ã¹ãã ã¯é«ãä¿¡é Œæ§ãšå¹çãå®çŸããŸããã
ãŸããQuantAleaãšããäŒæ¥ãF#ãæ¡çšããŸããã圌ãã¯F#ãçšããŠGPUäžã§å®è¡ããã¢ããªã±ãŒã·ã§ã³ã®éçºãè¡ããF#ã®åŒ·åãªåæšè«æ©èœãšäžŠåèšç®æ©èœã掻çšããŠãé«æ§èœã§å®å šãªãœãããŠã§ã¢ãæ§ç¯ããããšã«æåããŸããã
ãããã®äºäŸãããF#ã¯ãã®ãŠããŒã¯ãªç¹åŸŽãšåŒ·åãªæ©èœã掻ããããšã§ãæ§ã ãªéçºãããžã§ã¯ãã§æåãåããŠããããšãããããŸãã