Programming Kotlin

Familiarize yourself with all of Kotlin's features with this in-depth guide
Preview in Mapt

Programming Kotlin

Stephen Samuel, Stefan Bocutiu

6 customer reviews
Familiarize yourself with all of Kotlin's features with this in-depth guide
Mapt Subscription
FREE
$29.99/m after trial
eBook
$18.00
RRP $35.99
Save 49%
Print + eBook
$44.99
RRP $44.99
What do I get with a Mapt Pro subscription?
  • Unlimited access to all Packt’s 5,000+ eBooks and Videos
  • Early Access content, Progress Tracking, and Assessments
  • 1 Free eBook or Video to download and keep every month after trial
What do I get with an eBook?
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with Print & eBook?
  • Get a paperback copy of the book delivered to you
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with a Video?
  • Download this Video course in MP4 format
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
$0.00
$18.00
$44.99
$29.99 p/m after trial
RRP $35.99
RRP $44.99
Subscription
eBook
Print + eBook
Start 30 Day Trial

Frequently bought together


Programming Kotlin Book Cover
Programming Kotlin
$ 35.99
$ 18.00
Kotlin Programming By Example Book Cover
Kotlin Programming By Example
$ 39.99
$ 28.00
Buy 2 for $35.00
Save $40.98
Add to Cart

Book Details

ISBN 139781787126367
Paperback420 pages

Book Description

Kotlin has been making waves ever since it was open sourced by JetBrains in 2011; it has been praised by developers across the world and is already being adopted by companies. This book provides a detailed introduction to Kotlin that shows you all its features and will enable you to write Kotlin code to production.

We start with the basics: get you familiar with running Kotlin code, setting up, tools, and instructions that you can use to write basic programs. Next, we cover object oriented code: functions, lambdas, and properties - all while using Kotlin's new features.

Then, we move on to null safety aspects and type parameterization. We show you how to destructure expressions and even write your own. We also take you through important topics like testing, concurrency, microservices, and a whole lot more. By the end of this book you will be able to compose different services and build your own applications.

Table of Contents

Chapter 1: Getting Started with Kotlin
Using the command line to compile and run Kotlin code
Kotlin runtime
The REPL
Kotlin for scripting
Kotlin with Gradle
Kotlin with Maven
IntelliJ and Kotlin
Eclipse and Kotlin
Mixing Kotlin and Java in a project
Summary
Chapter 2: Kotlin Basics
Vals and vars
Type inference
Basic types
Comments
Packages
Imports
String templates
Ranges
Loops
Exception handling
Instantiating classes
Referential equality and structural equality
This expression
Visibility modifiers
Control flow as expressions
Null syntax
When expression
Type hierarchy
Summary
Chapter 3: Object-Oriented Programming in Kotlin
Classes
Interfaces
Inheritance
Visibility modifiers
Abstract classes
Interface or abstract class
Polymorphism
Overriding rules
Inheritance versus composition
Class delegation
Sealed classes
Summary
Chapter 4: Functions in Kotlin
Defining functions
Single expression functions
Member functions
Local functions
Top-level functions
Named parameters
Default parameters
Extension functions
Operators
Function literals
Tail recursive functions
Varargs
Standard library functions
Generic functions
Pure functions
Java from Kotlin
Kotlin from Java
Summary
Chapter 5: Higher Order Functions and Functional Programming
Higher order functions
Closures
Anonymous functions
Function references
Function-literal receivers
Functions in the JVM
Function composition
Inline functions
Currying and partial application
Memoization
Type alias
Either
Custom DSLs
Validation and error accumulation
Summary
Chapter 6: Properties
Why use properties?
Syntax and variations
Visibility
Late initialization
Delegated properties
Lazy initializations
Lateinit versus lazy
Observables
A non-null property delegate
Properties or methods?
Summary
Chapter 7: Null Safety, Reflection, and Annotations
Nullable types
Smart cast
Safe null access
Elvis operator
Safe casting
Optionals
Reflection
Constructors
Objects and companions
Useful KClass properties
Reflective functions and properties
Annotations
Standard annotations
Runtime annotation discovery
Summary
Chapter 8: Generics
Parameterised functions
Parameterized types
Bounded polymorphism
Type variance
Nothing type
Type projection
Type erasure
Type reification
Recursive type bounds
Algebraic data types
Summary
Chapter 9: Data Classes
Automatic creation of getters and setters
The copy method
toString out of the box
hashCode and equals methods generated for you
Destructed declarations
Destructing types
Data class definition rules
Limitations
Summary
Chapter 10: Collections
Class hierarchy
Arrays
Lists
Maps
Sets
Read-only views
Indexed access
Sequences
Summary
Chapter 11: Testing in Kotlin
Getting started
Choosing a spec
Matchers
Inspectors
Interceptors
Project config
Property testing
Table-driven testing
Tags, conditions, and config
Summary
Chapter 12: Microservices with Kotlin
Definition
Drawbacks
Why microservices?
Lagom
Defining services
Implementing a Lagom service
Summary
Chapter 13: Concurrency
Threads
Deadlocks and livelocks
Executors
Race conditions
Summary

What You Will Learn

  • Use new features to write structured and readable object-oriented code
  • Find out how to use lambdas and higher order functions to write clean, reusable, and simple code
  • Write unit tests and integrate Kotlin tests with Java code in a transitioning code base
  • Write real-world production code in Kotlin in the style of microservices
  • Leverage Kotlin’s extensions to the Java collections library
  • Use destructuring expressions and find out how to write your own
  • Write code that avoids null pointer errors and see how Java-nullable code can integrate with features in a Kotlin codebase
  • Discover how to write functions in Kotlin, see the new features available, and extend existing libraries
  • Learn to write an algebraic data types and figure out when they should be used

Authors

Table of Contents

Chapter 1: Getting Started with Kotlin
Using the command line to compile and run Kotlin code
Kotlin runtime
The REPL
Kotlin for scripting
Kotlin with Gradle
Kotlin with Maven
IntelliJ and Kotlin
Eclipse and Kotlin
Mixing Kotlin and Java in a project
Summary
Chapter 2: Kotlin Basics
Vals and vars
Type inference
Basic types
Comments
Packages
Imports
String templates
Ranges
Loops
Exception handling
Instantiating classes
Referential equality and structural equality
This expression
Visibility modifiers
Control flow as expressions
Null syntax
When expression
Type hierarchy
Summary
Chapter 3: Object-Oriented Programming in Kotlin
Classes
Interfaces
Inheritance
Visibility modifiers
Abstract classes
Interface or abstract class
Polymorphism
Overriding rules
Inheritance versus composition
Class delegation
Sealed classes
Summary
Chapter 4: Functions in Kotlin
Defining functions
Single expression functions
Member functions
Local functions
Top-level functions
Named parameters
Default parameters
Extension functions
Operators
Function literals
Tail recursive functions
Varargs
Standard library functions
Generic functions
Pure functions
Java from Kotlin
Kotlin from Java
Summary
Chapter 5: Higher Order Functions and Functional Programming
Higher order functions
Closures
Anonymous functions
Function references
Function-literal receivers
Functions in the JVM
Function composition
Inline functions
Currying and partial application
Memoization
Type alias
Either
Custom DSLs
Validation and error accumulation
Summary
Chapter 6: Properties
Why use properties?
Syntax and variations
Visibility
Late initialization
Delegated properties
Lazy initializations
Lateinit versus lazy
Observables
A non-null property delegate
Properties or methods?
Summary
Chapter 7: Null Safety, Reflection, and Annotations
Nullable types
Smart cast
Safe null access
Elvis operator
Safe casting
Optionals
Reflection
Constructors
Objects and companions
Useful KClass properties
Reflective functions and properties
Annotations
Standard annotations
Runtime annotation discovery
Summary
Chapter 8: Generics
Parameterised functions
Parameterized types
Bounded polymorphism
Type variance
Nothing type
Type projection
Type erasure
Type reification
Recursive type bounds
Algebraic data types
Summary
Chapter 9: Data Classes
Automatic creation of getters and setters
The copy method
toString out of the box
hashCode and equals methods generated for you
Destructed declarations
Destructing types
Data class definition rules
Limitations
Summary
Chapter 10: Collections
Class hierarchy
Arrays
Lists
Maps
Sets
Read-only views
Indexed access
Sequences
Summary
Chapter 11: Testing in Kotlin
Getting started
Choosing a spec
Matchers
Inspectors
Interceptors
Project config
Property testing
Table-driven testing
Tags, conditions, and config
Summary
Chapter 12: Microservices with Kotlin
Definition
Drawbacks
Why microservices?
Lagom
Defining services
Implementing a Lagom service
Summary
Chapter 13: Concurrency
Threads
Deadlocks and livelocks
Executors
Race conditions
Summary

Book Details

ISBN 139781787126367
Paperback420 pages
Read More
From 6 reviews

Read More Reviews

Recommended for You

Reactive Programming in Kotlin Book Cover
Reactive Programming in Kotlin
$ 35.99
$ 25.20
Reactive Android Programming Book Cover
Reactive Android Programming
$ 31.99
$ 22.40
Mastering Android Development with Kotlin Book Cover
Mastering Android Development with Kotlin
$ 35.99
$ 18.00
Spring: Developing Java Applications for the Enterprise Book Cover
Spring: Developing Java Applications for the Enterprise
$ 67.99
$ 47.60
Python GUI Programming Cookbook - Second Edition Book Cover
Python GUI Programming Cookbook - Second Edition
$ 39.99
$ 28.00
Mastering Object-oriented Python Book Cover
Mastering Object-oriented Python
$ 26.99
$ 18.90