Kotlin In-Depth [Vol-I]
173 pages
English

Vous pourrez modifier la taille du texte de cet ouvrage

Découvre YouScribe en t'inscrivant gratuitement

Je m'inscris

Kotlin In-Depth [Vol-I] , livre ebook

-

Découvre YouScribe en t'inscrivant gratuitement

Je m'inscris
Obtenez un accès à la bibliothèque pour le consulter en ligne
En savoir plus
173 pages
English

Vous pourrez modifier la taille du texte de cet ouvrage

Obtenez un accès à la bibliothèque pour le consulter en ligne
En savoir plus

Description

Master the concise and expressive power of a pragmatic, multi-paradigm language for JVM, Android and beyondKey Featuresa- Language fundamentalsa- Object-oriented and functional programming with Kotlina- Kotlin standard librarya- Building domain-specific languagesa- Using Kotlin for Web developmenta- Kotlin for Android platforma- Coroutine-based concurrencyDescriptionThe purpose of this book is to guide a reader through the capabilities of Kotlin language and give examples of how to use it for the development of various applications, be it desktop, mobile or Web. Although our primary focus is on JVM and Android, the knowledge we're sharing here, to various extents, applies to other Kotlin-supported platforms such as JavaScript, native and even multi-platform applications.The book starts with an introduction to the language and its ecosystem, which will give you an understanding of the key ideas behind the Kotlin design, introduce you to the Kotlin tooling and present you the basic language syntax and constructs. In the next chapters, we get to know the multi-paradigm nature of Kotlin which allows us to create powerful abstractions by combining various aspects of functional and object-oriented programming. We'll talk about using common Kotlin APIs, such as the standard library, reflection, and coroutine-based concurrency as well as the means for creating your own flexible APIs based on domain-specific languages. In the concluding chapters, we give examples of using Kotlin for more specialized tasks, such as testing, building Android applications, Web development and creating microservices.What will you learnBy the end of the book you'll obtain a thorough knowledge of all the basic aspects of Kotlin programming. You'll be able to create a flexible and reusable code by taking advantage of object-oriented and functional features, use Kotlin standard library, compose your own domain-specific languages, write asynchronous code using Kotlin coroutines library as well. You'll also have a basic understanding of using Kotlin for writing test code, web applications and Android development. This knowledge will also give you a solid foundation for deeper learning of related development platforms, tools, and frameworks.Who this book is forThe book is primarily aimed at developers who are familiar with Java and JVM and are willing to get a firm understanding of Kotlin while having little to no experience in that language. Discussion of various language features will be accompanied, if deemed necessary, by comparisons with their Java's analogs, which should simplify the Java-to-Kotlin transition. Most of the material, however, is rather Java-agnostic and should be beneficial even without prior knowledge of Java. In general, experience in object-oriented or functional paradigm is a plus, but not required.Table of Contents1. Kotlin: Powerful and Pragmatic2. Language Fundamentals3. Defining Functions4. Working with Classes and Objects5. Leveraging Advanced Functions and Functional Programming6. Using Special-Case Classes7. Understanding Class Hierarchies8. Exploring Collections and I/O9. Generics10. Annotations and Reflection11. Domain-Specific Languages12. Java Interoperability13. Concurrency14. Testing with Kotlin15. Android Applications16. Web Development with Ktor17. Building MicroserviceAbout the AuthorAleksei Sedunov has been working as a Java developer since 2008. Since joining JetBrains in 2012, he's been actively participating in the Kotlin language development, focusing on IDE tooling for the IntelliJ platform. Currently, he's working in a DataGrip team, a JetBrains Database IDE, while carrying on with Kotlin as a main development tool.His LinkedIn Profile: https://www.linkedin.com/in/alexey-sedunov-8554a530/

Sujets

Informations

Publié par
Date de parution 31 janvier 2020
Nombre de lectures 0
EAN13 9789389328592
Langue English

Informations légales : prix de location à la page 0,0600€. Cette information est donnée uniquement à titre indicatif conformément à la législation en vigueur.

Extrait

Kotlin In-Depth
[Vol. I]

A Comprehensive Guide to Modern Multi-Paradigm Language

by
Aleksei Sedunov
FIRST EDITION 2020
Copyright © BPB Publications, India
ISBN: 978-93-89328-585
All Rights Reserved. No part of this publication may be reproduced or distributed in any form or by any means or stored in a database or retrieval system, without the prior written permission of the publisher with the exception to the program listings which may be entered, stored and executed in a computer system, but they can not be reproduced by the means of publication.
LIMITS OF LIABILITY AND DISCLAIMER OF WARRANTY
The information contained in this book is true to correct and the best of author’s & publisher’s knowledge. The author has made every effort to ensure the accuracy of these publications, but cannot be held responsible for any loss or damage arising from any information in this book.
All trademarks referred to in the book are acknowledged as properties of their respective owners.
Distributors:
BPB PUBLICATIONS
20, Ansari Road, Darya Ganj
New Delhi-110002
Ph: 23254990/23254991
MICRO MEDIA
Shop No. 5, Mahendra Chambers,
150 DN Rd. Next to Capital Cinema,
V.T. (C.S.T.) Station, MUMBAI-400 001
Ph: 22078296/22078297
DECCAN AGENCIES
4-3-329, Bank Street,
Hyderabad-500195
Ph: 24756967/24756400
BPB BOOK CENTRE
376 Old Lajpat Rai Market,
Delhi-110006
Ph: 23861747
Published by Manish Jain for BPB Publications, 20 Ansari Road, Darya Ganj, New Delhi-110002 and Printed by him at Repro India Ltd, Mumbai
Dedicated to
Tatiana, my guiding light and the incessant source of inspiration
About the Author
Aleksei Sedunov has been working as a Java developer since 2008. After joining JetBrains in 2012 he’s been actively participating in the Kotlin language development focusing on IDE tooling for the IntelliJ platform. Currently he’s working in a DataGrip team, a JetBrains Database IDE, carrying on with using Kotlin as a main development tool.
Acknowledgement
Above all others I would like to give my gratitude to the entire Kotlin team at JetBrains which has created such a beautiful language and continues to relentlessly work on its improvement – especially Andrey Breslav who’s been leading the language design from the very first day.
I’m really grateful to everyone at BPB publications for giving me this splendid opportunity for writing this book and lending a tremendous support in improving the text before it gets to the readers.
Last but not least I’d like to thank my beloved family for their support throughout the work on the book.
– Aleksei Sedunov
Preface
Since its first release in 2016 (and even long before that) Kotlin has been gaining in popularity as a powerful and flexible tool in a multitude of development tasks being equally well-equipped for dealing with mobile, desktop and server-side applications finally getting its official acknowledgment from Google in 2017 and 2018 as a primary language for Android development. This popularity is well-justified since language pragmatism, the tendency to choose the best practice among known solutions was one of the guiding principles of its design.
With the book you’re holding in your hands I’d like to invite you to the beautiful world of Kotlin programming where you can see its benefits for yourself. After completing this book you’ll have all the necessary knowledge to write in Kotlin on your own.
The first volume deals with the fundamentals of Kotlin language such as its basic syntax, procedural, object-oriented and functional programming aspects as well as the Kotlin Standard Library. The material is divided into 9 chapters organized as follows:
Chapter 1 explains key ideas behind the language design, gives an overview of the Kotlin ecosystem and tooling and guides the reader through first steps required to set up a Kotlin project in various environments.
Chapter 2 introduces the reader to the Kotlin syntax, explains how to use variables and describes simple data types such as integers or boolean values as well their built-in operations. On top of that it addresses the basics of more complex data structures such as strings and arrays.
Chapter 3 discusses the syntax of Kotlin functions and explains the uses of various control structures supported by Kotlin such as binary/multiple choice, iteration and error handling. Additionally it addresses the matter of using packages for code structuring.
Chapter 4 introduces the reader to the basic aspects of object-oriented programming in Kotlin. It explains how to create and initialize a class instance and how to control member access, describe the use of object declarations and non-trivial kinds of properties and brings up the concept of type nullability.
Chapter 5 explains the functional aspects of Kotlin and introduces the reader to the idea of higher-order and anonymous functions, addresses the uses of inline functions and explain how one can add features to existing types using extension functions and properties.
Chapter 6 explains the use of special kinds of classes tailored at specific programming tasks: data classes for simple data holders, enumerations for representing a fixed set of instances and inline classes for creating lightweight wrappers.
Chapter 7 continues the treatment of object-oriented features introduced in chapters 4 and 6 focusing on the idea of a class hierarchy. It explains how to define subclasses, how to use abstract classes and interfaces and how to restricted hierarchies using sealed classes.
Chapter 8 describes a major part of the Kotlin standard library which is concerned with various collection types and their operations as well as utilities simplifying file access and stream-based I/O.
Chapter 9 introduces the idea of generic declarations and explain how to define and use generic classes, functions and properties in Kotlin. It also explains the notion of variance and how it can be used to improve flexibility of your generic code.
Errata
We take immense pride in our work at BPB Publications and follow best practices to ensure the accuracy of our content to provide with an indulging reading experience to our subscribers. Our readers are our mirrors, and we use their inputs to reflect and improve upon human errors if any, occurred during the publishing processes involved. To let us maintain the quality and help us reach out to any readers who might be having difficulties due to any unforeseen errors, please write to us at :
errata@bpbonline.com
Your support, suggestions and feedbacks are highly appreciated by the BPB Publications’ Family.
Table of Contents
1. Kotlin: Powerful and Pragmatic
Structure
Objective
What is Kotlin?
Safe
Multiparadigm
Concise and expressive
Interoperable
Multiplatform
Kotlin Ecosystem
Coroutines
Testing
Android Development
Web Development
Desktop applications
Getting started with Kotlin
Setting up an IntelliJ project
Using REPL
Kotlin Playground
Setting up an Eclipse project
Conclusion
2. Language Fundamentals
Structure
Objective
Basic syntax
Comments
Defining a variable
Identifiers
Mutable variables
Expressions and operators
Basic types
Integer types
Floating-Point types
Arithmetic operations
Bitwise operations
Char type
Numeric conversions
Boolean type and logical operations
Comparison and equality
Strings
String templates
Basic String operations
Arrays
Constructing an array
Using arrays
Conclusion
3. Defining Functions
Structure
Objective
Functions
The Anatomy of a Kotlin Function
Positional versus named arguments
Overloading and default values
Varargs
Function scope and visibility
Packages and imports
The packages and directory structure
Using import directives
Conditionals
Making decisions with if statements
Ranges, progressions, and in operation
When statements and multiple choice
Loops
The while/do-while loop
Iterables and for loop
Changing loop control-flow: break and continue
Nested loops and labels
Tail-recursive functions
Exception handling
Throwing an exception
Handling errors with try statements
Conclusion
Questions
4. Working with Classes and Objects
Structure
Objective
Defining a class
A class anatomy
Constructors
Member visibility
Nested classes
Local classes
Nullability
Nullable types
Nullability and smart casts
Not-null assertion operator
Safe call operator
Elvis operator
Properties: beyond simple variables
Top-level properties
Late initialization
Using custom accessors
Lazy properties and delegates
Objects
Object declarations
Companion objects
Object expressions
Conclusion
Questions
5. Leveraging Advanced Functions and Functional Programming
Structure
Objective
Functional programming in Kotlin
Higher-order functions
Functional types
Lambdas and anonymous functions
Callable references
Inline functions and properties
Non-local control flow
Extensions
Extension functions
Extension properties
Companion extensions
Lambdas and functional types with receiver
Callable references with receiver
Scope functions
run / with functions
run without context
apply / also functions
Extensions as class members
Conclusion
Questions
6. Using Special-Case Classes
Structure
Objective
Enum classes
Exhaustive when expressions
Declaring enums with custom members
Using common members of enum classes
Data classes
Data classes and their operations
Destructuring declarations
Inline classes
Defining an inline class
Unsigned integers
Conclusion
Questions
7. Exploring Collections and I/O
Structure
Objective
Collections
Collection types
Iterables
Collections, Lists, and Sets
Sequences
Maps
Comparables and Comparators
Creating a Collection
Basic operations
Accessing collection elements
Collective conditions
Aggregation
Filtering
Transf

  • Univers Univers
  • Ebooks Ebooks
  • Livres audio Livres audio
  • Presse Presse
  • Podcasts Podcasts
  • BD BD
  • Documents Documents