Il y a bientôt un an, Google a officialisé le support du langage Kotlin pour le développement d’application mobile Android, à la G I/O (17-19 mai 2017).
Ceci étant, pourquoi Kotlin ? Quels nouveaux concepts apporte ce langage de programmation orientée objet et fonctionnelle ? Quel est l’intérêt d'utiliser ce nouveau langage par rapport au Java ? Quels sont ses limitations et peuvent-elles nuire à son adoption ? Autant de questions auxquelles cette présentation tente de répondre, réalisée à la rencontre DMCA (Développement Mobile Côte-d'Azur) du 29 mars 2018.
11. " Kotlin VS Java
- Langage Minimaliste
11
. Langage clair et concis
; / 0
getter/setter
Log.i(TAG, "my width is $mWidth”)
Boilerplate / Lambdas
12. " Kotlin VS Java
- Rien n’est nulle
12
. Affranchissement du NullPointerException
13. " Kotlin VS Java
- Déclaration de variable
13
. Conversion de type
val width = 0
. Déclaration simplifiée
int x; / var x
static final String blabla / val blabla
14. " Kotlin VS Java
- Condition à tout faire
14
val res = when {
x in 1..10 -> "cheap"
s.contains("hello") -> "it's a welcome!"
v is ViewGroup -> "child count: ${v.getChildCount()}"
else -> ""
}
Référence [13] : https://antonioleiva.com/when-expression/
1 swith case de Java
15. " Kotlin VS Java
- Kotlin = Java
15
. Types
. Opérateurs
. Classe
. Propriété
. Object companion
. Fonction
. Héritage
19. " Principaux Concepts
. Fonction d’extension
19
• Définition : fonction que l'on définit pour une classe, en dehors de cette classe,
(elle va pouvoir être appelée comme étant une fonction de cette classe).
Référence [8] : https://antonioleiva.com/extension-functions/
20. " Principaux Concepts
. Délégué
20
"
Kotlin for Android
Préférence Utilisateur avec Délégué2
25. Lien vers la vidéo d'Introduction à Kotlin 4
! macha@chillcoding.com
+ ChillCoding
6 @MachaDaCosta
7 ChillCoding
8 ChillCoding
Des questions ?
Lien vers l'article d'Introduction à Kotlin 9
26. Sources
# Pourquoi Kotlin ?
• Apple : la fin d’Objective-C au profit de SWIFT ?
• Swift is like Kotlin
• Langage Java
• API Java : Google a enfreint les brevets d’Oracle, selon la Cour Suprême
• Antonioleiva: 12 reasons to strat Kotlin for Android
• ChillCoding : Introduction à Kotlin
# Kotlin en bref
• Kotlin: pourquoi ce nouveau langage est une bonne nouvelle
• Introduction to Kotlin Google I/O '17
• Kotlin it's the little things
• Android Development with Kotlin
# Android et Kotlin
• Android Studio 3.0 Canary
• Kotlin - Official Site
• developer.android: Get Started with Kotlin on Android
28. Sources
# Kotlin pour Android
• TRY Kotlin
• Kotlin Slides and Questions
• https://antonioleiva.com/free-kotlin-android-course/
• https://www.chillcoding.com/blog/2017/10/03/ajouter-extensions-kotlin/
• https://www.chillcoding.com/blog/2017/09/28/configurer-kotlin-projet-android/
# Bibliothèque Anko
• https://github.com/kotlin/anko
• https://www.kotlindevelopment.com/why-should-use-anko/
• https://antonioleiva.com/dialogs-android-anko-kotlin/
• AK 4 : Utiliser-anko-kotlin-android
# Fonction d’extension
• Les fonctions d'extension de Kotlin
• http://tutos-android-france.com/introduction-a-kotlin/
• Vidéo de Jake Wharton sur Kotlin (DEC 2015)
• Vidéo de Huyen Tue Dao & Christina Lee sur The Road to Kotlintown (KotlinConf 2017)