SlideShare a Scribd company logo
Who am I?
 Corneliu Balaban
 Mobile Engineering Manager @ Avira Romania
 Android aficionado with BI background
 Catching up on the “Kotlin for iOS” – Swift
 Passionate about BioMedical and AgriTech
What is this …
Kotlin?
 It is a Russian Island close
to St. Petersburg
 Initially belong to Sweden
but after Russia annexed it
and …
 Inspired the name for a new
programming language
running in the JVM
 Created by JetBrains,
creators of PhpStorm,
WebStorm, PyCharm etc
 Ads small overhead to the
Android dev env and dex
method count increase by
~6k methods
What have we
been missing
inJava?
 No need for functional interfaces in order to implement own
higher functions and lambda’s
 Embedded lists iterators and mapping functions
 Class extensions (well… Swift has them)
 Strongly typed with inferred data types
 No elegant ways of avoiding NPE’s
Basic Kotlin
syntax
fun sayHello(name: String): Unit {
print("Hello ${name}!" + "Welcome to Bucharest Mobile Meetup");
}
OR
fun sayHello(name: String): Unit = print("Hello ${name}!" + "Welcome to Bucharest
Mobile Meetup");
OR
fun sayHello(name: String) = print("Hello ${name}!" + "Welcome to Bucharest
Mobile Meetup");
OOP concepts
Kotlin classes
 Inherit from Java’s equivalent of Object  Any
 By default are final
 Inheritance is enabled by prefixing the class with "open"
 Primary constructor is embedded in the class signature . It cannot
contain any code
 Secondary constructors are available. Need to delegate to primary
constructor
 init() methods come to the rescue
 Immutable variables are represented by the prefix "val" and can have
inferred data type
OOP concepts
Good ol' "bean"
 Easily accessible via "data classes"
 Makes a good separation of code if you want some objects that just
need to hold data
 Can make use of companion objects to hold “static” values
MoreOOP …
 Java developers love to be "static"
 Bad luck, there are no class level methods
 "Companion objects" are the new black
 Used to replicate "statics" behavior in Kotlin
 Can be one per class
 Static variables are not available other than via " companion
objects
var, val … do I
need to know
them?
 Immutable objects/ variables are prefixed with "val"
 Can be initialized at declaration time. No data type needed as
inference works as a charm
 If they cannot be initialized at declaration time then data type is
mandatory
 Are there other kinds of immutable objects?
 var toDoList1: List<ToDoModel> = listOf(ToDoModel(name="Buy
Milk"),ToDoModel(name="Buy Weed"));
• var toDoList: MutableList<ToDoModel> = mutableListOf()
If val reffers to
immutable, do
I have project
level constants
 Compile time constants are defined using
the prefix "const”
 Cannot have a custom getter
 Can be used in annotations
 Can only be of type String or another
primitive
 Can or cannot be part of a class/ object
 Immutable and mutable properties have intrinsic get and set methods
 You can customize the visibility of the setter and or getter as well as their
behavior
 Since properties need to be assigned values at compile time, the only
way to define properties that can receive runtime values is by using the
prefix "lateinit"
Optionals &
null safe
accessors
 Swift has them so why not Kotlin as well
 They are some weird implementation of Schroedingers cat
 Optional properties can contain a value or can be null
 Methods can return optionals as well
• To access potentially null variables/ objects you
can use ?.
• In chaining if at least one of the conditions
is null then the entire chained expression is
null
Loops,
operator
overloading
and string
interpolation
 Iterating collections is easier with " for – in " loops . No more of the
Java " for – each" nightmare
 Range loops are introduces to help us run code for exact number
of times " for i in 1 .. 27"
 Operator overloading has been made available yet by another
language running on top on the JVM ( as did Groovy)
 String templates and interpolations are yet another valuable
Lambdas and
higher order
functions
 Introduced in Java 8 but cumbersome to use.Why?
 Cumbersome to introduce as functional interfaces are needed
 Not backwards compatible
 Not really useful for Android developers as we are still stuck on Java
7
 Lambdas are natively supported by Kotlin
 Kotlin allows methods that can receive other functions as
parameters
 Also it allows the existence of functions outside classes which is
perfect for utils
Extensions
 Imagine that "String" would have an … ”getGreetingById" method
 Extensions can be used to add custom methods to existing objects
 They can be called as : Object. getGreetingById(1)
 Very similar to Swift extensions
Useful
resources
 Must try the "anko" library: https://github.com/Kotlin/anko
 Get dirty with Kotlin Koans here:
http://try.kotlinlang.org/#/Kotlin%20Koans/Introduction/Strings/T
ask.kt
 Try reading Antonio Leiva's Kotlin book:
https://leanpub.com/kotlin-for-android-developers
Oh, and one
more thing …
adding Kotlin
to your project
 Not going through all the steps ;)
 Check them here:
https://blog.jetbrains.com/kotlin/2013/08/working-with-kotlin-in-
android-studio/
Q &A

More Related Content

What's hot

Introduction to Kotlin Language and its application to Android platform
Introduction to Kotlin Language and its application to Android platformIntroduction to Kotlin Language and its application to Android platform
Introduction to Kotlin Language and its application to Android platformEastBanc Tachnologies
 
Introduction to Koltin for Android Part I
Introduction to Koltin for Android Part I Introduction to Koltin for Android Part I
Introduction to Koltin for Android Part I Atif AbbAsi
 
Introduction to kotlin and OOP in Kotlin
Introduction to kotlin and OOP in KotlinIntroduction to kotlin and OOP in Kotlin
Introduction to kotlin and OOP in Kotlinvriddhigupta
 
Kotlin for Android Development
Kotlin for Android DevelopmentKotlin for Android Development
Kotlin for Android DevelopmentSpeck&Tech
 
Kotlin InDepth Tutorial for beginners 2022
Kotlin InDepth Tutorial for beginners 2022Kotlin InDepth Tutorial for beginners 2022
Kotlin InDepth Tutorial for beginners 2022Simplilearn
 
Coroutines in Kotlin
Coroutines in KotlinCoroutines in Kotlin
Coroutines in KotlinAlexey Soshin
 
Android Jetpack Compose - Turkey 2021
Android Jetpack Compose - Turkey 2021Android Jetpack Compose - Turkey 2021
Android Jetpack Compose - Turkey 2021Nelson Glauber Leal
 
Jetpack Compose.pptx
Jetpack Compose.pptxJetpack Compose.pptx
Jetpack Compose.pptxGDSCVJTI
 
Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Mr. Akaash
 
Android jetpack compose | Declarative UI
Android jetpack compose | Declarative UI Android jetpack compose | Declarative UI
Android jetpack compose | Declarative UI Ajinkya Saswade
 
Coroutines for Kotlin Multiplatform in Practise
Coroutines for Kotlin Multiplatform in PractiseCoroutines for Kotlin Multiplatform in Practise
Coroutines for Kotlin Multiplatform in PractiseChristian Melchior
 
Introduction to Kotlin for Android developers
Introduction to Kotlin for Android developersIntroduction to Kotlin for Android developers
Introduction to Kotlin for Android developersMohamed Wael
 
Android MVVM architecture using Kotlin, Dagger2, LiveData, MediatorLiveData
Android MVVM architecture using Kotlin, Dagger2, LiveData, MediatorLiveDataAndroid MVVM architecture using Kotlin, Dagger2, LiveData, MediatorLiveData
Android MVVM architecture using Kotlin, Dagger2, LiveData, MediatorLiveDataWaheed Nazir
 
Introduction to Kotlin coroutines
Introduction to Kotlin coroutinesIntroduction to Kotlin coroutines
Introduction to Kotlin coroutinesRoman Elizarov
 

What's hot (20)

Introduction to Kotlin Language and its application to Android platform
Introduction to Kotlin Language and its application to Android platformIntroduction to Kotlin Language and its application to Android platform
Introduction to Kotlin Language and its application to Android platform
 
Android with kotlin course
Android with kotlin courseAndroid with kotlin course
Android with kotlin course
 
Introduction to Koltin for Android Part I
Introduction to Koltin for Android Part I Introduction to Koltin for Android Part I
Introduction to Koltin for Android Part I
 
Introduction to kotlin and OOP in Kotlin
Introduction to kotlin and OOP in KotlinIntroduction to kotlin and OOP in Kotlin
Introduction to kotlin and OOP in Kotlin
 
Kotlin for Android Development
Kotlin for Android DevelopmentKotlin for Android Development
Kotlin for Android Development
 
Kotlin InDepth Tutorial for beginners 2022
Kotlin InDepth Tutorial for beginners 2022Kotlin InDepth Tutorial for beginners 2022
Kotlin InDepth Tutorial for beginners 2022
 
Kotlin on android
Kotlin on androidKotlin on android
Kotlin on android
 
Kotlin - Better Java
Kotlin - Better JavaKotlin - Better Java
Kotlin - Better Java
 
Coroutines in Kotlin
Coroutines in KotlinCoroutines in Kotlin
Coroutines in Kotlin
 
Android Jetpack Compose - Turkey 2021
Android Jetpack Compose - Turkey 2021Android Jetpack Compose - Turkey 2021
Android Jetpack Compose - Turkey 2021
 
Jetpack Compose.pptx
Jetpack Compose.pptxJetpack Compose.pptx
Jetpack Compose.pptx
 
Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...
 
Java vs kotlin
Java vs kotlin Java vs kotlin
Java vs kotlin
 
Android jetpack compose | Declarative UI
Android jetpack compose | Declarative UI Android jetpack compose | Declarative UI
Android jetpack compose | Declarative UI
 
Kotlin
KotlinKotlin
Kotlin
 
Coroutines for Kotlin Multiplatform in Practise
Coroutines for Kotlin Multiplatform in PractiseCoroutines for Kotlin Multiplatform in Practise
Coroutines for Kotlin Multiplatform in Practise
 
Introduction to Kotlin for Android developers
Introduction to Kotlin for Android developersIntroduction to Kotlin for Android developers
Introduction to Kotlin for Android developers
 
Android MVVM architecture using Kotlin, Dagger2, LiveData, MediatorLiveData
Android MVVM architecture using Kotlin, Dagger2, LiveData, MediatorLiveDataAndroid MVVM architecture using Kotlin, Dagger2, LiveData, MediatorLiveData
Android MVVM architecture using Kotlin, Dagger2, LiveData, MediatorLiveData
 
Introduction to Kotlin
Introduction to KotlinIntroduction to Kotlin
Introduction to Kotlin
 
Introduction to Kotlin coroutines
Introduction to Kotlin coroutinesIntroduction to Kotlin coroutines
Introduction to Kotlin coroutines
 

Similar to Kotlin presentation

Dear Kotliners - Java Developers are Humans too
Dear Kotliners - Java Developers are Humans tooDear Kotliners - Java Developers are Humans too
Dear Kotliners - Java Developers are Humans tooVivek Chanddru
 
Scala, Akka, and Play: An Introduction on Heroku
Scala, Akka, and Play: An Introduction on HerokuScala, Akka, and Play: An Introduction on Heroku
Scala, Akka, and Play: An Introduction on HerokuHavoc Pennington
 
Kotlin what_you_need_to_know-converted event 4 with nigerians
Kotlin  what_you_need_to_know-converted event 4 with nigeriansKotlin  what_you_need_to_know-converted event 4 with nigerians
Kotlin what_you_need_to_know-converted event 4 with nigeriansjunaidhasan17
 
Clojure and The Robot Apocalypse
Clojure and The Robot ApocalypseClojure and The Robot Apocalypse
Clojure and The Robot Apocalypseelliando dias
 
Java Closures
Java ClosuresJava Closures
Java ClosuresBen Evans
 
Scala for n00bs by a n00b.
Scala for n00bs by a n00b.Scala for n00bs by a n00b.
Scala for n00bs by a n00b.brandongulla
 
Kotlin for Android Developers - 1
Kotlin for Android Developers - 1Kotlin for Android Developers - 1
Kotlin for Android Developers - 1Mohamed Nabil, MSc.
 
Scala final ppt vinay
Scala final ppt vinayScala final ppt vinay
Scala final ppt vinayViplav Jain
 
Kevin Whinnery: Write Better JavaScript
Kevin Whinnery: Write Better JavaScriptKevin Whinnery: Write Better JavaScript
Kevin Whinnery: Write Better JavaScriptAxway Appcelerator
 
Top 10 Java Interview Questions and Answers 2014
Top 10 Java Interview Questions and Answers 2014 Top 10 Java Interview Questions and Answers 2014
Top 10 Java Interview Questions and Answers 2014 iimjobs and hirist
 
Future Programming Language
Future Programming LanguageFuture Programming Language
Future Programming LanguageYLTO
 
Scala the-good-parts
Scala the-good-partsScala the-good-parts
Scala the-good-partsFuqiang Wang
 
Scala and jvm_languages_praveen_technologist
Scala and jvm_languages_praveen_technologistScala and jvm_languages_praveen_technologist
Scala and jvm_languages_praveen_technologistpmanvi
 
Object Oriented Programming All Unit Notes
Object Oriented Programming All Unit NotesObject Oriented Programming All Unit Notes
Object Oriented Programming All Unit NotesBalamuruganV28
 
Kotlin at Team Billing
Kotlin at Team BillingKotlin at Team Billing
Kotlin at Team Billingarild2
 
Projects Valhalla and Loom at IT Tage 2021
Projects Valhalla and Loom at IT Tage 2021Projects Valhalla and Loom at IT Tage 2021
Projects Valhalla and Loom at IT Tage 2021Vadym Kazulkin
 
ObjectLayout: Closing the (last?) inherent C vs. Java speed gap
ObjectLayout: Closing the (last?) inherent C vs. Java speed gapObjectLayout: Closing the (last?) inherent C vs. Java speed gap
ObjectLayout: Closing the (last?) inherent C vs. Java speed gapAzul Systems Inc.
 

Similar to Kotlin presentation (20)

JavaCro'14 - Is there Kotlin after Java 8 – Ivan Turčinović and Igor Buzatović
JavaCro'14 - Is there Kotlin after Java 8 – Ivan Turčinović and Igor BuzatovićJavaCro'14 - Is there Kotlin after Java 8 – Ivan Turčinović and Igor Buzatović
JavaCro'14 - Is there Kotlin after Java 8 – Ivan Turčinović and Igor Buzatović
 
Dear Kotliners - Java Developers are Humans too
Dear Kotliners - Java Developers are Humans tooDear Kotliners - Java Developers are Humans too
Dear Kotliners - Java Developers are Humans too
 
Kotlin from-scratch
Kotlin from-scratchKotlin from-scratch
Kotlin from-scratch
 
Scala, Akka, and Play: An Introduction on Heroku
Scala, Akka, and Play: An Introduction on HerokuScala, Akka, and Play: An Introduction on Heroku
Scala, Akka, and Play: An Introduction on Heroku
 
scala-intro
scala-introscala-intro
scala-intro
 
Kotlin what_you_need_to_know-converted event 4 with nigerians
Kotlin  what_you_need_to_know-converted event 4 with nigeriansKotlin  what_you_need_to_know-converted event 4 with nigerians
Kotlin what_you_need_to_know-converted event 4 with nigerians
 
Clojure and The Robot Apocalypse
Clojure and The Robot ApocalypseClojure and The Robot Apocalypse
Clojure and The Robot Apocalypse
 
Java Closures
Java ClosuresJava Closures
Java Closures
 
Scala for n00bs by a n00b.
Scala for n00bs by a n00b.Scala for n00bs by a n00b.
Scala for n00bs by a n00b.
 
Kotlin for Android Developers - 1
Kotlin for Android Developers - 1Kotlin for Android Developers - 1
Kotlin for Android Developers - 1
 
Scala final ppt vinay
Scala final ppt vinayScala final ppt vinay
Scala final ppt vinay
 
Kevin Whinnery: Write Better JavaScript
Kevin Whinnery: Write Better JavaScriptKevin Whinnery: Write Better JavaScript
Kevin Whinnery: Write Better JavaScript
 
Top 10 Java Interview Questions and Answers 2014
Top 10 Java Interview Questions and Answers 2014 Top 10 Java Interview Questions and Answers 2014
Top 10 Java Interview Questions and Answers 2014
 
Future Programming Language
Future Programming LanguageFuture Programming Language
Future Programming Language
 
Scala the-good-parts
Scala the-good-partsScala the-good-parts
Scala the-good-parts
 
Scala and jvm_languages_praveen_technologist
Scala and jvm_languages_praveen_technologistScala and jvm_languages_praveen_technologist
Scala and jvm_languages_praveen_technologist
 
Object Oriented Programming All Unit Notes
Object Oriented Programming All Unit NotesObject Oriented Programming All Unit Notes
Object Oriented Programming All Unit Notes
 
Kotlin at Team Billing
Kotlin at Team BillingKotlin at Team Billing
Kotlin at Team Billing
 
Projects Valhalla and Loom at IT Tage 2021
Projects Valhalla and Loom at IT Tage 2021Projects Valhalla and Loom at IT Tage 2021
Projects Valhalla and Loom at IT Tage 2021
 
ObjectLayout: Closing the (last?) inherent C vs. Java speed gap
ObjectLayout: Closing the (last?) inherent C vs. Java speed gapObjectLayout: Closing the (last?) inherent C vs. Java speed gap
ObjectLayout: Closing the (last?) inherent C vs. Java speed gap
 

More from MobileAcademy

Questo presentation @ mobile growth meetup Bucharest
Questo presentation @ mobile growth meetup BucharestQuesto presentation @ mobile growth meetup Bucharest
Questo presentation @ mobile growth meetup BucharestMobileAcademy
 
Ludicon presentation @ mobile growth meetup Romania
Ludicon presentation @ mobile growth meetup RomaniaLudicon presentation @ mobile growth meetup Romania
Ludicon presentation @ mobile growth meetup RomaniaMobileAcademy
 
Push notifications at scale
Push notifications at scalePush notifications at scale
Push notifications at scaleMobileAcademy
 
Kotlin for Android - Vali Iorgu - mRready
Kotlin for Android - Vali Iorgu - mRreadyKotlin for Android - Vali Iorgu - mRready
Kotlin for Android - Vali Iorgu - mRreadyMobileAcademy
 
Azure for Android Developers
Azure for Android Developers Azure for Android Developers
Azure for Android Developers MobileAcademy
 
"Inspectorul Padurii" mobile app - Bogdan Micu
 "Inspectorul Padurii" mobile app - Bogdan Micu "Inspectorul Padurii" mobile app - Bogdan Micu
"Inspectorul Padurii" mobile app - Bogdan MicuMobileAcademy
 
Madalina Seghete, Branch Metrics, presentation on app virality
Madalina Seghete, Branch Metrics, presentation on  app viralityMadalina Seghete, Branch Metrics, presentation on  app virality
Madalina Seghete, Branch Metrics, presentation on app viralityMobileAcademy
 
Rares Serban, Sr. Mobile Developer at Soft to you - cross-platform development
Rares Serban, Sr. Mobile Developer at Soft to you - cross-platform developmentRares Serban, Sr. Mobile Developer at Soft to you - cross-platform development
Rares Serban, Sr. Mobile Developer at Soft to you - cross-platform developmentMobileAcademy
 
Bucharest City App presentation @MobileAcademy Meetup #2
Bucharest City App presentation @MobileAcademy Meetup #2Bucharest City App presentation @MobileAcademy Meetup #2
Bucharest City App presentation @MobileAcademy Meetup #2MobileAcademy
 

More from MobileAcademy (10)

Questo presentation @ mobile growth meetup Bucharest
Questo presentation @ mobile growth meetup BucharestQuesto presentation @ mobile growth meetup Bucharest
Questo presentation @ mobile growth meetup Bucharest
 
Ludicon presentation @ mobile growth meetup Romania
Ludicon presentation @ mobile growth meetup RomaniaLudicon presentation @ mobile growth meetup Romania
Ludicon presentation @ mobile growth meetup Romania
 
Push notifications at scale
Push notifications at scalePush notifications at scale
Push notifications at scale
 
MVVM with RxJava
MVVM with RxJavaMVVM with RxJava
MVVM with RxJava
 
Kotlin for Android - Vali Iorgu - mRready
Kotlin for Android - Vali Iorgu - mRreadyKotlin for Android - Vali Iorgu - mRready
Kotlin for Android - Vali Iorgu - mRready
 
Azure for Android Developers
Azure for Android Developers Azure for Android Developers
Azure for Android Developers
 
"Inspectorul Padurii" mobile app - Bogdan Micu
 "Inspectorul Padurii" mobile app - Bogdan Micu "Inspectorul Padurii" mobile app - Bogdan Micu
"Inspectorul Padurii" mobile app - Bogdan Micu
 
Madalina Seghete, Branch Metrics, presentation on app virality
Madalina Seghete, Branch Metrics, presentation on  app viralityMadalina Seghete, Branch Metrics, presentation on  app virality
Madalina Seghete, Branch Metrics, presentation on app virality
 
Rares Serban, Sr. Mobile Developer at Soft to you - cross-platform development
Rares Serban, Sr. Mobile Developer at Soft to you - cross-platform developmentRares Serban, Sr. Mobile Developer at Soft to you - cross-platform development
Rares Serban, Sr. Mobile Developer at Soft to you - cross-platform development
 
Bucharest City App presentation @MobileAcademy Meetup #2
Bucharest City App presentation @MobileAcademy Meetup #2Bucharest City App presentation @MobileAcademy Meetup #2
Bucharest City App presentation @MobileAcademy Meetup #2
 

Recently uploaded

Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowPeter Caitens
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTier1 app
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Shahin Sheidaei
 
Breaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdfBreaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdfMeon Technology
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Anthony Dahanne
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfAMB-Review
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024Ortus Solutions, Corp
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILNatan Silnitsky
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesGlobus
 
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...rajkumar669520
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyanic lab
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...Juraj Vysvader
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownloadvrstrong314
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamtakuyayamamoto1800
 
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...Alluxio, Inc.
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessWSO2
 
Agnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in KrakówAgnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in Krakówbim.edu.pl
 

Recently uploaded (20)

Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
Breaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdfBreaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdf
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
Agnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in KrakówAgnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in Kraków
 

Kotlin presentation

  • 1.
  • 2. Who am I?  Corneliu Balaban  Mobile Engineering Manager @ Avira Romania  Android aficionado with BI background  Catching up on the “Kotlin for iOS” – Swift  Passionate about BioMedical and AgriTech
  • 3. What is this … Kotlin?  It is a Russian Island close to St. Petersburg  Initially belong to Sweden but after Russia annexed it and …  Inspired the name for a new programming language running in the JVM  Created by JetBrains, creators of PhpStorm, WebStorm, PyCharm etc  Ads small overhead to the Android dev env and dex method count increase by ~6k methods
  • 4. What have we been missing inJava?  No need for functional interfaces in order to implement own higher functions and lambda’s  Embedded lists iterators and mapping functions  Class extensions (well… Swift has them)  Strongly typed with inferred data types  No elegant ways of avoiding NPE’s
  • 5. Basic Kotlin syntax fun sayHello(name: String): Unit { print("Hello ${name}!" + "Welcome to Bucharest Mobile Meetup"); } OR fun sayHello(name: String): Unit = print("Hello ${name}!" + "Welcome to Bucharest Mobile Meetup"); OR fun sayHello(name: String) = print("Hello ${name}!" + "Welcome to Bucharest Mobile Meetup");
  • 6. OOP concepts Kotlin classes  Inherit from Java’s equivalent of Object  Any  By default are final  Inheritance is enabled by prefixing the class with "open"  Primary constructor is embedded in the class signature . It cannot contain any code  Secondary constructors are available. Need to delegate to primary constructor  init() methods come to the rescue  Immutable variables are represented by the prefix "val" and can have inferred data type
  • 7. OOP concepts Good ol' "bean"  Easily accessible via "data classes"  Makes a good separation of code if you want some objects that just need to hold data  Can make use of companion objects to hold “static” values
  • 8. MoreOOP …  Java developers love to be "static"  Bad luck, there are no class level methods  "Companion objects" are the new black  Used to replicate "statics" behavior in Kotlin  Can be one per class  Static variables are not available other than via " companion objects
  • 9. var, val … do I need to know them?  Immutable objects/ variables are prefixed with "val"  Can be initialized at declaration time. No data type needed as inference works as a charm  If they cannot be initialized at declaration time then data type is mandatory  Are there other kinds of immutable objects?  var toDoList1: List<ToDoModel> = listOf(ToDoModel(name="Buy Milk"),ToDoModel(name="Buy Weed")); • var toDoList: MutableList<ToDoModel> = mutableListOf()
  • 10. If val reffers to immutable, do I have project level constants  Compile time constants are defined using the prefix "const”  Cannot have a custom getter  Can be used in annotations  Can only be of type String or another primitive  Can or cannot be part of a class/ object  Immutable and mutable properties have intrinsic get and set methods  You can customize the visibility of the setter and or getter as well as their behavior  Since properties need to be assigned values at compile time, the only way to define properties that can receive runtime values is by using the prefix "lateinit"
  • 11. Optionals & null safe accessors  Swift has them so why not Kotlin as well  They are some weird implementation of Schroedingers cat  Optional properties can contain a value or can be null  Methods can return optionals as well • To access potentially null variables/ objects you can use ?. • In chaining if at least one of the conditions is null then the entire chained expression is null
  • 12. Loops, operator overloading and string interpolation  Iterating collections is easier with " for – in " loops . No more of the Java " for – each" nightmare  Range loops are introduces to help us run code for exact number of times " for i in 1 .. 27"  Operator overloading has been made available yet by another language running on top on the JVM ( as did Groovy)  String templates and interpolations are yet another valuable
  • 13. Lambdas and higher order functions  Introduced in Java 8 but cumbersome to use.Why?  Cumbersome to introduce as functional interfaces are needed  Not backwards compatible  Not really useful for Android developers as we are still stuck on Java 7  Lambdas are natively supported by Kotlin  Kotlin allows methods that can receive other functions as parameters  Also it allows the existence of functions outside classes which is perfect for utils
  • 14. Extensions  Imagine that "String" would have an … ”getGreetingById" method  Extensions can be used to add custom methods to existing objects  They can be called as : Object. getGreetingById(1)  Very similar to Swift extensions
  • 15. Useful resources  Must try the "anko" library: https://github.com/Kotlin/anko  Get dirty with Kotlin Koans here: http://try.kotlinlang.org/#/Kotlin%20Koans/Introduction/Strings/T ask.kt  Try reading Antonio Leiva's Kotlin book: https://leanpub.com/kotlin-for-android-developers
  • 16. Oh, and one more thing … adding Kotlin to your project  Not going through all the steps ;)  Check them here: https://blog.jetbrains.com/kotlin/2013/08/working-with-kotlin-in- android-studio/
  • 17. Q &A