Perception and Effects of Implementing Kotlin in Existing Projects
Total Page:16
File Type:pdf, Size:1020Kb
Bachelor thesis Undergraduate level Perception and effects of implementing Kotlin in existing projects A case study about language adoption Author: Emil Sundin Supervisor: Wei Song Examiner: Azadeh Sarkheyli Discipline: Informatics Course: IK2017 Credit: 15 credits Examination date: 2018-05-25 Dalarna University provides the opportunity for publishing the thesis through DiVA as Open Access. This means that the thesis work will become freely available to read and download through their portal. Dalarna University encourages students as well as researchers to publish their work in the Open Access format. We approve the publishing of this thesis work under the Open Access format: Yes ☒ No ☐ Dalarna University – SE-791 88 Falun – Phone +4623-77 80 00 Abstract The Kotlin programming language has seen an increase of adoption since its launch in 2011. In late 2017 Google announced first-class support for Kotlin on the Android platform which further popularized the language. With this increase in popularity we felt it was interesting to investigate how Kotlin affects the developer experience. We performed a case study to see how Java developers perceive the Kotlin language, and how it meets the requirements of these developers. To gather the developer requirements and their perception of Kotlin we performed two sets of interviews and rewrote parts of their codebase. The first set of interviews identified developer requirements and the second set of interviews showcased the Kotlin language and its potential use in their codebase. The results show that Kotlin can meet most of the developer requirements and that the perception of Kotlin is positive. Kotlin’s ability to be incrementally adopted was a prominent feature which reduced the inherent risks of technology adoption while providing them the ability to further evaluate the language. The expressiveness of a programming language has previously been found to be a prominent factor of language adoption. In this study, we identified the expressive nature of Kotlin as a major factor of its adoption potential. Keywords: Kotlin, Language Adoption, Developer Experience, Java, Code Migration Acknowledgements A big thank you to my research partner InfoCaption AB which has been ideal in their cooperation. They’ve been enthusiastic, open to critique and has in a self-aware way provided technical and social insights. Table of contents 1. Introduction ................................................................................................................. 1 1.1 Background ........................................................................................................................ 1 1.2 Problem and research questions ......................................................................................... 3 1.3 Purpose.............................................................................................................................. 3 1.4 Constraints ......................................................................................................................... 3 2. Theory .......................................................................................................................... 4 2.1 Unhappiness of Software Developers .................................................................................. 4 2.2 Empirical Analysis of Programming Language Adoption ....................................................... 5 2.2.1 Power Law ............................................................................................................................. 5 2.2.2 Intrinsic features ................................................................................................................... 5 2.2.3 Forgetfulness ......................................................................................................................... 5 2.2.4 Expressiveness ....................................................................................................................... 5 2.2.5 Motivation for selecting languages ....................................................................................... 5 2.2.6 Valued features ..................................................................................................................... 5 2.2.7 Learning ................................................................................................................................. 5 2.3 Stack Overflow developer survey ........................................................................................ 6 2.3.1 Developer roles ..................................................................................................................... 6 2.3.2 Most popular programming, scripting and markup languages ............................................. 6 2.3.3 Most loved, dreaded and wanted ......................................................................................... 7 2.4 Programming Language Use in US Academia and Industry ................................................... 8 3. Kotlin as a language ...................................................................................................... 9 3.1 Selling points ...................................................................................................................... 9 3.2 Apparent syntax differences ............................................................................................. 10 3.3 Variables .......................................................................................................................... 10 3.3.1 Immutable variables ............................................................................................................ 10 3.3.2 Mutable variable ................................................................................................................. 10 3.3.3 String templates and string literals ..................................................................................... 10 3.4 Functions definitions ........................................................................................................ 11 3.5 Classes and objects ........................................................................................................... 12 3.5.1 Basic classes ........................................................................................................................ 12 3.5.2 With constructor ................................................................................................................. 12 3.5.3 With default parameters ..................................................................................................... 12 3.5.4 Getter and setters ............................................................................................................... 12 3.5.5 POJO and DTO ..................................................................................................................... 13 3.5.6 Inheritance .......................................................................................................................... 13 3.5.7 Singletons ............................................................................................................................ 13 3.6 Extension functions .......................................................................................................... 13 3.7 Null safety ........................................................................................................................ 14 3.8 Miscellaneous convenient features ................................................................................... 15 3.8.1 Use of classes with same name ........................................................................................... 15 3.8.2 Smart casting ....................................................................................................................... 15 4. Method ...................................................................................................................... 16 4.1 Research strategy ............................................................................................................. 16 4.2 Data generation ............................................................................................................... 17 4.2.1 Literature review ................................................................................................................. 17 4.2.2 Informal interview ............................................................................................................... 18 4.2.3 Code introduction and document studies........................................................................... 18 4.2.4 Interviews ............................................................................................................................ 18 4.3 Analysis and execution ..................................................................................................... 19 4.3.1 Summarization and visualization ........................................................................................ 19 4.4 Interview design ............................................................................................................... 20 4.4.1 Pre-interview ....................................................................................................................... 21 4.4.2 Post-interview ..................................................................................................................... 22 4.5 Interviewees ...................................................................................................................