1. Scalaãšã¯ïŒ
Scalaã¯Java Virtual Machine (JVM)äžã§åäœããããªããžã§ã¯ãæåãšé¢æ°åããã°ã©ãã³ã°ãçµ±åããéçåä»ãã®èšèªã§ãããžã§ããªã¯ãªããŒã¿æœè±¡åãèš±å¯ããJavaãšã®ã·ãŒã ã¬ã¹ãªäºææ§ãä¿ã€äžæ¹ã§ãããæŽç·Žãããåã·ã¹ãã ãæäŸããæ©èœããããŸãã
Javaã®æ¢åã®ã©ã€ãã©ãªããã«ã«æŽ»çšããªãããæ°ããªé«åºŠãªçš®é¡ã®æœè±¡åãšé¢æ°åããã°ã©ãã³ã°ã®ããŒã«ãå©çšããããšãå¯èœã§ããããã«ãããJavaãããã³ãŒããç°¡æœã«ãªãå¯èœæ§ããããŸãã
ãŸããScalaã¯å®å šãªãã«ãã¹ã¬ããåŠçãæ¯æŽããæ°å€ãã®äŸ¿å©ãªæ©èœãåããŠããŸããããã«ããã䞊è¡æ§ãåæ£æ§ãå¿ èŠãšããã¢ããªã±ãŒã·ã§ã³ã®éçºã«ãé©ããŠããŸãã
1.1 Scalaãšããèšèªã®ç¹åŸŽãšã¯
Scalaã®ç¹åŸŽãšããŠãæãéèŠãªã®ã¯ãªããžã§ã¯ãæåãšé¢æ°åããã°ã©ãã³ã°ã®çµ±åã§ããããã«ãããéçºè ã¯ç¶æ³ã«å¿ããŠäŸ¡å€ããèšèšéžæãè¡ãããšãã§ããŸãã
ãŸããScalaã¯JVMäžã§å®è¡ããããããJavaãšã®çžäºéçšæ§ããããŸãããã®ãããæ¢åã®Javaã³ãŒããJavaã®ãã¬ãŒã ã¯ãŒã¯çãScalaããã°ã©ã å ããçŽæ¥äœ¿çšããããšãå¯èœã§ãã
éçåä»ããScalaã®éèŠãªç¹åŸŽã§ããåãã§ãã¯ã¯ã³ã³ãã€ã«æã«è¡ããããããå®è¡æãšã©ãŒãå€§å¹ ã«æžããããšãã§ããŸãã
1.2 Scalaãæ¯ããæè¡å²åŠ
Scalaã®æè¡å²åŠã®äžå¿ã«ã¯ããã¹ã±ãŒã©ããªãã£ããšãæ±çšæ§ããååšããŸããããã¯ãScalaãå°èŠæš¡ãã倧èŠæš¡ãªãããžã§ã¯ãã«å¯Ÿå¿ã§ãããããããããéçºã¹ã±ãŒã«ã§äœ¿çšã§ããèšèšããããŠããããšãæå³ããŸãã
ãŸãããã®æè¡å²åŠã®äžéšãšããŠãã³ã³ãã€ã©ãéçã«åããã§ãã¯ããããšã§ãéçºè ãå®å šã§ä¿å®æ§ã®é«ãã³ãŒããæžãæå©ããããããšãç®æããŠããŸãã
Scalaã¯ãœãããŠã§ã¢ã®ã©ã€ãã¿ã€ã å šäœãéããŠãé²åãç¶ããã¢ããªã±ãŒã·ã§ã³ã®ããŒãºã«å¯Ÿå¿ã§ãããããé²åæ§ãéèŠããŠããŸãã
1.3 Scalaã®æŽå²ãšéçºèæ¯
Scalaã¯2004幎ã«ã¹ã€ã¹é£éŠç工倧åŠã®Martin Oderskyææã«ãã£ãŠéçºãããŸããã圌ã¯Javaèšèªã®åæã®éçºè ã§ããããšã§ãç¥ãããŠããŸãã
Scalaã®éçºã®èæ¯ã«ã¯ããªããžã§ã¯ãæåããã°ã©ãã³ã°ãšé¢æ°åããã°ã©ãã³ã°ã®çµ±åãåã³Javaãšã®ã·ãŒã ã¬ã¹ãªäºææ§ãæ±ããããããã§ãã
ãã®çµæãJavaã®åŒ·åãªãšã³ã·ã¹ãã ã«ã¢ã¯ã»ã¹ããªãããããç·çµããã³ãŒããæžãããšãå¯èœãšãªã£ãScalaã¯ããšã³ã¿ãŒãã©ã€ãºéçºãªã©å€ãã®åéã§åœ¹ç«ã€èšèªãšããŠåãå ¥ããããŠããŸãã
1.4 Scalaã®éçºç°å¢ã®æ§ç¯
Scalaã®éçºç°å¢ã®æ§ç¯ã¯æ¯èŒçã·ã³ãã«ã§ããå ¬åŒãŠã§ããµã€ãããScalaã®ææ°ããŒãžã§ã³ãããŠã³ããŒãããã€ã³ã¹ããŒã«ããã ãã§äœ¿çšéå§ããããšãã§ããŸãã
ãŸãIntelliJ IDEAãEclipseãšãã£ãIDEã«Scalaãã©ã°ã€ã³ãã€ã³ã¹ããŒã«ããããšã§ãæ§æãã€ã©ã€ããã³ãŒãè£å®ãªã©ãScalaéçºã«ãšã£ãŠäŸ¿å©ãªæ©èœãå©çšããããšãã§ããŸãã
æåŸã«ããã«ãããŒã«ãšããŠã¯ãsbtãScalaã®æšæºçãªãã«ãããŒã«ã§ãããScalaã®ãããžã§ã¯ã管çã«éåžžã«æçšã§ããããã±ãŒãžç®¡çããã¹ãããããã€ãªã©ãäžé£ã®éçºããµããŒãããŸãã
2. Scalaã®åºæ¬çãªæ§æãšæµã
ããã°ã©ã èšèªã®äžçš®ã§ããScalaã«ã€ããŠããã®åºæ¬çãªæ§æãšããã°ã©ã æµãã玹ä»èŽããŸããScalaã¯æ©èœãè±å¯ã§åŒ·åãªèšèªã§ããããã®æ±ãæ¹æ¬¡ç¬¬ã§ã¯éåžžã«å¹ççãªããã°ã©ã ãäœãããŸãã
åºæã®æ§æãå¶åŸ¡æ§æãªã©ãScalaã®ç¹æ§ãç解ããããšã¯ããã°ã©ãã³ã°ã®å¹çãå€§å¹ ã«ã¢ãããããéèŠãªèŠçŽ ã§ãããã®ããŒãžã§ã¯ããããã®åºæ¬äºé ãåãæ±ããŸãã
ãããããScalaã®ããŒã¿åãšå€æ°ã®å®çŸ©ãå¶åŸ¡æ§æãšé¢æ°ã®æŠèŠãScalaã«ããããªããžã§ã¯ãæåãšé¢æ°åããã°ã©ãã³ã°ããããŠãšã©ãŒåŠçãšäŸå€åŠçã«ã€ããŠåŠãã§ãããŸãããã
2.1 ããŒã¿åãšå€æ°ã®å®çŸ©
Scalaã¯éçåä»ãã®èšèªã§ãInt, Double, Stringãªã©ã®ãããªããŒã¿åãæã£ãŠããŸããããããã®ããŒã¿åã¯ç¹å®ã®å€ãæ ŒçŽããã®ã«çšãããããã®ç¯å²ãæäœã決ãŸã£ãŠããŸãã
ãŸããããŒã¿ãä¿æããããã«ã¯å€æ°ãå®çŸ©ããŸããScalaã§ã¯valã®ãããªããŒã¯ãŒãã䜿çšããŠå€æ°ãå®çŸ©ããããã«é©åãªããŒã¿åãå²ãåœãŠãŸãããã®éãvalã¯åä»£å ¥äžå¯èœãªå€æ°ãå®çŸ©ããã®ã«çšããããvarã¯åä»£å ¥å¯èœãªå€æ°ãå®çŸ©ããã®ã«çšããããŸãã
ãããã®ããŒã¿åãšå€æ°ã®å®çŸ©ã¯Scalaã®ããã°ã©ã ã®åºç€ããªãããã®ç解ãããããããããè€éãªããã°ã©ã äœãã«é²ãã§ãããŸãã
2.2 å¶åŸ¡æ§æãšé¢æ°ã®ãŸãšã
Scalaã®å¶åŸ¡æ§æã¯ããã°ã©ã ã®å¶åŸ¡ãããŒã管å¶ããŸããif, while, forãªã©ã®å¶åŸ¡æ§æãåŠã¶äºã§ãæ¡ä»¶åå²ãç¹°ãè¿ãåŠçãªã©ãå®è£ ããäºãã§ããŸãã
次ã«é¢æ°ã§ãããScalaã§ã¯é¢æ°ããŸãéèŠãªæ§æèŠçŽ ã§ããé¢æ°ã¯ã³ãŒãã®äžéšãåé¢ã»åå©çšå¯èœãªåœ¢ã§ãŸãšãããã®ã§ãããã䜿ã£ãŠåŠçãèšè¿°ããŸããããã«ãã£ãŠã³ãŒãã®éè€ãæžãããä¿å®æ§ãå¯èªæ§ãåäžãããŸãã
ãããå¶åŸ¡æ§æãšé¢æ°ã®ç解ãšäœ¿ãæ¹ãèŠããäºããScalaã§ã®ããã°ã©ã äœæã®åºç€ãšãªããŸãã
2.3 ãªããžã§ã¯ãæåãšé¢æ°åããã°ã©ãã³ã°
Scalaã¯ããªããžã§ã¯ãæåãšé¢æ°åããã°ã©ãã³ã°ã®äž¡æ¹ã®ãã©ãã€ã ããµããŒãããŠããèšèªã§ãã
ãªããžã§ã¯ãæåããã°ã©ãã³ã°ã§ã¯ãããŒã¿ãšãã®ããŒã¿ãæäœããã¡ãœãããäžã€ã®“ãªããžã§ã¯ã”ãšããŠæããŸããããã«ãããããŒã¿ãšåŠçãäžäœåããŠç®¡çããäºãã§ããæç¶ãåããã°ã©ã ãããç解ããããä¿®æ£ã容æãªããã°ã©ã ãäœæããäºãå¯èœã§ãã
äžæ¹ãé¢æ°åããã°ã©ãã³ã°ã§ã¯ãèšç®ãè€æ°ã®å°ããªçŽç²é¢æ°ã«åå²ããããšã§åé¡ã解決ããŸããå¯èªæ§ãããããã¹ãããããã°ãããããããã倧èŠæš¡ãªã·ã¹ãã ãå®å šã«æ§ç¯ããäžã§æå¹ã§ãã
2.4 Scalaã®ãšã©ãŒåŠçãšäŸå€
ãšã©ãŒåŠçã¯ãããã°ã©ã ãæ£åžžã«åäœããªãç¶æ³ã«å¯ŸåŠããããã®æ段ã§ããScalaã§ã¯ãç°åžžç¶æ³ãæããšã©ãŒã¯ã©ã¹ãæäŸãããŠããããšã©ãŒãçºçããå Žåã«ã¯ããããã£ããããŠå¯Ÿå¿ããäºãå¿ èŠã§ãã
Scalaã§ã¯ãäºæããªãç¶æ³ãçºçããå Žåã«äŸå€ãæããããšãã§ããŸãããã®äŸå€ãææããããšã§ããã®ç¶æ³ã«é©åã«å¯Ÿå¿ããäºãå¯èœãšãªããŸãã
æ£åžžã«ããã°ã©ã ãåããããã«ã¯ããšã©ãŒåŠçãšäŸå€ã®ç解ãäžå¯æ¬ ã§ããããããç解ããããšã§ãRobustãªã³ãŒããæžãã¹ãã«ã磚ãããšãå¯èœã«ãªããŸãã
3. Scalaã®çç£æ§é«ã䜿ãããã®è¯ãç¿æ £
Scalaãçç£æ§é«ã䜿ãããã«ã¯ãããã€ãã®è¯ãç¿æ £ã身ã«ã€ããããšãéåžžã«éèŠã§ãããããããããã®ç¿æ £ãå®çãããããã«ã¯ãäžå®æéã®æéãšåªåãå¿ èŠã§ãã
3.1 ã³ãŒãã®ãªãŒããã«æ§ãé«ããæ¹æ³
ã³ãŒãã®ãªãŒããã«æ§ãé«ããããã«ã¯ãèŠçŽãæ £ç¿ã«åŸãããšãéèŠã§ããScalaã§ã¯å ·äœçã«ã¯ãåœåèŠåãã€ã³ãã³ãã空çœã®äœ¿çšãªã©ã該åœããŸãããŸããã³ãŒããäœãè¡ã£ãŠããã®ãã説æããããã«ã³ã¡ã³ããé©åã«çšããããšãéèŠã§ãã
ã³ã¡ã³ãã¯ãä»ã®éçºè ãããªãã®ã³ãŒããç解ããããã®éããã¹ãšãèšããŸãããã®ãããã³ãŒãèªäœãèªå·±èª¬æçã§ããããšãæãçæ³çã§ããããããé£ããå Žåãè€éãªããžãã¯ãçšããŠããå Žåã«ã¯ãã³ã¡ã³ãã掻çšããŸãããã
培åºããããŒã å ã®ã³ãŒãã¬ãã¥ãŒããã³ãŒãã®ãªãŒããã«æ§ã確ä¿ããäžã§åœ¹ç«ã¡ãŸããä»ã®ã¡ã³ããŒãšæèŠã亀ãããããè¯ãã³ãŒãã«ãªãããã«åžžã«æ¹åãç¶ããŠãã ããã
3.2 å®å šæ§ã確ä¿ãããã¹ãã®åœ¹å²ãšææ³
ScalaãçšãããœãããŠã§ã¢éçºã«ãããŠãããã¹ãã¯éåžžã«éèŠãªåœ¹å²ãæãããŸãããã¹ãã«ãã£ãŠãã³ãŒããæ³å®éãã®åäœãããããšã確èªãããããã°ãæ©æã«çºèŠãããããŸãã
Scalaã§ã¯ãTDD(Test-Driven Development)ãBDD(Behavior-Driven Development)ãšãã£ãéçºææ³ãäžè¬çã«çšãããããã®ããã«ã¯ScalaTestãSpecs2ãªã©ã®ã©ã€ãã©ãªãå©çšãããŸãã
ãŸããã¡ãœãããã¯ã©ã¹ã®åäœãã¹ãã ãã§ãªããã·ã¹ãã å šäœã®çµåãã¹ããéèŠã§ããããã«ããé«åºŠãªãã°ãçºèŠãããœãããŠã§ã¢ã®å質ãä¿ã€ããšãã§ããŸãã
3.3 ã¡ã¢ãªç®¡çãšããã©ãŒãã³ã¹ãã¥ãŒãã³ã°
Scalaãçšããéã®ããã©ãŒãã³ã¹ãã¥ãŒãã³ã°ãã¡ã¢ãªç®¡çãéèŠãªç¿æ £ã®äžã€ã§ããããã§ã¯ã¬ããŒãžã³ã¬ã¯ã·ã§ã³ã®æåç解ãæ£ããããŒã¿æ§é ã®éžæãéµãšãªããŸãã
é©åãªããŒã¿æ§é ãéžæããããšã§ã¡ã¢ãªæ¶è²»ãæãã€ã€ãã¢ããªã±ãŒã·ã§ã³ã®ããã©ãŒãã³ã¹ãåäžãããããšãå¯èœã§ãããŸããäžå¿ èŠãªãªããžã§ã¯ãã®çæãé¿ããããšã§ã¬ããŒãžã³ã¬ã¯ã·ã§ã³ã®åæ°ãæžãããåæã«ããã©ãŒãã³ã¹ã®åäžã«ãå¯äžããŸãã
Scalaã§ã¯JVMäžã§åäœãããããJavaãšåæ§ã®ã¡ã¢ãªç®¡çãããã©ãŒãã³ã¹ãã¥ãŒãã³ã°ã®ææ³ãé©çšå¯èœã§ããJVMã®ãã¥ãŒãã³ã°ãªãã·ã§ã³ãé©åã«æŽ»çšããããšãéèŠãªç¿æ £ã§ãã
3.4 ãªãã¡ã¯ã¿ãªã³ã°ã®éèŠæ§
Scalaãçç£æ§é«ã䜿ãããã«ã¯ããªãã¡ã¯ã¿ãªã³ã°ã®ç¿æ £ãéåžžã«éèŠã§ãããªãã¡ã¯ã¿ãªã³ã°ãšã¯ãã³ãŒãã®æ¯ãèããå€ããããšãªããã®å éšæ§é ãæ¹åããããšãæããŸãã
Scalaã§ã¯ãç¹ã«äžå¿ èŠãªäžéããŒã¿ãçæããããšãªãã·ã³ãã«ãªã³ãŒããå®çŸããããã®æ¹æ³ãšããŠãé¢æ°åããã°ã©ãã³ã°ã®ãã¯ããã¯ã掻çšããããšãå€ãã§ããããã«ã¯ãããã(map)ããã£ã«ã¿ãŒ(filter)ããªãã¥ãŒã¹(reduce)ãªã©ã®é«éé¢æ°ãå©çšãããŸãã
ãªãã¡ã¯ã¿ãªã³ã°ã¯æã«èªå·±æºè¶³çãªæ¬èœãæºããããã®è¡çºãšèª€è§£ãããã¡ã§ãããããã¯å€§ããªééãã§ããè¯ãã³ãŒãã¯ããã¡ã³ããã³ã¹ããããã³ãŒãã§ãããæªæ¥ã®ãã©ãã«ãé¿ããããã«ããªãã¡ã¯ã¿ãªã³ã°ã¯çµ¶å¯Ÿã«æ¬ ãããªãäœæ¥ãšããæèãæã€ããšã倧åã§ãã
4. Scalaã®ããæ·±ãç解ã®ããã«
äžçŽScalaãšã³ãžãã¢ã«ãªãããã«ã¯ãScalaã®æ¡åŒµæ§ãšãã¯ãŒããã«ã«æŽ»çšããªããã°ãªããŸããã匷åãªã©ã€ãã©ãªãŠãã¯ãªããæè»æ§ã®ãããããã¯ãã©ã èšèªãŠããããšããç¹æ§ãç解ã§ããããšããã€ã³ãã§ãã
Scalaã®äžçã«ã¯ãæéãšå ±ã«æè¡åãæ·±ããããã®å€ãã®ãªãœãŒã¹ããããŸãããããã¯ãScalaã®é«åºŠãªãã¯ããã¯ãã©ã€ãã©ãªãšãã¬ãŒã ã¯ãŒã¯ãããŒã¿åæãšãã·ã³ã©ãŒãã³ã°ã®æ±ãã倧èŠæš¡åæ£ã·ã¹ãã ã®å®è£ ãªã©ãScalaã®è±ãããããŸããŸãªè§åºŠãã玹ä»ããŠããŸãã
æ¬ç« ã§ã¯ããããã®ãããã¯ã«è§ŠããªãããScalaã®ããæ·±ãç解ãç®æãããã®æ å ±ãæäŸããŸãã
4.1 Scalaã®é«åºŠãªãã¯ããã¯
Scalaã®åŒ·åãªæ©èœããã«ã«æŽ»çšããã«ã¯ããã¿ãŒã³ãããã³ã°ãé«éé¢æ°ãæé»çãã©ã¡ãŒã¿ãŒãªã©ãScalaç¹æã®æŠå¿µãç解ããããšãå¿ èŠã§ãã
ç¹ã«ãå¯èªæ§ãšåå©çšæ§ãåäžãããããã«ã¯ãé«éé¢æ°ãå®éã«äœ¿çšãããã¯ããã¯ãç解ããããšãéèŠã§ãããŸããè€éãªããŒã¿æ§é ãå¹æçã«æ±ãããã«ã¯ããã¿ãŒã³ãããã³ã°ã®æŽ»çšãéµãšãªããŸãã
ãããã®é«åºŠãªæ©èœã¯ãããã©ãŒãã³ã¹ãæ¹åããããã³ãŒãã®å¯èªæ§ãç¶æããããã³ãŒãã®å®è£ ãåå©çšãããããããã«å¿ èŠã§ãã
4.2 ã©ã€ãã©ãªãšãã¬ãŒã ã¯ãŒã¯
Scalaã䜿çšããæ倧ã®å©ç¹ã®äžã€ã¯ãå å®ããã©ã€ãã©ãªãšãã¬ãŒã ã¯ãŒã¯ãžã®ã¢ã¯ã»ã¹ã§ãããããã®ããŒã«ã¯Scalaã®æ©èœãæ¡åŒµãããã容æã«å®è£ ããããšãå¯èœã§ãã
äŸãã°ã誰ããç¥ã£ãŠãããã¬ãŒã ã¯ãŒã¯Playãã¬ãŒã ã¯ãŒã¯ããApache Sparkãšãã£ãåæ£åŠçã·ã¹ãã ããµããŒãããã©ã€ãã©ãªãªã©ããããŸãã
ãããã®ããŒã«ã¯ãScalaã®ãã¯ãŒã掻çšããªããããããã¿ã€ããè¿ éã«äœæããããšãå¯èœã«ãããšã³ãžãã¢ã®çç£æ§ãé«ããŸãã
4.3 ããŒã¿åæãšãã·ã³ã©ãŒãã³ã°ã®æ±ã
Scalaã¯ãããŒã¿åæãšãã·ã³ã©ãŒãã³ã°ã«ãåªããŠããŸãããã®çç±ã¯ãScalaãé¢æ°åããã°ã©ãã³ã°ãšãªããžã§ã¯ãæåããã°ã©ãã³ã°ãçµã¿åãããããšã§ãããŒã¿ãããçŽèŠ³çã§å¹æçã«æ±ããããã§ãã
Apache Sparkã¯ãScalaã§æžããããªãŒãã³ãœãŒã¹ã®å€§èŠæš¡ããŒã¿åŠçãšã³ãžã³ã§ãããŒã¿åæãšãã·ã³ã©ãŒãã³ã°ã«åºã䜿çšãããŠããŸãã
ç¹ã«ãæ©æ¢°åŠç¿ã©ã€ãã©ãªMLlibã®äœ¿çšãéããŠãScalaã¯å€§èŠæš¡ãªããŒã¿ã»ããã§è€éãªæ©æ¢°åŠç¿ã¢ãã«ã®èšç·Žãšè©äŸ¡ãè¡ãããšãã§ããŸãã
4.4 倧èŠæš¡åæ£ã·ã¹ãã ã®å®è£
Scalaã¯å€§èŠæš¡åæ£ã·ã¹ãã ã®èšèšã«æé©åãããŠããŸããããã¯ç¹ã«ãçŸä»£ã®é«åºŠãªããŒã¿åŠçã¯ãŒã¯ããŒãã«ãããŠéèŠã§ãã
äŸãã°ãã©ã€ãã©ãªã®1ã€ã«Apache Kafkaããããããã¯ãªã¢ã«ã¿ã€ã ã®å€§èŠæš¡ããŒã¿åŠçãè¡ãããã®ãªãŒãã³ãœãŒã¹ãã©ãããã©ãŒã ã§ãScalaã§éçºãããŠããŸãã
ãŸããäžè¬çãªåæ£åŠçããŒã«ã§ããAkkaã¯ããªã¢ã¯ãã£ããªã·ã¹ãã ãèšèšããããã®ãã¬ãŒã ã¯ãŒã¯ã§ãããScalaã§ã®æ¡çšãé²ãã§ããŸãããããã®ããŒã«ã¯ã倧èŠæš¡ãã€é«åºŠãªåæ£ã·ã¹ãã ã®æ§ç¯ã«åœ¹ç«ã¡ãScalaã®åŒ·åããç©èªã£ãŠããŸãã
5. Scalaã§ã®ãããžã§ã¯ããããŒãžã¡ã³ã
Scalaã¯é«ãããã©ãŒãã³ã¹ãšæè»æ§ãæã€ãéçåä»ããããããã°ã©ãã³ã°èšèªã§ããããã«ãããéçºãããžã§ã¯ãã管çããéãããããã®ç¹æ§ã掻ããããŸãããã®ç« ã§ã¯ãScalaã§ã®ãããžã§ã¯ããããŒãžã¡ã³ãã®ããã«éèŠãªããã€ãã®èŠçŽ ãåãäžããŸãã
ãããã®èŠçŽ ã«ã¯ããã«ãããŒã«ã®éžæãšå©çšãããŒãžã§ã³ç®¡çãCI/CDã®å°å ¥ãšæŽ»çšãã³ãŒãã¬ãã¥ãŒãšããŒã ã§ã®éçºãå«ãŸããŸãã
ãããã®ãã¹ãŠãç解ããé©åã«æŽ»çšããããšã§ãå¹ççã§çç£çãªScalaã®ãããžã§ã¯ã管çãå¯èœãšãªããŸãã
5.1 ãã«ãããŒã«ã®éžæãšå©çš
Scalaãããžã§ã¯ãã®ÐœÐ°Ñалеã«ã¯é©åãªãã«ãããŒã«ã®éžæãéèŠã§ãããã«ãããŒã«ã¯ãããžã§ã¯ãã®ã³ã³ãã€ã«ãè€æ°ã®ã©ã€ãã©ãªã®äŸåé¢ä¿ã®è§£æ±ºããã¹ãå®è¡ãªã©ããããžã§ã¯ãã®ã©ã€ããµã€ã¯ã«ã®å€ãã®æ®µéã§æŽ»çšãããŸãã
sbtã¯ãScalaã§æãäžè¬çã«äœ¿çšããããã«ãããŒã«ã§ããããã®æ©èœæ§ãšæ¡åŒµæ§ããScalaã®éçºè éã«å¹ åºãæ¯æãããŠããŸãã
ãã«ãããŒã«ãç解ããé©åã«äœ¿çšããããšã§ããããžã§ã¯ãå šäœã®å質ãšçç£æ§ãåäžãããããšãå¯èœãšãªããŸãã
5.2 ããŒãžã§ã³ç®¡çã®ç解
gitã¯ãScalaãããžã§ã¯ããããŒãžã§ã³ç®¡çããããã®äž»èŠãªããŒã«ã§ãããã®ããŒã«ãé©åã«äœ¿çšããããšã§ãå€æŽã®è¿œè·¡ãåé¡ã®ãã©ãã«ã·ã¥ãŒãã£ã³ã°ãåŸããã®å€æŽã®åã蟌ã¿ãªã©ã容æã«ãªããŸãã
ãŸããGitHubãGitLabãªã©ã®ãã©ãããã©ãŒã ãå©çšããããšã§ããªã¢ãŒãã§ã®éçºãã³ã©ãã¬ãŒã·ã§ã³ãå¯èœãšãªãããããžã§ã¯ãã®é²è¡ã«é¢ããå¯èŠæ§ãåäžãããããšãã§ããŸãã
ãããã£ãŠãããŒãžã§ã³ç®¡çã®ç解ãšå®è¡ã¯ãScalaãããžã§ã¯ãã®ç®¡çã«ãããŠéåžžã«éèŠãšãªããŸãã
5.3 CI/CDã®å°å ¥ãšæŽ»çš
CI(ç¶ç¶çã€ã³ãã°ã¬ãŒã·ã§ã³)ãšCD(ç¶ç¶çããªããªãŒãŸãã¯ãããã€ã¡ã³ã)ã¯ãçŸä»£ã®ãœãããŠã§ã¢éçºããã»ã¹ã«ãããŠäžå¿çãªåœ¹å²ãæãããŠããŸãã
Scalaãããžã§ã¯ãã§ããCI/CDã®å°å ¥ãšæŽ»çšã¯ãé«å質ãªãœãããŠã§ã¢ãçããµã€ã¯ã«ã§ãªãªãŒã¹ãããŠãŒã¶ãŒã¬ãã¥ãŒããåŸããããã£ãŒãããã¯ãè¿ éã«åæ ããæ段ãšããŠéåžžã«æå¹ã§ãã
JenkinsãTravis CIãCircleCIãªã©ã®ããŒã«ã䜿çšããŠãScalaãããžã§ã¯ãã®CI/CDãã€ãã©ã€ã³ãèšå®ããããšãå¯èœã§ãã
5.4 ã³ãŒãã¬ãã¥ãŒãšããŒã ã§ã®éçº
ã³ãŒãã¬ãã¥ãŒã¯ãå質ä¿èšŒã®äžã§éèŠãªåœ¹å²ãæãããŠããŸãã
ã³ãŒãã¬ãã¥ãŒãå®æçã«è¡ãããšã§ãã³ãŒãã®å質ãã³ãŒãããŒã¹ã®å¥å šæ§ããããŠããŒã å ã®ã¹ãã«ãšç¥èã®å ±æãå¹æçã«é²è¡ããŸãã
ç¹ã«Scalaã®ãããªé«åºŠãªæœè±¡åãšå€æ©èœæ§ãæã€èšèªã§ã¯ãã³ãŒãã¬ãã¥ãŒãéããŠããŒã å šäœã®ç解ãæ·±ããããšãéèŠã§ãã
6. Scalaã®å°æ¥æ§ãšé²å
ããã°ã©ãã³ã°èšèªã¯åžžã«æ±ããããéèŠã«åãããŠæè¡é©æ°ãç¹°ãè¿ãããã®é²åããšããŠããŸãããã®äžã§ãScalaã¯ãé¢æ°åãšãªããžã§ã¯ãæåã®ãã€ããªãããªç¹æ§ã掻ãããŠãå¹ åºãé åã§èŠªããŸããŠããŸããã§ã¯ããã®Scalaãããããããã¹ãéãã©ãé²ãã®ãããã®æªæ¥ãšé²åã«ã€ããŠèããŠã¿ãŸãããã
6.1 倧èŠæš¡éçºã§ã®å©çšäºäŸãšåŸå
Scalaã¯ããã®é«åºŠãªæœè±¡åãå¯èœãªç¹æ§ãã倧èŠæš¡éçºã«ãããŠåãçºæ®ããŸããTwitterãSoundCloudãªã©å€§èŠæš¡ã·ã¹ãã ãæã€äŒæ¥ãScalaãæ¡çšããæåãããããŠããŸããããã¯Scalaã倧èŠæš¡ãªã³ãŒãããŒã¹ã§ããã®å質ãä¿ã¡ç¶ããããããã§ãã
ãŸããScalaãæäŸããéçåä»ãã¯ãã³ãŒãã®å®å šæ§ãšã¡ã³ããã³ã¹æ§ãé«ããäžæ¹ã§ãéçºé床ãèœãšããªããšãããã©ã³ã¹ãä¿ãŠãçŽ æŽãããç¹æ§ã§ãããã®ããã倧èŠæš¡éçºã§ã¯ãã®ç¹æ§ãããåŒãç«ã€ãšèšããŸãã
æŽã«ãScalaã¯AkkaãPlayãšãã£ãæå 端ã®ãã¬ãŒã ã¯ãŒã¯ãšçžæ§ãè¯ããããããšçµã¿åãããŠäœ¿çšããããšã§å€§èŠæš¡éçºãåæ»ã«é²ããããšãå¯èœã§ãã
6.2 Scala3ãžã®ç§»è¡ãšæ°æ©èœ
Scalaã¯çå®ã«é²åãç¶ããŠãããæ°ããããŒãžã§ã³ã®Scala3ãžã®ç§»è¡ãçŸåšé²è¡äžã§ããScala3ã«ã¯æ°ããªæ©èœãå€æ°å°å ¥ãããããé¢æ°åããã°ã©ãã³ã°ã匷åã«ãµããŒãããããã®æ¹è¯ãæœãããŠããŸãã
Scala3ã§ã¯ãæ°ããªåã·ã¹ãã ãæ°ããªå¶åŸ¡æ§é ãæ°ããªãã¯ãã·ã¹ãã ãªã©ãå°å ¥ãããŸããããã«ãããScalaã®ã³ãŒãã¯ããå®å šæ§ãšå¹çæ§ãå¢ãããã®å質ã¯æŽã«åäžããŸãã
çŸè¡ã®Scala2.xç³»ã®ã³ãŒããScala3ã«ç§»è¡ããããã®ãµããŒããå å®ããŠãããæ°ããªç¹æ§ãåãå ¥ãã€ã€æ¢åã®ã³ãŒãããŒã¹ãä¿æããããšãã§ããŸãã
6.3 ãã€ã¯ããµãŒãã¹ã®å®è£ ãšã¯ã©ãŠããžã®é©å¿
è¿å¹Žããã€ã¯ããµãŒãã¹ãšããã¢ãŒããã¯ãã£ãçãã«äœ¿çšãããŠããŸããScalaã¯ãã®ç¹æ§äžããã€ã¯ããµãŒãã¹ã®å®è£ ã«é©ããŠããŸããAkkaãLagomãPlay Frameworkãªã©ãšãã£ãScalaã®äž»èŠãªãã¬ãŒã ã¯ãŒã¯ã®å€ãããã®ãã€ã¯ããµãŒãã¹ããµããŒãããŠããããã§ãã
ãã€ã¯ããµãŒãã¹ã¯ãã¢ããªã±ãŒã·ã§ã³ãççµåãªã³ã³ããŒãã³ãã«åå²ãããããããç¬ç«ããŠãããã€ã»ã¹ã±ãŒã«ãããšããã¢ãŒããã¯ãã£ã§ãããããå®çŸããããã«Scalaã®ç¹æ§ãé«ãæœè±¡åãšçµåãã®èªç±åºŠã掻ããããŸãã
ãŸããScalaã¯ã¯ã©ãŠãã®å©çšã«ãé©å¿ããŠããŸããAWS LambdaãGoogle Cloud Functionsãªã©ã®å€ãã®ãµãŒããŒã¬ã¹ãã©ãããã©ãŒã ãScalaããµããŒãããŠãããã¯ã©ãŠãäžã§ã®éçºã»éçšã容æã«ã§ããŸãã
6.4 AIãIoTåéã§ã®æŽ»çšå¯èœæ§
è¿å¹ŽãAIãIoTãšãã£ãé åã§ã®ãã¯ãããžãŒã®é²åãç¶ããŠããŸãããããã®é åã§ã¯ãæ©æ¢°åŠç¿ãããŒã¿åæãã·ã¹ãã å¶åŸ¡ãªã©ãè€éãªåé¡è§£æ±ºãæ±ããããŸããScalaã¯ãããã®é åã§æŽ»çšå¯èœãªç¹æ§ãæããŠããŸãã
äŸãã°ãApache Sparkãªã©ã®å€§èŠæš¡ããŒã¿åŠçãã¬ãŒã ã¯ãŒã¯ã掻çšããããšã§ãScalaã§ã®ããŒã¿åŠçãæ©æ¢°åŠç¿ã容æã«è¡ããŸãããŸããScalaã®éçåä»ãã¯ãè€éãªAIã»IoTã·ã¹ãã ã®éçºã«ãããŠå®å šæ§ãé«ããç¹ã§å©ç¹ãšãªããŸãã
ãŸããScalaã¯åŒ·åãªäžŠè¡ã»äžŠååŠçã®æ©èœãæã£ãŠããŸããããã¯ãAIãIoTã®åéã§å€ãã®ã¿ã¹ã¯ã䞊è¡ã«å®è¡ããå¿ èŠãããå Žé¢ã§å€§ãã«åœ¹ç«ã¡ãŸãããã®çµæãScalaã¯ãããã®é åã§ã®éçºãé²ããããã®åªããããŒã«ãšèšããã§ãããã
åèæç®
![](https://homeworkers.jp/program/wp-content/themes/the-thor/img/img_no_768.gif)