Kotlin Quick Start Guide
Core features to get you ready for developing applications
Marko Devcic
BIRMINGHAM - MUMBAI
Kotlin Quick Start Guide
Copyright 2018 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Commissioning Editor: Richa Tripathi
Acquisition Editor: Siddharth Mandal
Content Development Editor: Kirk Dsouza
Technical Editor: Shweta Jadhav
Copy Editor: Safis Editing
Project Coordinator: Hardik Bhinde
Proofreader: Safis Editing
Indexer: Mariammal Chettiyar
Graphics: Jason Monteiro
Production Coordinator: Deepika Naik
First published: August 2018
Production reference: 1300818
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-78934-418-9
www.packtpub.com
This book is dedicated to my son, Bruno.
Marko Devcic
mapt.io
Mapt is an online digital library that gives you full access to over 5,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website.
Why subscribe?
Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals
Improve your learning with Skill Plans built especially for you
Get a free eBook or video every month
Mapt is fully searchable
Copy and paste, print, and bookmark content
PacktPub.com
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at service@packtpub.com for more details.
At www.PacktPub.com , you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks.
Contributors
About the author
Marko Devcic is a software engineer currently working as an Android developer for an Austrian company called mySugr in Vienna. He has a master's degree in engineering from the University of Zagreb in Croatia. Over the years, he has worked with various technologies and languages, mostly C#, Java, and Kotlin.
He is passionate about technology and software development. He loves reading about programming languages.
In his spare time, he writes codes and contributes towards open source projects. You can follow him on GitHub (username deva666). He also likes to write about Kotlin, C#, and programming in general on his web page. When he is not behind a computer, he's practicing Brazilian Jiu-Jitsu or spending time with his son.
About the reviewer
Mitchell Wong Ho was born in Johannesburg, South Africa, where he completed his national diploma in electrical engineering. Mitchell's software career development started on embedded systems and then moved to Microsoft desktop/server applications. Mitchell has been programming in Java since 2000 on J2ME, JEE, desktop, and Android applications, and has more recently been advocating Kotlin for Android. Mitchell made a significant contribution to the development of the Kotlin Programming Cookbook, which was published recently by Packt.
Packt is searching for authors like you
If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea.
Preface
Kotlin is a relatively new language that is gaining popularity rapidly, thanks to its numerous unique features that increase developer productivity. It is primarily used for mobile (Android) and server-side (backend) development but can be used anywhere Java is used. Thanks to its other compiler, which transforms it into JavaScript, it can even be used for frontend web development. This book targets newcomers to the language and tries to bring them to intermediate-advanced levels of Kotlin knowledge.
Who this book is for
This book covers the basic features of the language and its syntax, so no prior knowledge of Kotlin is required. You should have at least basic knowledge of general programming. You should know what control-flow statements, variables, classes, and basic data structures are.
What this book covers
, Introducing Kotlin , covers general features of the language and shows the reader how to install an IDE and the Kotlin compiler.
, Kotlin Basics , introduces the reader to the language syntax and explores the basic building blocks of the language: functions, variables, basic types, and so on.
, Classes and Object-Oriented Programming , focuses on the object-oriented features of the language. The chapter explores classes and interfaces and how they are extended and implemented. The chapter also shows some features that are specific to Kotlin, such as objects, companion objects, and sealed classes.
, Functions and Lambdas , shows how functions are first-class citizens in Kotlin. The chapter also shows Kotlin function features that are not present in Java, such as default argument values, named parameters, and function inlining.
, Advanced Kotlin , deals with more advanced features of Kotlin, such as operator overloading, generics, receiver functions, and constructs for multi-threaded programming.
, Kotlin Standard Library , shows some really useful functions that ship with Kotlin and also explores the Collections API.
, Coding a Dictionary App with Kotlin , is the chapter where we put Kotlin into practice. We summarize our learning from previous chapters and build a desktop dictionary application.
Next page