SlideShare ist ein Scribd-Unternehmen logo
1 von 17
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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 
Kotlin Overview
Kotlin OverviewKotlin Overview
Kotlin OverviewEkta Raj
 
Kotlin vs Java | Edureka
Kotlin vs Java | EdurekaKotlin vs Java | Edureka
Kotlin vs Java | EdurekaEdureka!
 
Introduction to kotlin for android app development gdg ahmedabad dev fest 2017
Introduction to kotlin for android app development   gdg ahmedabad dev fest 2017Introduction to kotlin for android app development   gdg ahmedabad dev fest 2017
Introduction to kotlin for android app development gdg ahmedabad dev fest 2017Hardik Trivedi
 
Kotlin 101 for Java Developers
Kotlin 101 for Java DevelopersKotlin 101 for Java Developers
Kotlin 101 for Java DevelopersChristoph Pickl
 
Learn Java with Dr. Rifat Shahriyar
Learn Java with Dr. Rifat ShahriyarLearn Java with Dr. Rifat Shahriyar
Learn Java with Dr. Rifat ShahriyarAbir Mohammad
 
Declarative UIs with Jetpack Compose
Declarative UIs with Jetpack ComposeDeclarative UIs with Jetpack Compose
Declarative UIs with Jetpack ComposeRamon Ribeiro Rabello
 
[Webinar] Qt Test-Driven Development Using Google Test and Google Mock
[Webinar] Qt Test-Driven Development Using Google Test and Google Mock[Webinar] Qt Test-Driven Development Using Google Test and Google Mock
[Webinar] Qt Test-Driven Development Using Google Test and Google MockICS
 
Android jetpack compose | Declarative UI
Android jetpack compose | Declarative UI Android jetpack compose | Declarative UI
Android jetpack compose | Declarative UI Ajinkya Saswade
 
Kotlin Tutorial for Beginners | Kotlin Android Tutorial | Edureka
Kotlin Tutorial for Beginners | Kotlin Android Tutorial | EdurekaKotlin Tutorial for Beginners | Kotlin Android Tutorial | Edureka
Kotlin Tutorial for Beginners | Kotlin Android Tutorial | EdurekaEdureka!
 
JUnit & Mockito, first steps
JUnit & Mockito, first stepsJUnit & Mockito, first steps
JUnit & Mockito, first stepsRenato Primavera
 
Android Development with Kotlin, Part 1 - Introduction
Android Development with Kotlin, Part 1 - IntroductionAndroid Development with Kotlin, Part 1 - Introduction
Android Development with Kotlin, Part 1 - IntroductionAndreas Jakl
 
Android Development with Kotlin course
Android Development  with Kotlin courseAndroid Development  with Kotlin course
Android Development with Kotlin courseGoogleDevelopersLeba
 
Java 8 presentation
Java 8 presentationJava 8 presentation
Java 8 presentationVan Huong
 

Was ist angesagt? (20)

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
 
Kotlin Overview
Kotlin OverviewKotlin Overview
Kotlin Overview
 
Kotlin vs Java | Edureka
Kotlin vs Java | EdurekaKotlin vs Java | Edureka
Kotlin vs Java | Edureka
 
Junit
JunitJunit
Junit
 
Introduction to kotlin for android app development gdg ahmedabad dev fest 2017
Introduction to kotlin for android app development   gdg ahmedabad dev fest 2017Introduction to kotlin for android app development   gdg ahmedabad dev fest 2017
Introduction to kotlin for android app development gdg ahmedabad dev fest 2017
 
Kotlin 101 for Java Developers
Kotlin 101 for Java DevelopersKotlin 101 for Java Developers
Kotlin 101 for Java Developers
 
Kotlin on android
Kotlin on androidKotlin on android
Kotlin on android
 
Learn Java with Dr. Rifat Shahriyar
Learn Java with Dr. Rifat ShahriyarLearn Java with Dr. Rifat Shahriyar
Learn Java with Dr. Rifat Shahriyar
 
Declarative UIs with Jetpack Compose
Declarative UIs with Jetpack ComposeDeclarative UIs with Jetpack Compose
Declarative UIs with Jetpack Compose
 
[Webinar] Qt Test-Driven Development Using Google Test and Google Mock
[Webinar] Qt Test-Driven Development Using Google Test and Google Mock[Webinar] Qt Test-Driven Development Using Google Test and Google Mock
[Webinar] Qt Test-Driven Development Using Google Test and Google Mock
 
JUNit Presentation
JUNit PresentationJUNit Presentation
JUNit Presentation
 
Android jetpack compose | Declarative UI
Android jetpack compose | Declarative UI Android jetpack compose | Declarative UI
Android jetpack compose | Declarative UI
 
Kotlin Tutorial for Beginners | Kotlin Android Tutorial | Edureka
Kotlin Tutorial for Beginners | Kotlin Android Tutorial | EdurekaKotlin Tutorial for Beginners | Kotlin Android Tutorial | Edureka
Kotlin Tutorial for Beginners | Kotlin Android Tutorial | Edureka
 
JUnit & Mockito, first steps
JUnit & Mockito, first stepsJUnit & Mockito, first steps
JUnit & Mockito, first steps
 
Android Development with Kotlin, Part 1 - Introduction
Android Development with Kotlin, Part 1 - IntroductionAndroid Development with Kotlin, Part 1 - Introduction
Android Development with Kotlin, Part 1 - Introduction
 
Lazy java
Lazy javaLazy java
Lazy java
 
Kotlin
KotlinKotlin
Kotlin
 
Android Development with Kotlin course
Android Development  with Kotlin courseAndroid Development  with Kotlin course
Android Development with Kotlin course
 
JUnit Presentation
JUnit PresentationJUnit Presentation
JUnit Presentation
 
Java 8 presentation
Java 8 presentationJava 8 presentation
Java 8 presentation
 

Ähnlich wie 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
 
Introduction to Kotlin for Android developers
Introduction to Kotlin for Android developersIntroduction to Kotlin for Android developers
Introduction to Kotlin for Android developersMohamed Wael
 
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
 

Ähnlich wie 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
 
Introduction to Kotlin for Android developers
Introduction to Kotlin for Android developersIntroduction to Kotlin for Android developers
Introduction to Kotlin for Android developers
 
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
 

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...Akihiro Suda
 

Kürzlich hochgeladen (20)

Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
 

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