John Hunt
Midmarsh Technology Limited, Marshfield, Wiltshire, UK
ISBN 978-3-030-80892-1 e-ISBN 978-3-030-80893-8
https://doi.org/10.1007/978-3-030-80893-8
The Editor(s) (if applicable) and The Author(s), under exclusive license to Springer Nature Switzerland AG 2021
This work is subject to copyright. All rights are solely and exclusively licensed by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.
The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant protective laws and regulations and therefore free for general use.
The publisher, the authors and the editors are safe to assume that the advice and information in this book are believed to be true and accurate at the date of publication. Neither the publisher nor the authors or the editors give a warranty, expressed or implied, with respect to the material contained herein or for any errors or omissions that may have been made. The publisher remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
This Springer imprint is published by the registered company Springer Nature Switzerland AG
The registered company address is: Gewerbestrasse 11, 6330 Cham, Switzerland
Preface
So you are interested in Kotlin; you are not alone! Kotlin is now the second most popular programming language on the Java Virtual Machine (JVM). Only Java is more popular, with Scala and Clojure now significantly behind Kotlin in popularity.
The aim of this book is to introduce Kotlin and Android development to those with limited programming experience via a set of examples developed as the book progresses.
As such this book is divided into five parts; Part I introduces the functional side of the Kotlin programming language, Part II develops the object-oriented features in the Kotlin language, and Part III considers collections or container data types in Kotlin. Part IV expands on this with some of the features in Kotlin that allow concurrent programs to be written. The final part of the book, Part V, introduces Android Development using Kotlin.
Some of the key aspects of this book are as follows:
It assumes very little knowledge or experience of Kotlin or programming.
It provides a basic introduction to Kotlin but expands on those to end on advanced topics such as generic types and co-routines.
Kotlins support for functional programming is presented.
Following on from introducing the basic ideas behind functional programming, the book presents how advanced functional concepts such as closures, currying and higher-order functions work in Kotlin.
The book also provides extensive coverage of object orientation and the features in Kotlin supporting classes, inheritance and interfaces.
The book includes exercises at the end of most chapters with online solutions.
Android mobile application development using Kotlin is also introduced. The focus is on the core concepts used within Android development such as Activities, Fragments and Views.
All code examples (and exercise solutions) are provided online in a GitHub repository.
Chapter Organization
Each chapter has a brief introduction, the main body of the chapter, followed by a list of (typically) online references that can be used for further reading.
Following this, there is typically an Exercises section that lists one or more exercises that build on the skills you will have learnt in that chapter.
Sample solutions to the exercises are available in a GitHub online repository that supports this book.
What You Need
You can of course just read this book; however, following the examples in this book will ensure that you get as much as possible out of the content.
For this, you will need a computer.
Kotlin is a cross platform programming language and as such you can use Kotlin on a Windows PC, a Linux box or an Apple Mac, etc. So you are not tied to a particular type of operating system; you can use whatever you have available. However you will need to install some software on that computer. At a minimum, you will need Kotlin and editor to write your programs in.
You will also need some form of editor in which to write your programs. There are numerous generic programming editors available for different operating systems with VIM on Linux, Notepad++ on Windows and Sublime Text on Windows and Macs being popular choices.
Using an integrated development environment (IDE) editor such as IntelliJ IDEA, however, will make writing and running your programs much easier.
Using an IDE
A very widely used IDE for Kotlin is IntelliJ IDEA (and for Android development its cousin the Android Studio IDE); it is not the only IDE for Kotlin by any means, but it is the most popular.
Other IDEs available for Kotlin include
Visual Studio Code: This is a very good free editor from Microsoft that has really useful features https://code.visualstudio.com .
Sublime Text is more of a text editor that color codes Kotlin; however, for a simple project it may be all you need https://www.sublimetext.com .
Eclipse with the Kotlin plugin see https://marketplace.eclipse.org/content/kotlin-plugin-eclipse .
Downloading the IntelliJ IDEA IDE
IntelliJ is provided by JetBrains who make tools for a variety of different languages. The IntelliJ IDEA IDE can be downloaded from their sitesee https://www.jetbrains.com/ . Look for the menu heading Tools and select that. You will see a long list of tools, which should include IntelliJ IDEA.
Select the IntelliJ IDEA option. The resulting page has a lot of information on it; however, you only need to select the DOWNLOAD option. Make sure that you select the operating system you use (there are options for Windows, macOS and Linux).
There are then two download options available: Professional and Community. The Professional version is charged for option while the Community version is free. For most of the work I do in Kotlin, the Community version is more than adequate, and it is therefore the version we will download and install (note with the Professional version you do get a free trial but will need to either pay for the full version at the end of the trial or reinstall the Community version at that point).
Assuming you selected the Community edition, the installer will now download, and you will be prompted to run it. Note you can ignore the request to subscribe if you want.