SlideShare una empresa de Scribd logo
1 de 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

Más contenido relacionado

La actualidad más candente

Analysing in depth work manager
Analysing in depth work managerAnalysing in depth work manager
Analysing in depth work managerbhatnagar.gaurav83
 
Kotlin Language powerpoint show file
Kotlin Language powerpoint show fileKotlin Language powerpoint show file
Kotlin Language powerpoint show fileSaurabh Tripathi
 
Core java concepts
Core java  conceptsCore java  concepts
Core java conceptsRam132
 
Kotlin InDepth Tutorial for beginners 2022
Kotlin InDepth Tutorial for beginners 2022Kotlin InDepth Tutorial for beginners 2022
Kotlin InDepth Tutorial for beginners 2022Simplilearn
 
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 Development with Kotlin course
Android Development  with Kotlin courseAndroid Development  with Kotlin course
Android Development with Kotlin courseGoogleDevelopersLeba
 
Kotlin vs Java | Edureka
Kotlin vs Java | EdurekaKotlin vs Java | Edureka
Kotlin vs Java | EdurekaEdureka!
 
Pune Flutter Presents - Flutter 101
Pune Flutter Presents - Flutter 101Pune Flutter Presents - Flutter 101
Pune Flutter Presents - Flutter 101Arif Amirani
 
Golang - Overview of Go (golang) Language
Golang - Overview of Go (golang) LanguageGolang - Overview of Go (golang) Language
Golang - Overview of Go (golang) LanguageAniruddha Chakrabarti
 
Functional programming
Functional programmingFunctional programming
Functional programmingijcd
 
Kotlin as a Better Java
Kotlin as a Better JavaKotlin as a Better Java
Kotlin as a Better JavaGarth Gilmour
 
Dart presentation
Dart presentationDart presentation
Dart presentationLucas Leal
 

La actualidad más candente (20)

Analysing in depth work manager
Analysing in depth work managerAnalysing in depth work manager
Analysing in depth work manager
 
Kotlin Language powerpoint show file
Kotlin Language powerpoint show fileKotlin Language powerpoint show file
Kotlin Language powerpoint show file
 
Dart programming language
Dart programming languageDart programming language
Dart programming language
 
Kotlin on android
Kotlin on androidKotlin on android
Kotlin on android
 
Core java concepts
Core java  conceptsCore java  concepts
Core java concepts
 
Kotlin
KotlinKotlin
Kotlin
 
Kotlin InDepth Tutorial for beginners 2022
Kotlin InDepth Tutorial for beginners 2022Kotlin InDepth Tutorial for beginners 2022
Kotlin InDepth Tutorial for beginners 2022
 
Introduction to Kotlin for Android developers
Introduction to Kotlin for Android developersIntroduction to Kotlin for Android developers
Introduction to Kotlin for Android developers
 
Android Development with Kotlin course
Android Development  with Kotlin courseAndroid Development  with Kotlin course
Android Development with Kotlin course
 
Introduction to kotlin
Introduction to kotlinIntroduction to kotlin
Introduction to kotlin
 
Kotlin vs Java | Edureka
Kotlin vs Java | EdurekaKotlin vs Java | Edureka
Kotlin vs Java | Edureka
 
Flutter introduction
Flutter introductionFlutter introduction
Flutter introduction
 
Pune Flutter Presents - Flutter 101
Pune Flutter Presents - Flutter 101Pune Flutter Presents - Flutter 101
Pune Flutter Presents - Flutter 101
 
Workmanager PPTX
Workmanager PPTXWorkmanager PPTX
Workmanager PPTX
 
Golang - Overview of Go (golang) Language
Golang - Overview of Go (golang) LanguageGolang - Overview of Go (golang) Language
Golang - Overview of Go (golang) Language
 
Functional programming
Functional programmingFunctional programming
Functional programming
 
Kotlin as a Better Java
Kotlin as a Better JavaKotlin as a Better Java
Kotlin as a Better Java
 
Kotlin
KotlinKotlin
Kotlin
 
Dart presentation
Dart presentationDart presentation
Dart presentation
 
Clean coding-practices
Clean coding-practicesClean coding-practices
Clean coding-practices
 

Similar a 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 a 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
 

Más de 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
 

Más de 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
 

Último

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
 
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
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
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
 
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
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
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
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 

Último (20)

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
 
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...
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
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
 
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...
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
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
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
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
 

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