Head First Kotlin
by Dawn Griffiths and David Griffiths
Copyright 2019 Dawn Griffiths and David Griffiths. All rights reserved.
Printed in Canada.
Published by OReilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
OReilly Media books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (.
Series Creators: | Kathy Sierra, Bert Bates |
Editor: | Jeff Bleiel |
Cover Designer: | Randy Comer |
Production Editor: | Kristen Brown |
Production Services: | Jasmine Kwityn |
Indexer: | Lucie Haskins |
Brain image on spine: | Eric Freeman |
Page Viewers: | Mum and Dad, Laura and Aisha |
Printing History:
February 2019: First Edition.
The OReilly logo is a registered trademark of OReilly Media, Inc. The Head First series designations, Head First Kotlin, and related trade dress are trademarks of OReilly Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and OReilly Media, Inc., was aware of a trademark claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and the authors assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein.
No Duck objects were harmed in the making of this book.
ISBN: 978-1-491-99669-0
[MBP]
To the brains behind Kotlin for creating such a great programming language.
Authors of Head First Kotlin
Dawn Griffiths has over 20 years experience working in the IT industry, working as a senior developer and senior software architect. She has written various books in the Head First series, including Head First Android Development. She also developed the animated video course The Agile Sketchpad with her husband, David, as a way of teaching key concepts and techniques in a way that keeps your brain active and engaged.
When Dawns not writing books or creating videos, youll find her honing her Tai Chi skills, reading, running, making bobbin lace, or cooking. She particularly enjoys spending time with her wonderful husband, David.
David Griffiths has worked as an Agile coach, a developer and a garage attendant, but not in that order. He began programming at age 12 when he saw a documentary on the work of Seymour Papert, and when he was 15, he wrote an implementation of Paperts computer language LOGO. Before writing Head First Kotlin, David wrote various other Head First books, including Head First Android Development, and created The Agile Sketchpad video course with Dawn.
When Davids not writing, coding, or coaching, he spends much of his spare time traveling with his lovely wifeand coauthorDawn.
You can follow Dawn and David on Twitter at https://twitter.com/HeadFirstKotlin.
how to use this book: Intro
Note
In this section, we answer the burning question: So why DID they put that in a book on Kotlin?
Who is this book for?
If you can answer yes to all of these:
Have you done some programming?
Do you want to learn Kotlin?
Do you prefer actually doing things and applying the stuff you learn over listening to someone in a lecture rattle on for hours on end?
this book is for you.
Note
This is NOT a reference book. Head First Kotlin is a book designed for learning, not an encyclopedia of Kotlin facts.
Who should probably back away from this book?
If you can answer yes to any of these:
Is your programming background limited to HTML only, with no scripting language experience?
(If youve done anything with looping, or if/then logic, youll do fine with this book, but HTML tagging alone might not be enough.)
Are you a kick-butt Kotlin programmer looking for a reference book?
Would you rather have your toenails pulled out by 15 screaming monkeys than learn something new? Do you believe a Kotlin book should cover everything, especially all the obscure stuff youll never use, and if it bores the reader to tears in the process, then so much the better?
this book is not for you.
Note
[Note from Marketing: this book is for anyone with a credit card or a PayPal account]
We know what youre thinking
How can this be a serious Kotlin book?
Whats with all the graphics?
Can I actually learn it this way?
Do I smell pizza?
We know what your brain is thinking
Your brain craves novelty. Its always searching, scanning, waiting for something unusual. It was built that way, and it helps you stay alive.
So what does your brain do with all the routine, ordinary, normal things you encounter? Everything it can to stop them from interfering with the brains real jobrecording things that matter. It doesnt bother saving the boring things; they never make it past the this is obviously not important filter.
How does your brain know whats important? Suppose youre out for a day hike and a tiger jumps in front of youwhat happens inside your head and body?
Neurons fire. Emotions crank up. Chemicals surge.
And thats how your brain knows
This must be important! Dont forget it!
But imagine youre at home or in a library. Its a safe, warm, tiger-free zone. Youre studying. Getting ready for an exam. Or trying to learn some tough technical topic your boss thinks will take a week, ten days at the most.
Just one problem. Your brains trying to do you a big favor. Its trying to make sure that this obviously unimportant content doesnt clutter up scarce resources. Resources that are better spent storing the really big things. Like tigers. Like the danger of fire. Like how you should never have posted those party photos on your Facebook page. And theres no simple way to tell your brain, Hey brain, thank you very much, but no matter how dull this book is, and how little Im registering on the emotional Richter scale right now, I really do want you to keep this stuff around.
Next page