Kotlin is an open-source programming language created by JetBrains that runs on the Java Virtual Machine (JVM) and JavaScript. JetBrains created Kotlin to have a language that cuts down codebase size and is concise while addressing issues in other languages like NullPointerExceptions. The Kotlin language supports features like single-line functions, automatic casting, non-nullable types, and lambda expressions that compile to anonymous classes. Kotlin also supports JavaScript with all language features available in Kotlin code running in Node.js and browsers.
3. What is Kotlin ?
An open source JVM targeted
language for JVM, Android & JS
4. Why JetBrains do create Kotlin?
IDEs for every language
Language that cut down the codebase
Concise language
Get ride for language issue NPE,..
5.
6. Why JetBrains do create Kotlin?
IDEs for every language
Language that cut down the codebase
Concise language
Get ride for language issues NPE,..
7. The Kotlin Language
Single line function.
Everything is expression in K
Mark return from labels
Lambda compile down to Anonymous
class
8. The Kotlin Language
Auto cast/smart cast
By default vars/types can’t have a null
value
Elvis operator
9. The less side effect you have the more
correct your program is (immutability)
- Hadi Hariri
10. JavaScript support
All language features in Kotlin 1.1
Reflection for JavaScript is not available
Dynamic types (dynamic types to
interoperate with “native” JavaScript
code)
15. Kotlin By Example @Nullable
/**
* Consumes the next line of text and returns it.
* Returns null if there are no more lines.
*/
function readUtf8Line() throw "Exception"
/**
* Consumes the next line of text and returns it.
* Returns null if there are no more lines.
*/
fun readUtf8Line(): String?
16. Kotlin By Example @Nothing
fun fail() {
throw RuntimeException("Something went wrong")
}
fun fail(): Nothing {
throw RuntimeException("Something went wrong")
}
17. Kotlin By Example @when
if (firstName.equals("Dad")) {
person.setTeam(programmers);
} else if (lastName.equals("Dihiansan")) {
person.setTeam(designers);
} else {
person.setTeam(others);
}
when {
firstName == "Dan" -> person.team = programmers
lastName == "Dihiansan" -> person.team = designers
else -> person.team = others
}
18. Kotlin By Example @when
switch (firstName) {
case "Dan": person.setTeam(programmers)
break;
case "Jay": person.setTeam(programmers)
break;
case "Jamie": person.setTeam(designers)
break;
default:
person.setTeam(others)
}
when (firstName) {
"Dan", "Jay" -> person.team = programmers
"Jamie" -> person.team = designers
else -> person.team = others
}
19. Kotlin By Example @let
if (message != null) {
System.out.println(message)
}
message?.let { println(it) }
20. Kotlin By Example @?:
if (people == null) {
people = new ArrayList();
}
return people ?: emptyArrayList()
21. if (people == null) {
people = new ArrayList();
}
return people ?: emptyArrayList()
23. Where do I begin ?
Kotlin.link — almost a complete list of links to
Kotlin projects, libraries and other resources
Kotlin Weekly — a weekly mailing list containing
latest notable news and articles
The Daily Kotlin — Daily Kotlin news and tips
Bonjour Tous le monde A prime abord je me présente je suis Abdellah SELASSI Expert Android et développeur full stack mobile.Aujourd’hui vous allez voir le magnifique langage Kotlin développé par JetBrains et qui le langage le plus préféré dans la communauté Android ainsi qu’il est officiellement reconnu par google
Voici quelque société qui utilise Kotlin
C’est quoi Kotlin ?
C'est un nouveau langage de programmation ciblant la plate-forme Java et JavaScript.
Kotlin est un langage dont le typage est statique qui vise la lisibilité du coup il est concise, pragmatique ainsi qu’il le langage a introduit un nouveau concept et qui est parmis c’est point fort : qui est l'interopérabilité avec Java et JavaScript.
Il peut être utilisé presque partout où Java & JavaScript est utilisé aujourd'hui: pour le développement côté serveur, côté client, développement Android, et bien plus encore.
Kotlin fonctionne très bien avec toutes les librairies et frameworks Java et JavaScript existants.
Kotlin vient de l'industrie, pas du milieu académique. Ce qui dit qu’il résout les problèmes rencontrés aujourd’hui par les programmeurs.
---
Statically typed programming language for the JVM, Android and the browser
Target platforms : server-side, Android, JS, anywhere Java runs
Les utilisateurs de Kotlin obtiennent encore plus: la sécurité nulle imposée par le compilateur
L'approche des langues modernes, y compris Kotlin, consiste à convertir (NullPointerException) des erreurs d'exécution en erreurs de compilation. Via le support de la nullabilité dans les types du système, le compilateur peut détecter de nombreuses erreurs possibles pendant la compilation et réduire la possibilité d'avoir des exceptions lancées au moment de l'exécution
----
Kotlin users get even more: compiler-enforced null safety
The approach of modern languages, including Kotlin, is to convert these problems (NPE) from runtime errors into compile-time errors. By supporting nullability as part of the type system, the compiler can detect many possible errors during compilation and reduce the possibility of having exceptions thrown at runtime
Les utilisateurs de Kotlin obtiennent encore plus: la sécurité nulle imposée par le compilateur
L'approche des langues modernes, y compris Kotlin, consiste à convertir (NullPointerException) des erreurs d'exécution en erreurs de compilation. Via le support de la nullabilité dans les types du système, le compilateur peut détecter de nombreuses erreurs possibles pendant la compilation et réduire la possibilité d'avoir des exceptions lancées au moment de l'exécution
----
Kotlin users get even more: compiler-enforced null safety
The approach of modern languages, including Kotlin, is to convert these problems (NPE) from runtime errors into compile-time errors. By supporting nullability as part of the type system, the compiler can detect many possible errors during compilation and reduce the possibility of having exceptions thrown at runtime
Single line function (function with no body) -> equal’s some value -> type inference -> ignore type return
Everything is expression in K -> return expression directly
Mark return from labels -> useful with lambda
Lambda compile down to Anonymous class (AC) -> AC has ref to it’s parent (K handle this think like Java 8)
Single line function (function with no body) -> equal’s some value -> type inference -> ignore type return
Lorsqu'une fonction renvoie une seule expression, les accolades peuvent être omises et le corps de la fonction deviendra après le symbole =
When a function returns a single expression, the curly braces can be omitted and the body is specified after a = symbol
La déclaration explicite du type de retour est facultative lorsque cela peut être déduit par le compilateur
--
Explicitly declaring the return type is optional when this can be inferred by the compiler