Kotlinããã°ã©ãã³ã°èšèªã®æ°ããããŒãžã§ã³ã§ããKotlin 1.1ãã玹ä»ããŸãã
ç§ãã¡ã®ç®æšã¯ãææ°ã®ã¢ããªã±ãŒã·ã§ã³ã®ãã¹ãŠã®ã³ã³ããŒãã³ããå¹æçã«èšè¿°ã§ãããè¡šçŸåè±ããªéçåä»ãèšèªãäœæããããšã§ãã æ¬æ¥ã®ãªãªãŒã¹ã§ã¯ããã®æ¹åã«2ã€ã®éèŠãªã¹ããããèžã¿ãŸãã
ãŸããJavaScriptã®ãµããŒãã¯å®éšçãªãã®ã§ã¯ãªããªããŸããã èšèªã®ãã¹ãŠã®æ©èœãå©çšå¯èœã§ããæšæºã©ã€ãã©ãªã®éèŠãªéšåã§ããããã¡ãããJavaScriptã³ãŒããšå¯Ÿè©±ããæ©èœããããŸãã ããã§ãã¢ããªã±ãŒã·ã§ã³ã®ã¯ã©ã€ã¢ã³ãéšåãKotlinã«ç§»è¡ã§ããããã«ãªããReactãªã©ã®éåžžã®ã©ã€ãã©ãªãšãã¬ãŒã ã¯ãŒã¯ãæŸæ£ããå¿ èŠããªããªããŸããã
第äºã«ãã³ã«ãã³ã®ãµããŒãããããŸããã³ã«ãã³ã¯ãã¹ã¬ããã®è»œéé¡äŒŒç©ã§ãããã¢ããªã±ãŒã·ã§ã³ãé©åã«ã¹ã±ãŒãªã³ã°ãã1å°ã®ãã·ã³ã§å€§ããªè² è·ããµããŒãã§ããŸãã ããã«ãã³ã«ãŒãã³ã¯éåæã³ãŒãã®èšè¿°ãå€§å¹ ã«ç°¡çŽ åããŸããããã¯ããã¹ãŠã®ãã©ãããã©ãŒã ã§ã®UIã®ãå¿çæ§ãã«ãšã£ãŠéèŠã§ãã
ãããã®å€æŽã®è©³çŽ°ã«ã€ããŠã¯ã以äžã§èª¬æããŸãã ä»ã®é©æ°ã«ã¯ã åãšã€ãªã¢ã¹ ã ãã€ã³ããããåŒã³åºãå¯èœãªåç § ã ã©ã ãã§ã®ç Žå£ãå«ãŸããŸãã èå³æ·±ãå€æŽã®å®å šãªãªã¹ãã¯ã æ°æ©èœããŒãžã«ãããŸãïŒäŸãå®è¡ããããšã«æ³šæããŠãã ããïŒïŒã
ã³ã«ãŒãã³ïŒã³ã«ãŒãã³ïŒ
Kotlinã®ã³ã«ãŒãã³ã«ãããéåæã³ãŒããéåžžã®åæã³ãŒããšåããããç°¡åã«äœæã§ããŸãã
éåæã³ãŒãã¯å€§ãããªã£ãŠããŠããããããæžãã®ã¯éåžžã«é£ããããšããããããŸãã ãã®äœæ¥ã容æã«ããããã«ãKotlinèšèªã¬ãã«ã®ã³ã«ãŒãã³ãµããŒããè¿œå ããŸãããããã«ã¯ã1ã€ã®ããªããã£ãïŒ ãµã¹ãã³ãé¢æ°ïŒã®ã¿ãå«ãŸããŸãã ãã®ãããªé¢æ°ã®å®è¡ã¯ãã¹ã¬ããããããã¯ããã«äžæåæ¢ããåŸã§åéã§ããŸãã ããã«ãå®è¡ã®äžæãšåéã®ããžãã¯ã«å¯Ÿããå¶åŸ¡ã¯ãã©ã€ãã©ãªã®äœæè ã«å®å šã«å±ããã¹ã¬ããã®è»œéãªä»£æ¿ãšããŠã³ã«ãŒãã³ã䜿çšã§ããŸãã çŸåšãè²»çšã®ããããããŒã®ãããã¯ã®ä»£ããã«ãã³ã«ãŒãã³ã®ã»ãŒç¡æã®ãµã¹ãã³ã·ã§ã³ã䜿çšã§ããŸãã
èšèªã®æ§æã«ã¯ã»ãšãã©è¿œå ãããŠããŸããïŒ1ã€ã®ä¿®é£ŸåïŒããã©ã€ãã©ãªã«ã¯ã¢ã¯ãã£ããã£ã®å·šå€§ãªã¹ã³ãŒããäžããããŠããŸãã ããšãã°ã kotlinx.coroutinesãããžã§ã¯ãã§ã¯ãRxãCompletableFutureãNIOãJavaFxãããã³Swingã®ãµããŒããæ¢ã«å®è£ ããŠããŸãã ãã®ãããªã©ã€ãã©ãªãŒã¯ãAndroidããã³JavaScriptçšã«äœæã§ããŸãïŒäºå®ãããŠããŸãïŒã ä»ã®ããã°ã©ãã³ã°èšèªã«çµã¿èŸŒãŸããŠããã³ã³ã¹ãã©ã¯ãã§ãããã©ã€ãã©ãªã®Kotlinã§å®è£ ã§ããŸããããšãã°ããžã§ãã¬ãŒã¿ãŒ/ Pythonããã®åºåããã£ãã«/ Goããã®éžæããŸãã¯CïŒããã®éåæ/åŸ æ©ïŒ
// runs the code in the background thread pool fun asyncOverlay() = async(CommonPool) { // start two async operations val original = asyncLoadImage("original") val overlay = asyncLoadImage("overlay") // and then apply overlay to both results applyOverlay(original.await(), overlay.await()) } // launches new coroutine in UI context launch(UI) { // wait for async overlay to complete val image = asyncOverlay().await() // and then show it in UI showImage(image) }
ããã¥ã¡ã³ãã®è©³çŽ°
éèŠãªãç¥ãã ã ã³ã«ãŒãã³ãæäŸãããã¹ãŠã®å©ç¹ã«ããããããããã®èšèšã¯ãŸã æ¯èŒçæ°ãããã®ã§ãã ãããã£ãŠããã¹ãŠãæ£ããå®è¡ããããšã確èªããããã«ãå®éã«éäžçã«æ€èšŒããå¿ èŠããããŸãã ãããã£ãŠã1.1ã®ã³ã«ãŒãã³ã¯ãå®éšçã ãã©ã°ã®äžã«åºãŠããŸãã èšèªã³ã³ã¹ãã©ã¯ããå€æŽãããå¯èœæ§ã¯äœããšæ³å®ããŠããŸãããKotlin 1.2ã§ã¯ãã³ã«ãŒãã³é¢é£ã®APIãžã®å€æŽãå¯èœã§ãã
JavaScriptãµããŒã
äžã§è¿°ã¹ãããã«ãKotlinã®ãã¹ãŠã®æ©èœã¯ãJVM / AndroidãšJavaScriptã®äž¡æ¹ã§åçã«å©çšã§ããããã«ãªããŸããïŒãªãã¬ã¯ã·ã§ã³ãé€ããçŸåšåãçµãã§ããŸãïŒã ããã«ãããJetBrainså ã®äžéšã®è£œåã§æåããŠããKotlinã§å®å šã«Webã¢ããªã±ãŒã·ã§ã³ãéçºã§ããŸãã è¿ãå°æ¥ãé¢é£ããããã¥ã¡ã³ããšæé ãå ¬éããäºå®ã§ãã
JavaScriptçšã®Kotlinã¯ãJavaScriptã³ãŒããšå¯Ÿè©±ããããã®åçã¿ã€ãããµããŒãããŠããŸãã 人æ°ã®ããã©ã€ãã©ãªãžã®åä»ãã¢ã¯ã»ã¹ã®å Žåã DefinitelyTypedã®ããããŒã§ts2ktã³ã³ããŒã¿ãŒã䜿çšã§ããŸãã
ããã¥ã¡ã³ãã®è©³çŽ°
ããŒã«ããã
äžéãªãªãŒã¹ã§ã¯ãèšèªã®æ§æã«é¢ä¿ã®ãªãæ°ããæ©èœããªãªãŒã¹ããããšããŠããŸãã Kotlin 1.0以éã«ç»å Žããæãå°è±¡çãªãã®ã¯æ¬¡ã®ãšããã§ãã
- ãã¹ãŠã®äž»èŠãªIDEã®ãã©ã°ã€ã³ïŒIntelliJ IDEAãAndroid StudioãEclipseãNetBeans
- IntelliJ IDEAããã³Gradleã§ã®ã€ã³ã¯ãªã¡ã³ã¿ã«ã³ã³ãã€ã«
- SpringãJPAãMockitoãšã®çµ±åãæ¹åããã³ã³ãã€ã©ãã©ã°ã€ã³ïŒããã©ã«ãã§æ¡åŒµå¯èœãªã¯ã©ã¹ãšç©ºã®ã³ã³ã¹ãã©ã¯ã¿ãŒã®èªåçæïŒ
- kapt-泚éããŒã«
- Androidãããžã§ã¯ãã«åºæã®ã³ãŒããã§ãã¯
- ãããŠãã¡ãããå€ãã®å€ãã®æ°ãã蚺æããã§ãã¯ãã¯ã€ãã¯ãã£ãã¯ã¹ããªãã¡ã¯ã¿ãªã³ã°ãããã³ãªãŒãã³ã³ããªãŒãã®æ¹åãIDEã«è¿œå ãããŸãã
ãã ããããŒãžã§ã³1.1.xã®ããŒã«ãããã®æ¹åã¯æ¢ã«åæ¢ããŠãããæ¢ã«æºåäžã§ãã
Kotlinã®æåã®å¹ŽïŒã³ãã¥ããã£ãšé åž
èŠããã«ãç§ãã¡ã¯æé·ããŠããŸãïŒ éå»1幎éã§16äžäººãè¶ ããããã°ã©ããŒãKotlinã䜿çšããŸããã Githubã®ãªãŒãã³ãœãŒã¹ãããžã§ã¯ãã®Kotlinã®è¡æ°ã¯ã2.4ãã1,000äžã«å¢å ããŸããã ãªãªãŒã¹1.0ã®æç¹ã§ãKotlinã®ã¹ã©ãã¯ãã£ã³ãã«ã«ã¯1'400人ãããŸãã-çŸåšã¯5'900人ã§ãã æ¯é±ãã³ãã¥ããã£ã®ã¢ã¯ãã£ããªã¡ã³ããŒã«ãã£ãŠç·šæãããæ°ããmitapãšãŠãŒã¶ãŒã°ã«ãŒããäžçäžã«è¡šç€ºãããŸãã ããå€ãã®æ°ããæ¬ããªã³ã©ã€ã³ã³ãŒã¹ãå ¬éãããŠããŸãã
Kotlinã¯ããµãŒããŒåŽãšAndroidéçºè ã®éã§ã»ãŒåãããã人æ°ããããŸãã Spring Framework 5.0 ã§ã¯ãKotlinãšvert.x 3.4ã® ãµããŒããå°å ¥ãããŠããŸãã GradleãšTeamCityã¯ãKotlinããŒã¹ã®DSLã䜿çšããŠãã«ãã¹ã¯ãªãããããã°ã©ã ããŸãã ãã¹ãŠã®äž»èŠãªKotlinãããžã§ã¯ããšã©ã€ãã©ãªã®ãªã¹ãã¯ã kotlin.linkã«ãããŸãã
å€æ°ã®äžççã«æåãªäŒæ¥ã補åã³ãŒãã«Kotlinã䜿çšãå§ããŸããïŒ Amazon Web Services ã Pinterest ã Coursera ã Netflix ã Uber ã Square ã Trello ã Basecamp ããã®ä»å€æ°ã Corda-æåãªéè¡ã®ã³ã³ãœãŒã·ã¢ã ïŒãŽãŒã«ããã³ãµãã¯ã¹ããŠã§ã«ãºãã¡ãŒãŽãJPã¢ãŒã¬ã³ããã€ãéè¡ãUBSãHSBCãBNPããªãããœã·ãšããžã§ãã©ã«ãªã©ïŒã«ãã£ãŠéçºãããåæ£ã¯ãŒã¯ãããŒã·ã¹ãã ã¯ãKotlinã®æåããéçºãããŸããã Kotlinã¯ãAvitoãRocketbankãAviââasalesãªã©ã®ãã·ã¢äŒæ¥ã§ã䜿çšãããŠããŸãã
ç§ãã¡ã¯ãäžçäžã®ãã¹ãŠã®ãŠãŒã¶ãŒãè²¢ç®è ãç©æ¥µçãªãµããŒã¿ãŒã«ééãªãæè¬ããŠããŸãã ããªãã®ãµããŒãã¯ç§ãã¡ã«ãšã£ãŠéåžžã«éèŠã§ãïŒ
Kotlin 1.1ã€ãã³ããæ§ç¯ãã
ãã®ãªãªãŒã¹ã¯ãä»ã®KotlinãŠãŒã¶ãŒã«äŒãæ£åœãªçç±ã§ãã ããªãã®è¡ã§ãã®ãããªäŒè°ãéå¬ããã®ã«åœ¹ç«ã€äžé£ã®è³æãçšæããŸããã3æ23æ¥ã«ãKotlinããŒã ã®ä»£è¡šè ãšã®ã©ã€ãäŒè°ããããŒããã£ã¹ãããŸããããã«ããåç£ãFuture Features Surveyã®ã»ãããå ¥æã§ããŸãã 詳现ãšç»é²ãã©ãŒã ã¯ãã¡ã ã
次ã¯äœã§ãã
Kotlinãçã«ãŠãããŒãµã«ãªãã«ã¹ã¿ãã¯èšèªã«ããããã«ãè€æ°ã®ãã©ãããã©ãŒã ã®å ±éã³ãŒããäžåºŠã«ã³ã³ãã€ã«ããããã®èšèªãšããŒã«ã®ãµããŒãã«åãçµãã§ããŸãã ããã«ãããã¯ã©ã€ã¢ã³ãåŽãšãµãŒããŒåŽã®äž¡æ¹ã§ã³ãŒãã䜿çšãããã¢ãžã¥ãŒã«ãäœæã§ããŸãã ãŸãããµãŒãããŒãã£ã®JavaScriptã©ã€ãã©ãªã®ããŒã«ãšãµããŒããæ¹åãç¶ããŠããŸãã JavaScriptã®ã€ã³ã¯ãªã¡ã³ã¿ã«ã³ã³ãã€ã«ãé²è¡äžã§ããããŒãžã§ã³1.1.xã®ããããã§ãªãªãŒã¹ããŸãã
Java 9ã®ãµããŒãã¯ããã®ãã©ãããã©ãŒã ã®å ¬åŒããŒãžã§ã³ã®ãªãªãŒã¹ïŒãã®å€ïŒãŸã§ã«è¡šç€ºãããŸãã
ã³ã«ãŒãã³ã«é¢ããå€ãã®ãã£ãŒãããã¯ãæåŸ ããŠãããèšèšãããã©ãŒãã³ã¹ãããã³ã©ã€ãã©ãªãå©çšå¯èœã«ãªã£ããšãã«ã©ã€ãã©ãªã®æ¹åã«åªããŸãã
ããããæŠããŠã次ã®ãªãªãŒã¹ã§ã¯ãæ¢åã®èšèªæ©èœã®ããŒã«ã®å質ãããã©ãŒãã³ã¹ã®åäžãã€ã³ãã©ã¹ãã©ã¯ãã£ã®æ¡å€§ããã°ã®ä¿®æ£ã«äž»ã«çŠç¹ãåœãŠãŸãã Kotlinã¯åŸã ã«å€ãã®ãããžã§ã¯ãã®ããŒãã¯ãããžãŒã«ãªãã€ã€ãããããã«å¿ããŠæé·ã«å¯Ÿå¿ããŠããŸãã
PSãã¹ãŠã®äž»èŠãã©ãããã©ãŒã ã§ã®Kotlinã®é åžã¯ãåœç€Ÿã«ãšã£ãŠæŠç¥çãªæ¹åæ§ã§ãã ãµãŒããŒããã¹ã¯ããããAndroidããã€ã¹ããã©ãŠã¶ãŒã§æ¢ã«å®è¡ã§ããŸãã è¿ãå°æ¥ããä»®æ³ãã·ã³ã®ãªãäžçããã«ããŒããiOSãçµã¿èŸŒã¿ã·ã¹ãã ãªã©ã®ãã©ãããã©ãŒã ããµããŒãããäºå®ã§ãã çŸåšãKotlin Nativeã®åªããããŒã ãJetBrainsã§åãçµãã§ãããæ¯èŒççæéã§äœãé¢çœããã®ãèŠããããšèããŠããŸãã
è©Šãæ¹
ãã€ãã®ããã«ããã©ãŠã¶ã§çŽæ¥Kotlinãè©Šãããšãã§ããŸãïŒ try.kotlinlang.org
Maven / Gradle ïŒ1.1.0ãã³ã³ãã€ã©ãšæšæºã©ã€ãã©ãªã®ããŒãžã§ã³çªå·ãšããŠäœ¿çšããŸãã
IntelliJ IDEA ïŒKotlin 1.1ã®ãµããŒãã¯2017.1ã«æ¢ã«çµã¿èŸŒãŸããŠããŸãã以åã®ããŒãžã§ã³ã§ã¯ããã©ã°ã€ã³ãããŒãžã§ã³1.1ã«æŽæ°ããå¿
èŠããããŸãã
Android Studio ïŒ ãã©ã°ã€ã³ãããŒãžã£ãŒã䜿çšããŠãã©ã°ã€ã³ãã€ã³ã¹ããŒã«ãŸãã¯æŽæ°ããŸãã
Eclipse ïŒ ããŒã±ãããã¬ã€ã¹ã§æ°ãããã©ã°ã€ã³ãå©çšã§ããŸãã
ã³ãã³ãã©ã€ã³ã³ã³ãã€ã©ã¯ãGithubã®ãªãªãŒã¹ããŒãžããå
¥æã§ããŸãã
äºææ§ Kotlin 1.1ã§ã¯ãèšèªãšæšæºã©ã€ãã©ãªã¯å®å šã«åŸæ¹äºææ§ããããŸã ïŒã¢ãžã¥ããã°ïŒã äœãã1.0ã®äžã§æ§ç¯ããã³éå§ãããå Žåã1.1ã§ãæ©èœãç¶ããŸãã 倧èŠæš¡ãªããŒã ã®æ®µéçãªç§»è¡ã容æã«ããããã«ã1.1ã®ãã¹ãŠã®æ°ããèšèªæ©èœãç¡å¹ã«ããç¹å¥ãªã³ã³ãã€ã©ããŒãæäŸããŠããŸãã ãã®ããã¥ã¡ã³ãã§ã¯ã移è¡ã®ãã¹ãŠã®åŸ®åŠãªç¹ã«ã€ããŠè©³ãã説æããŸããã