SlideShare a Scribd company logo
1 of 64
Hello To Kotlin
@ArbazPirwani
life begins
at the end of your
COMFORT
ZONE-Neale Donald Walsch-
Kick Start With Kotlin
Arbaz Pirwani
@arbazpirwani
Modern Language
2016 2017 2018 2019 2020
Kotlin Timeline
2016 2017 2018 2019 2020
1.0
Kotlin Timeline
2016 2017 2018 2019 2020
1.0 Google I/O: Kotlin Officially supported language for Android
Kotlin Timeline
2016 2017 2018 2019 2020
1.0
Google I/O: Kotlin Officially supported language for Android
Google I/O: Android goes Kotlin-first
Kotlin Timeline
2016 2017 2018 2019 2020
1.0
Google I/O: Kotlin Officially supported language for Android
Google I/O: Android goes Kotlin-first
Coroutines Preferred
Kotlin Timeline
Kotlin Timeline
2016 2017 2018 2019 2020
1.0
Google I/O: Kotlin Officially supported language for Android
Google I/O: Android goes Kotlin-first
You are here
Coroutines Preferred
WHY KOTLIN?
- Google Preferred Language
- Statistically typed
- Type Inference
- Developed by Jetbrains
- Concise
- 100% interoperable with Java
- Null Safety
- And many more.
I don’t like Kotlin
I Love Kotlin
Java vs Kotlin
Java to Kotlin
Multiplatform
projects
Server
Kotlin/JVM
Android
Kotlin/JVM
Browser
Kotlin/JS
iOS
Kotlin/Native
Question Of The Day
WHY DO KOTLIN AND JAVA PROGRAMMERS WEAR GLASSES?
BECAUSE THEY DON’T SEE SHARP.BECAUSE THEY DON’T SEE SHARP.
Tools For Kotlin.
https://www.jetbrains.com/idea/download/
Why Kotlin?
Expressiveness Safety
Interoperability Structured
concurrency
class MainActivity : AppCompatActivity () {
override fun onCreate(savedInstanceState: Bundle?) {
...
fab.setOnClickListener { view ->
Snackbar.make(view,
"Hello ${name.capitalize()}",
Snackbar.LENGTH_LONG).show()
}
fab.backgroundTintList = backgroundTintList
}
}
Why Kotlin?
class MainActivity : AppCompatActivity () {
override fun onCreate(savedInstanceState: Bundle?) {
...
fab.setOnClickListener { view ->
Snackbar.make(view,
"Hello ${name.capitalize()}",
Snackbar.LENGTH_LONG).show()
}
fab.backgroundTintList = backgroundTintList
}
}
Nullability in the
type system
Why Kotlin?
class MainActivity : AppCompatActivity () {
override fun onCreate(savedInstanceState: Bundle?) {
...
fab.setOnClickListener { view ->
Snackbar.make(view,
"Hello ${name.capitalize()}",
Snackbar.LENGTH_LONG).show()
}
fab.backgroundTintList = backgroundTintList
}
}
Nullability in the
type system
Lambdas
Why Kotlin?
class MainActivity : AppCompatActivity () {
override fun onCreate(savedInstanceState: Bundle?) {
...
fab.setOnClickListener { view ->
Snackbar.make(view,
"Hello ${name.capitalize()}",
Snackbar.LENGTH_LONG).show()
}
fab.backgroundTintList = backgroundTintList
}
}
Nullability in the
type system
Lambdas
Extension
functions
Why Kotlin?
class MainActivity : AppCompatActivity () {
override fun onCreate(savedInstanceState: Bundle?) {
...
fab.setOnClickListener { view ->
Snackbar.make(view,
"Hello ${name.capitalize()}",
Snackbar.LENGTH_LONG).show()
}
fab.backgroundTintList = backgroundTintList
}
}
Nullability in the
type system
Lambdas
Template
expressions
Extension
functions
Why Kotlin?
class MainActivity : AppCompatActivity () {
override fun onCreate(savedInstanceState: Bundle?) {
...
fab.setOnClickListener { view ->
Snackbar.make(view,
"Hello ${name.capitalize()}",
Snackbar.LENGTH_LONG).show()
}
fab.backgroundTintList = backgroundTintList
}
}
Nullability in the
type system
Lambdas
Template
expressions
Extension
functions
Property access
syntax for getters
and setters
Why Kotlin?
Kotlin Uptake
60% of Pro Android Developers use Kotlin
70% of Top 1000 Apps contain Kotlin code
Source: Google internal data, May 2020
● Data Classes
● Extension Methods
● Elvis Operator
● Properties
● Default Parameters
● Type Aliases
● Named Parameters
● Spread Operator
● Auto Casts
● Covariance
● Null Safety
● Operator Overloading
● Type Inference
● DSL Support
● Type-Safe Builders
● Coroutines
● String Interpolation
● Ranges
● Map Array Syntax
● Inline Functions
● Sealed Classes
● Delegation
● Destructuring
● KDoc
Coroutine
s
Coroutines
● Coroutines are like very light-weight threads
● Asynchronous programming made easy
● No callbacks
● No complex functionality
VS
Kotlin & Swift
● The syntax of Swift doesn’t just resemble that of Kotlin: in
small chunks of code there can be up to 77% string
similarity.
● At the very least, it should be noted that while Swift
appeared in 2013, Kotlin originated back in 2011. Hence,
even though comparing Kotlin to Swift (in this exact
order) can be convenient due to Swift’s earlier
introduction to a wide audience, any ‘copycat’ attitudes
towards Kotlin aren’t justified.
Kotlin & Swift
● Available on both mobile-client and back-end server
● Highly performant and statically-typed
● Kotlin also can be used for web front-end via Kotlin.JS
Swift is like Kotlin:
Hello World
Swift
print("Hello, world!")
Kotlin
println("Hello, world!")
Swift
var myVariable = 42
myVariable = 50
let myConstant = 42
Kotlin
var myVariable = 42
myVariable = 50
val myConstant = 42
Swift is like Kotlin:
Variables And Constants
Swift
let explicitDouble: Double = 42
Kotlin
val explicitDouble: Double = 42.0
Swift is like Kotlin:
Explicit Types
Swift
var shoppingList = ["catfish", "water",
"tulips", "blue paint"]
shoppingList[1] = "bottle of water"
Kotlin
val shoppingList = arrayOf("catfish", "water",
"tulips", "blue paint")
shoppingList[1] = "bottle of water"
Swift is like Kotlin:
Arrays
Swift
func greet(_ name: String,_ day: String) -> String {
return "Hello (name), today is (day)."
}
greet("Bob", "Tuesday")
Kotlin
fun greet(name: String, day: String): String {
return "Hello $name, today is $day."
}
greet("Bob", "Tuesday")
Swift is like Kotlin:
Functions
Swift
class Shape {
var numberOfSides = 0
func simpleDescription() -> String {
return "A shape with (numberOfSides) sides."
}
}
Kotlin
class Shape {
var numberOfSides = 0
fun simpleDescription()
= "A shape with $numberOfSides sides."
}
Swift is like Kotlin:
Classes
• Advantages over Java 7 are overwhelming
• Java 8 introduced
• Lambdas
• Null safety (“Optional” class)
• Default methods
• Streams API
• New Date & Time API
Java strikes back with Java 8
• Is more elegant, concise and safe
• Has more cool stuff
But even with Java 8 Kotlin still...
• Functions - definition in package or in class
• Immutable/mutable variables
• No “new” keyword
• Type inference
• No checked exceptions
• No primitive types
• No static members
Basic syntax and rules
More elegant?
• Primary constructors
• No fields, just properties
• Bean style classes easy to declare
• By default, all classes are final
Basic syntax and rules cont’d
More elegant?
• Null reference – Billion dollar mistake
• Kotlin is designed in a way that aims to eliminate NPE from our code
Null Safety
More elegant?
Tony Hoare
• Declaration-site variance
• out / in generics modifiers
• Supports use-site variance also
• No wildcard syntax, out / in used
Generics
More elegant?
MORE COOL STUFF
• Default argument values can be defined
• Arguments with default values are optional
• No more need for function overloading (almost)
• Kotlin classes can have only one constructor
• Arguments can be called by name
• When passing arguments by name ordering doesn’t matter
Default arguments and
named arguments
• Simpler “is it in range” check
• Can be used for any type that implements Comparable
• “both ends“ included
• “..” operator is translated to “rangeTo” function
• “rangeTo” function is implemented as extension function on
Comparable
• Numerical ranges can be iterated over
• In both directions and in arbitrary steps
Ranges
Ranges
• Java’s instaceof not very practical
• No !instanceof
• Meet Kotlin’s "is“
• "is" negation "!is“
• Automatic type cast when “is” evaluates true inside if / when
blocks
Pattern matching
AND MANY MORE
Resources
• https://kotlinlang.org/
• https://play.kotlinlang.org/
• http://nilhcem.com/swift-is-like-kotlin/
FreeCodeCamp.org
Android Developers
Best Kotlin Learning Resources
Arbaz Pirwani
Hello to Kotlin

More Related Content

Similar to Hello to Kotlin

Swift and Kotlin Presentation
Swift and Kotlin PresentationSwift and Kotlin Presentation
Swift and Kotlin PresentationAndrzej Sitek
 
Kotlin for Android Developers - 1
Kotlin for Android Developers - 1Kotlin for Android Developers - 1
Kotlin for Android Developers - 1Mohamed Nabil, MSc.
 
Writing Kotlin Multiplatform libraries that your iOS teammates are gonna love
Writing Kotlin Multiplatform libraries that your iOS teammates are gonna loveWriting Kotlin Multiplatform libraries that your iOS teammates are gonna love
Writing Kotlin Multiplatform libraries that your iOS teammates are gonna loveAndré Oriani
 
What's new with Kotlin - Google IO18' extended Covenant University.
What's new with Kotlin - Google IO18' extended Covenant University.What's new with Kotlin - Google IO18' extended Covenant University.
What's new with Kotlin - Google IO18' extended Covenant University.SimileoluwaAluko
 
Kotlin: Why Do You Care?
Kotlin: Why Do You Care?Kotlin: Why Do You Care?
Kotlin: Why Do You Care?intelliyole
 
Kickstarting Kotlin Culture, Part 1 - Neil Power
Kickstarting Kotlin Culture, Part 1 - Neil PowerKickstarting Kotlin Culture, Part 1 - Neil Power
Kickstarting Kotlin Culture, Part 1 - Neil PowerNeil Power
 
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
 
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
 
Basics of kotlin ASJ
Basics of kotlin ASJBasics of kotlin ASJ
Basics of kotlin ASJDSCBVRITH
 
A quick and fast intro to Kotlin
A quick and fast intro to Kotlin A quick and fast intro to Kotlin
A quick and fast intro to Kotlin XPeppers
 
Kotlin fundamentals - By: Ipan Ardian
Kotlin fundamentals - By: Ipan ArdianKotlin fundamentals - By: Ipan Ardian
Kotlin fundamentals - By: Ipan ArdianRizal Khilman
 
Kotlin Fundamentals
Kotlin Fundamentals Kotlin Fundamentals
Kotlin Fundamentals Ipan Ardian
 
Kotlin for android 2019
Kotlin for android 2019Kotlin for android 2019
Kotlin for android 2019Shady Selim
 
Android 101 - Kotlin ( Future of Android Development)
Android 101 - Kotlin ( Future of Android Development)Android 101 - Kotlin ( Future of Android Development)
Android 101 - Kotlin ( Future of Android Development)Hassan Abid
 
Summer of Tech 2017 - Kotlin/Android bootcamp
Summer of Tech 2017 - Kotlin/Android bootcampSummer of Tech 2017 - Kotlin/Android bootcamp
Summer of Tech 2017 - Kotlin/Android bootcampKai Koenig
 
Having Fun with Kotlin Android - DILo Surabaya
Having Fun with Kotlin Android - DILo SurabayaHaving Fun with Kotlin Android - DILo Surabaya
Having Fun with Kotlin Android - DILo SurabayaDILo Surabaya
 

Similar to Hello to Kotlin (20)

Swift and Kotlin Presentation
Swift and Kotlin PresentationSwift and Kotlin Presentation
Swift and Kotlin Presentation
 
Kotlin for Android Developers - 1
Kotlin for Android Developers - 1Kotlin for Android Developers - 1
Kotlin for Android Developers - 1
 
Kotlin from-scratch
Kotlin from-scratchKotlin from-scratch
Kotlin from-scratch
 
Writing Kotlin Multiplatform libraries that your iOS teammates are gonna love
Writing Kotlin Multiplatform libraries that your iOS teammates are gonna loveWriting Kotlin Multiplatform libraries that your iOS teammates are gonna love
Writing Kotlin Multiplatform libraries that your iOS teammates are gonna love
 
What's new with Kotlin - Google IO18' extended Covenant University.
What's new with Kotlin - Google IO18' extended Covenant University.What's new with Kotlin - Google IO18' extended Covenant University.
What's new with Kotlin - Google IO18' extended Covenant University.
 
Kotlin: Why Do You Care?
Kotlin: Why Do You Care?Kotlin: Why Do You Care?
Kotlin: Why Do You Care?
 
Kickstarting Kotlin Culture, Part 1 - Neil Power
Kickstarting Kotlin Culture, Part 1 - Neil PowerKickstarting Kotlin Culture, Part 1 - Neil Power
Kickstarting Kotlin Culture, Part 1 - Neil Power
 
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
 
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
 
Basics of kotlin ASJ
Basics of kotlin ASJBasics of kotlin ASJ
Basics of kotlin ASJ
 
Introduction to Kotlin
Introduction to KotlinIntroduction to Kotlin
Introduction to Kotlin
 
A quick and fast intro to Kotlin
A quick and fast intro to Kotlin A quick and fast intro to Kotlin
A quick and fast intro to Kotlin
 
Kotlin fundamentals - By: Ipan Ardian
Kotlin fundamentals - By: Ipan ArdianKotlin fundamentals - By: Ipan Ardian
Kotlin fundamentals - By: Ipan Ardian
 
Kotlin Fundamentals
Kotlin Fundamentals Kotlin Fundamentals
Kotlin Fundamentals
 
Kotlin for android 2019
Kotlin for android 2019Kotlin for android 2019
Kotlin for android 2019
 
Android 101 - Kotlin ( Future of Android Development)
Android 101 - Kotlin ( Future of Android Development)Android 101 - Kotlin ( Future of Android Development)
Android 101 - Kotlin ( Future of Android Development)
 
Koin Quickstart
Koin QuickstartKoin Quickstart
Koin Quickstart
 
Kotlin
KotlinKotlin
Kotlin
 
Summer of Tech 2017 - Kotlin/Android bootcamp
Summer of Tech 2017 - Kotlin/Android bootcampSummer of Tech 2017 - Kotlin/Android bootcamp
Summer of Tech 2017 - Kotlin/Android bootcamp
 
Having Fun with Kotlin Android - DILo Surabaya
Having Fun with Kotlin Android - DILo SurabayaHaving Fun with Kotlin Android - DILo Surabaya
Having Fun with Kotlin Android - DILo Surabaya
 

More from FatimaYousif11

More from FatimaYousif11 (15)

Day 2 react bootcamp
Day 2 react bootcampDay 2 react bootcamp
Day 2 react bootcamp
 
The concept of vector art
The concept of vector artThe concept of vector art
The concept of vector art
 
CV/resume writing
CV/resume writingCV/resume writing
CV/resume writing
 
Day 8 sketchware
Day 8  sketchwareDay 8  sketchware
Day 8 sketchware
 
Firebase
Firebase Firebase
Firebase
 
Android local databases
Android local databasesAndroid local databases
Android local databases
 
Day 5 android app code advancement
Day 5  android app code advancementDay 5  android app code advancement
Day 5 android app code advancement
 
Day 4 android bootcamp
Day 4  android bootcampDay 4  android bootcamp
Day 4 android bootcamp
 
Android app code mediator
Android app code mediatorAndroid app code mediator
Android app code mediator
 
Android App code starter
Android App code starterAndroid App code starter
Android App code starter
 
Android bootcamp-day1
Android bootcamp-day1Android bootcamp-day1
Android bootcamp-day1
 
Getting started with android development
Getting started with android developmentGetting started with android development
Getting started with android development
 
Oop
OopOop
Oop
 
Hacktoberfest slides
Hacktoberfest slidesHacktoberfest slides
Hacktoberfest slides
 
Info session about dsc
Info session  about dscInfo session  about dsc
Info session about dsc
 

Recently uploaded

Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 

Recently uploaded (20)

Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 

Hello to Kotlin

  • 2.
  • 3. life begins at the end of your COMFORT ZONE-Neale Donald Walsch-
  • 4.
  • 5. Kick Start With Kotlin Arbaz Pirwani @arbazpirwani
  • 7.
  • 8. 2016 2017 2018 2019 2020 Kotlin Timeline
  • 9. 2016 2017 2018 2019 2020 1.0 Kotlin Timeline
  • 10. 2016 2017 2018 2019 2020 1.0 Google I/O: Kotlin Officially supported language for Android Kotlin Timeline
  • 11. 2016 2017 2018 2019 2020 1.0 Google I/O: Kotlin Officially supported language for Android Google I/O: Android goes Kotlin-first Kotlin Timeline
  • 12. 2016 2017 2018 2019 2020 1.0 Google I/O: Kotlin Officially supported language for Android Google I/O: Android goes Kotlin-first Coroutines Preferred Kotlin Timeline
  • 13. Kotlin Timeline 2016 2017 2018 2019 2020 1.0 Google I/O: Kotlin Officially supported language for Android Google I/O: Android goes Kotlin-first You are here Coroutines Preferred
  • 15. - Google Preferred Language - Statistically typed - Type Inference - Developed by Jetbrains - Concise - 100% interoperable with Java - Null Safety - And many more.
  • 16. I don’t like Kotlin
  • 20.
  • 22.
  • 23. Question Of The Day WHY DO KOTLIN AND JAVA PROGRAMMERS WEAR GLASSES? BECAUSE THEY DON’T SEE SHARP.BECAUSE THEY DON’T SEE SHARP.
  • 27. class MainActivity : AppCompatActivity () { override fun onCreate(savedInstanceState: Bundle?) { ... fab.setOnClickListener { view -> Snackbar.make(view, "Hello ${name.capitalize()}", Snackbar.LENGTH_LONG).show() } fab.backgroundTintList = backgroundTintList } } Why Kotlin?
  • 28. class MainActivity : AppCompatActivity () { override fun onCreate(savedInstanceState: Bundle?) { ... fab.setOnClickListener { view -> Snackbar.make(view, "Hello ${name.capitalize()}", Snackbar.LENGTH_LONG).show() } fab.backgroundTintList = backgroundTintList } } Nullability in the type system Why Kotlin?
  • 29. class MainActivity : AppCompatActivity () { override fun onCreate(savedInstanceState: Bundle?) { ... fab.setOnClickListener { view -> Snackbar.make(view, "Hello ${name.capitalize()}", Snackbar.LENGTH_LONG).show() } fab.backgroundTintList = backgroundTintList } } Nullability in the type system Lambdas Why Kotlin?
  • 30. class MainActivity : AppCompatActivity () { override fun onCreate(savedInstanceState: Bundle?) { ... fab.setOnClickListener { view -> Snackbar.make(view, "Hello ${name.capitalize()}", Snackbar.LENGTH_LONG).show() } fab.backgroundTintList = backgroundTintList } } Nullability in the type system Lambdas Extension functions Why Kotlin?
  • 31. class MainActivity : AppCompatActivity () { override fun onCreate(savedInstanceState: Bundle?) { ... fab.setOnClickListener { view -> Snackbar.make(view, "Hello ${name.capitalize()}", Snackbar.LENGTH_LONG).show() } fab.backgroundTintList = backgroundTintList } } Nullability in the type system Lambdas Template expressions Extension functions Why Kotlin?
  • 32. class MainActivity : AppCompatActivity () { override fun onCreate(savedInstanceState: Bundle?) { ... fab.setOnClickListener { view -> Snackbar.make(view, "Hello ${name.capitalize()}", Snackbar.LENGTH_LONG).show() } fab.backgroundTintList = backgroundTintList } } Nullability in the type system Lambdas Template expressions Extension functions Property access syntax for getters and setters Why Kotlin?
  • 33. Kotlin Uptake 60% of Pro Android Developers use Kotlin 70% of Top 1000 Apps contain Kotlin code Source: Google internal data, May 2020
  • 34. ● Data Classes ● Extension Methods ● Elvis Operator ● Properties ● Default Parameters ● Type Aliases ● Named Parameters ● Spread Operator ● Auto Casts ● Covariance ● Null Safety ● Operator Overloading ● Type Inference ● DSL Support ● Type-Safe Builders ● Coroutines ● String Interpolation ● Ranges ● Map Array Syntax ● Inline Functions ● Sealed Classes ● Delegation ● Destructuring ● KDoc Coroutine s
  • 35. Coroutines ● Coroutines are like very light-weight threads ● Asynchronous programming made easy ● No callbacks ● No complex functionality
  • 36. VS
  • 37. Kotlin & Swift ● The syntax of Swift doesn’t just resemble that of Kotlin: in small chunks of code there can be up to 77% string similarity. ● At the very least, it should be noted that while Swift appeared in 2013, Kotlin originated back in 2011. Hence, even though comparing Kotlin to Swift (in this exact order) can be convenient due to Swift’s earlier introduction to a wide audience, any ‘copycat’ attitudes towards Kotlin aren’t justified.
  • 38. Kotlin & Swift ● Available on both mobile-client and back-end server ● Highly performant and statically-typed ● Kotlin also can be used for web front-end via Kotlin.JS
  • 39. Swift is like Kotlin: Hello World Swift print("Hello, world!") Kotlin println("Hello, world!")
  • 40. Swift var myVariable = 42 myVariable = 50 let myConstant = 42 Kotlin var myVariable = 42 myVariable = 50 val myConstant = 42 Swift is like Kotlin: Variables And Constants
  • 41. Swift let explicitDouble: Double = 42 Kotlin val explicitDouble: Double = 42.0 Swift is like Kotlin: Explicit Types
  • 42. Swift var shoppingList = ["catfish", "water", "tulips", "blue paint"] shoppingList[1] = "bottle of water" Kotlin val shoppingList = arrayOf("catfish", "water", "tulips", "blue paint") shoppingList[1] = "bottle of water" Swift is like Kotlin: Arrays
  • 43. Swift func greet(_ name: String,_ day: String) -> String { return "Hello (name), today is (day)." } greet("Bob", "Tuesday") Kotlin fun greet(name: String, day: String): String { return "Hello $name, today is $day." } greet("Bob", "Tuesday") Swift is like Kotlin: Functions
  • 44. Swift class Shape { var numberOfSides = 0 func simpleDescription() -> String { return "A shape with (numberOfSides) sides." } } Kotlin class Shape { var numberOfSides = 0 fun simpleDescription() = "A shape with $numberOfSides sides." } Swift is like Kotlin: Classes
  • 45. • Advantages over Java 7 are overwhelming • Java 8 introduced • Lambdas • Null safety (“Optional” class) • Default methods • Streams API • New Date & Time API Java strikes back with Java 8
  • 46. • Is more elegant, concise and safe • Has more cool stuff But even with Java 8 Kotlin still...
  • 47.
  • 48. • Functions - definition in package or in class • Immutable/mutable variables • No “new” keyword • Type inference • No checked exceptions • No primitive types • No static members Basic syntax and rules More elegant?
  • 49. • Primary constructors • No fields, just properties • Bean style classes easy to declare • By default, all classes are final Basic syntax and rules cont’d More elegant?
  • 50. • Null reference – Billion dollar mistake • Kotlin is designed in a way that aims to eliminate NPE from our code Null Safety More elegant? Tony Hoare
  • 51. • Declaration-site variance • out / in generics modifiers • Supports use-site variance also • No wildcard syntax, out / in used Generics More elegant?
  • 53. • Default argument values can be defined • Arguments with default values are optional • No more need for function overloading (almost) • Kotlin classes can have only one constructor • Arguments can be called by name • When passing arguments by name ordering doesn’t matter Default arguments and named arguments
  • 54. • Simpler “is it in range” check • Can be used for any type that implements Comparable • “both ends“ included • “..” operator is translated to “rangeTo” function • “rangeTo” function is implemented as extension function on Comparable • Numerical ranges can be iterated over • In both directions and in arbitrary steps Ranges
  • 56. • Java’s instaceof not very practical • No !instanceof • Meet Kotlin’s "is“ • "is" negation "!is“ • Automatic type cast when “is” evaluates true inside if / when blocks Pattern matching
  • 61.
  • 62. Best Kotlin Learning Resources