SlideShare uma empresa Scribd logo
1 de 28
Baixar para ler offline
Kotlin pour Android
Macha DA COSTA
! macha@chillcoding.com
#DMCA 22
29 mars 2018
" Kotlin pour Android
 I/O $ 17-19 Mai 2017
2
% Annonce du langage Kotlin
" Kotlin pour Android
A. Pourquoi Kotlin ?
B. Kotlin VS Java
C. Principaux Concepts
Retour d’Expérience
3
" Pourquoi Kotlin ?
4
"
" Pourquoi Kotlin ?
♥ Android et Java
5
" ♥+ =
JVM (
" Pourquoi Kotlin ?
) L’histoire de Java
6
* +
$ 1995 $ 2009
,
"
$ 2015
" Pourquoi Kotlin ?
) L’histoire de Kotlin
7
" Pourquoi Kotlin ?
- Kotlin né en 2011
8
" Pourquoi Kotlin ?
- Kotlin en bref
9
♥
"
LANGAGE POO (B)
&
FONCTIONNEL (C)
" Kotlin VS Java
10
CONCEPT DE
LANGAGE POO
" Kotlin VS Java
- Langage Minimaliste
11
. Langage clair et concis
; / 0
getter/setter
Log.i(TAG, "my width is $mWidth”)
Boilerplate / Lambdas
" Kotlin VS Java
- Rien n’est nulle
12
. Affranchissement du NullPointerException
" 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
" 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
" Kotlin VS Java
- Kotlin = Java
15
. Types
. Opérateurs
. Classe
. Propriété
. Object companion
. Fonction
. Héritage
" Principaux Concepts
16
CONCEPT DE
LANGAGE FONCTIONNEL
" Principaux Concepts
- Kotlin en bref
17
. Cohabitation Java & Kotlin
. Conversion automatique
.java : Ctrl C / .kt : Ctrl V
‘Code’ > ‘Convert Java File to Kotlin File’
(Command + Option + Shift + K)
" Principaux Concepts
. Lambdas
18
view.setOnClickListener { toast("hello") }
view.setOnClickListener ( object : OnClickListener {
override fun onClick(v: View) {
toast("hello")
}
})
. Signature
fun setOnClickListener(listener: (view: View) -> Unit){}
Référence [7] : https://antonioleiva.com/lambdas-kotlin/
" 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/
" Principaux Concepts
. Délégué
20
"
Kotlin for Android
Préférence Utilisateur avec Délégué2
" Principaux Concepts
. Ce n’est pas simple
21
" Retour d’expérience
22
P
E
R
F
O
R
M
A
N
C
E
TEMPS# Désapprentissage
du Java
# Puissance du Fonctionnel
# Null
# Anko
# (" +  = ♥ )
DIFFICULT ROADS
OFTEN
LEAD TO
BEAUTIFUL
DESTINATIONS.
¡ Merci, Thank you, Obrigada, Gracias, Sawadica !
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
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
Sources
# Type Kotlin
• https://code.tutsplus.com/tutorials/kotlin-from-scratch-
variables-basic-types-arrays-type-inference-and-
comments--cms-29328
• https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/
index.html
• http://kotlinlang.org/docs/reference/basic-
types.html#arrays
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)

Mais conteúdo relacionado

Semelhante a Kotlin pour Android

20131024 qualité de code et sonar - mug lyon
20131024   qualité de code et sonar - mug lyon20131024   qualité de code et sonar - mug lyon
20131024 qualité de code et sonar - mug lyon
Clement Bouillier
 
Working effectively with legacy code
Working effectively with legacy codeWorking effectively with legacy code
Working effectively with legacy code
Mathieu Gandin
 
Du JavaScript propre ? Challenge accepted ! @Devoxx France 2013
Du JavaScript propre ? Challenge accepted ! @Devoxx France 2013Du JavaScript propre ? Challenge accepted ! @Devoxx France 2013
Du JavaScript propre ? Challenge accepted ! @Devoxx France 2013
Julien Jakubowski
 

Semelhante a Kotlin pour Android (20)

meetup - Workflow complet de CI/CD pour les geeks avec gitlab et kubernetes
meetup - Workflow complet de CI/CD pour les geeks avec gitlab et kubernetesmeetup - Workflow complet de CI/CD pour les geeks avec gitlab et kubernetes
meetup - Workflow complet de CI/CD pour les geeks avec gitlab et kubernetes
 
Paris Web 2015 - Atelier desendettement javascript
Paris Web 2015 - Atelier desendettement javascriptParis Web 2015 - Atelier desendettement javascript
Paris Web 2015 - Atelier desendettement javascript
 
20131024 qualité de code et sonar - mug lyon
20131024   qualité de code et sonar - mug lyon20131024   qualité de code et sonar - mug lyon
20131024 qualité de code et sonar - mug lyon
 
Presentation Drupal 8 au DrupalCamp Paris 2013
Presentation Drupal 8 au DrupalCamp Paris 2013Presentation Drupal 8 au DrupalCamp Paris 2013
Presentation Drupal 8 au DrupalCamp Paris 2013
 
Php 100k
Php 100kPhp 100k
Php 100k
 
Kotlin arrowkt
Kotlin arrowktKotlin arrowkt
Kotlin arrowkt
 
Paris Web 2015 - Atelier désendettement Javascript legacy
Paris Web 2015 - Atelier désendettement Javascript legacyParis Web 2015 - Atelier désendettement Javascript legacy
Paris Web 2015 - Atelier désendettement Javascript legacy
 
.NET Core - Mug In Clermont
.NET Core - Mug In Clermont.NET Core - Mug In Clermont
.NET Core - Mug In Clermont
 
.Net pour le développeur Java - une source d'inspiration?
.Net pour le développeur Java - une source d'inspiration?.Net pour le développeur Java - une source d'inspiration?
.Net pour le développeur Java - une source d'inspiration?
 
Gradle_LyonJUG
Gradle_LyonJUGGradle_LyonJUG
Gradle_LyonJUG
 
Cobalt chez Orange Lannion, 2015
Cobalt chez Orange Lannion, 2015Cobalt chez Orange Lannion, 2015
Cobalt chez Orange Lannion, 2015
 
JUGL 2009 - Introduction Groovy/Grails
JUGL 2009 - Introduction Groovy/GrailsJUGL 2009 - Introduction Groovy/Grails
JUGL 2009 - Introduction Groovy/Grails
 
Javascript proprement
Javascript proprementJavascript proprement
Javascript proprement
 
Qualité de code et bonnes pratiques
Qualité de code et bonnes pratiquesQualité de code et bonnes pratiques
Qualité de code et bonnes pratiques
 
Working effectively with legacy code
Working effectively with legacy codeWorking effectively with legacy code
Working effectively with legacy code
 
Gradle_BordeauxJUG
Gradle_BordeauxJUGGradle_BordeauxJUG
Gradle_BordeauxJUG
 
Apéro techno node.js + AngularJS @Omnilog 2014
Apéro techno node.js + AngularJS @Omnilog 2014Apéro techno node.js + AngularJS @Omnilog 2014
Apéro techno node.js + AngularJS @Omnilog 2014
 
Introduction Kotlin
Introduction KotlinIntroduction Kotlin
Introduction Kotlin
 
VDLT - Retour DevFest 2023
VDLT - Retour DevFest 2023VDLT - Retour DevFest 2023
VDLT - Retour DevFest 2023
 
Du JavaScript propre ? Challenge accepted ! @Devoxx France 2013
Du JavaScript propre ? Challenge accepted ! @Devoxx France 2013Du JavaScript propre ? Challenge accepted ! @Devoxx France 2013
Du JavaScript propre ? Challenge accepted ! @Devoxx France 2013
 

Kotlin pour Android

  • 1. Kotlin pour Android Macha DA COSTA ! macha@chillcoding.com #DMCA 22 29 mars 2018
  • 2. " Kotlin pour Android  I/O $ 17-19 Mai 2017 2 % Annonce du langage Kotlin
  • 3. " Kotlin pour Android A. Pourquoi Kotlin ? B. Kotlin VS Java C. Principaux Concepts Retour d’Expérience 3
  • 5. " Pourquoi Kotlin ? ♥ Android et Java 5 " ♥+ = JVM (
  • 6. " Pourquoi Kotlin ? ) L’histoire de Java 6 * + $ 1995 $ 2009 , " $ 2015
  • 7. " Pourquoi Kotlin ? ) L’histoire de Kotlin 7
  • 8. " Pourquoi Kotlin ? - Kotlin né en 2011 8
  • 9. " Pourquoi Kotlin ? - Kotlin en bref 9 ♥ " LANGAGE POO (B) & FONCTIONNEL (C)
  • 10. " Kotlin VS Java 10 CONCEPT DE LANGAGE POO
  • 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
  • 16. " Principaux Concepts 16 CONCEPT DE LANGAGE FONCTIONNEL
  • 17. " Principaux Concepts - Kotlin en bref 17 . Cohabitation Java & Kotlin . Conversion automatique .java : Ctrl C / .kt : Ctrl V ‘Code’ > ‘Convert Java File to Kotlin File’ (Command + Option + Shift + K)
  • 18. " Principaux Concepts . Lambdas 18 view.setOnClickListener { toast("hello") } view.setOnClickListener ( object : OnClickListener { override fun onClick(v: View) { toast("hello") } }) . Signature fun setOnClickListener(listener: (view: View) -> Unit){} Référence [7] : https://antonioleiva.com/lambdas-kotlin/
  • 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
  • 21. " Principaux Concepts . Ce n’est pas simple 21
  • 22. " Retour d’expérience 22 P E R F O R M A N C E TEMPS# Désapprentissage du Java # Puissance du Fonctionnel # Null # Anko # (" +  = ♥ )
  • 24. ¡ Merci, Thank you, Obrigada, Gracias, Sawadica !
  • 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
  • 27. Sources # Type Kotlin • https://code.tutsplus.com/tutorials/kotlin-from-scratch- variables-basic-types-arrays-type-inference-and- comments--cms-29328 • https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/ index.html • http://kotlinlang.org/docs/reference/basic- types.html#arrays
  • 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)