(Go: >> BACK << -|- >> HOME <<)

SlideShare a Scribd company logo
A quick and fast intro to Kotlin
KOTLIN
● Primary target JVM
● Javascript
● Compiled in Java byte code
● Created for industry
Core goals is 100% Java interoperability.
KOTLIN main features
Concise
Drastically reduce the amount of
boilerplate code you need to write.
Safe
Avoid entire classes of errors such
as null pointer exceptions.
Interoperable
Leverage existing frameworks and
libraries of the JVM with 100% Java
Interoperability.
data class Person(
var name: String,
var surname: String,
var age: Int)
Create a POJO with:
● Getters
● Setters
● equals()
● hashCode()
● toString()
● copy()
Concise
public class Person {
final String firstName;
final String lastName;
public Person(...) {
...
}
// Getters
...
// Hashcode / equals
...
// Tostring
...
// Egh...
}
KOTLIN lambdas
● must always appear between curly brackets
● if there is a single parameter then it can be referred to by it
Concise
val list = (0..49).toList()
val filtered = list
.filter({ x -> x % 2 == 0 })
val list = (0..49).toList()
val filtered = list
.filter { it % 2 == 0 }
NULL safety
// ERROR
// OK
// OK
// ERROR
NULL safety
// ERROR
NULL safety
// ERROR
SAFE CALL
NULL safety
Extend existing classes functionality
Ability to extend a class with new functionality without having to inherit from the class
● does not modify classes
● are resolved statically
Extend existing classes functionality
fun String.lastChar() = this.charAt(this.length() - 1)
// this can be omitted
fun String.lastChar() = charAt(length() - 1)
fun use(){
Val c: Char = "abc".lastChar()
}
Everything is an expression
val max = if (a > b) a else b
val hasPrefix = when(x) {
is String -> x.startsWith("prefix")
else -> false
}
when(x) {
in 1..10 -> ...
102 -> ...
else -> ...
}
boolean hasPrefix;
if (x instanceof String)
hasPrefix = x.startsWith("prefix");
else
hasPrefix = false;
switch (month) {
case 1: ... break
case 7: ... break
default: ...
}
Default Parameters
fun foo( i :Int, s: String = "", b: Boolean = true) {}
fun usage(){
foo( 1, b = false)
}
for loop
can iterate over any type that provides an iterator implementing next() and hasNext()
for (item in collection)
print(item)
for ((index, value) in array.withIndex()) {
println("the element at $index is $value")
}
Collections
● Made easy
● distinguishes between immutable and mutable collections
val numbers: MutableList = mutableListOf(1, 2, 3)
val readOnlyNumbers: List = numbers
numbers.add(4)
println(readOnlyView) // prints "[1, 2, 3, 4]"
readOnlyNumbers.clear() // -> does not compile
Java 6
// Using R.layout.activity_main from the main source set
import kotlinx.android.synthetic.main.activity_main.*
class MyActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
textView.setText("Hello, world!")
}
}
public class MyActivity extends Activity() {
@override
void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView textView = (TextView) findViewById(R.id.textView);
textView.setText("Hello, world!");
}
}
Kotlin Android Extensions
Extension functions
fun Fragment.toast(message: CharSequence, duration: Int = Toast.LENGTH_SHORT) {
Toast.makeText(getActivity(), message, duration).show()
}
fragment.toast("Hello world!")
Activities
startActivity( intentFor< NewActivity > ("Answer" to 42) )
Intent intent = new Intent(this, NewActivity.class);
intent.putExtra("Answer", 42);
startActivity(intent);
Functional support (Lambdas)
view.setOnClickListener { toast("Hello world!") }
View view = (View) findViewById(R.id.view);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(this, "asdf", Toast.LENGTH_LONG)
.show();
}
});
Dynamic Layout
scrollView {
linearLayout(LinearLayout.VERTICAL) {
val label = textView("?")
button("Click me!") {
label.setText("Clicked!")
}
editText("Edit me!")
// codice koltin
// ...
}
}.style(...)
?
Click me!
Edit me!
Easily mixed with Java
● Do not have to convert everything at once
● You can convert little portions
● Write kotlin code over the existing Java code
Everything still works
Kotlin costs nothing to adopt
● It’s open source
● There’s a high quality, one-click Java to Kotlin converter tool
● Can use all existing Java frameworks and libraries
● It integrates with Maven, Gradle and other build systems.
● Great for Android, compiles for java 6 byte code
● Very small runtime library 924 KB
Kotlin usefull links
● A very well done documentation : Tutorial, Videos
● Kotlin Koans online
● Constantly updating in Github, kotlin-projects
● Talks: Kotlin in Action, Kotlin on Android
What Java has that Kotlin does not
https://kotlinlang.org/docs/reference/comparison-to-java.html
Primitive Types
Everything is an object
we can call member functions and properties on any variable.
What Java has that Kotlin does not
val a: Int? = 1
val b: Long? = a
print(a == b)
Primitive Types
Everything is an object
we can call member functions and properties on any variable.
What Java has that Kotlin does not
val a: Int? = 1
val b: Long? = a
print(a == b) // FALSE //
Primitive Types
Everything is an object
we can call member functions and properties on any variable.
What Java has that Kotlin does not
val b: Byte = 1
val i: Int = b
val i: Int = b.toInt()
val a: Int? = 1
val b: Long? = a
print(a == b) // FALSE //
Primitive Types
Everything is an object
we can call member functions and properties on any variable.
What Java has that Kotlin does not
val b: Byte = 1
val i: Int = b // ERROR //
val i: Int = b.toInt() // OK //
val a: Int? = 1
val b: Long? = a
print(a == b) // FALSE //
Static Members
class MyClass {
companion object Factory {
fun create(): MyClass = MyClass()
}
}
val instance = MyClass.create()
What Java has that Kotlin does not
Singleton
object MyClass {
// ....
}
Gradle Goes Kotlin
https://kotlinlang.org/docs/reference/using-gradle.html
Thank You
Erinda Jaupaj
@ErindaJaupi

More Related Content

What's hot

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
EastBanc Tachnologies
 
Coroutines in Kotlin
Coroutines in KotlinCoroutines in Kotlin
Coroutines in Kotlin
Alexey Soshin
 
Kotlin as a Better Java
Kotlin as a Better JavaKotlin as a Better Java
Kotlin as a Better Java
Garth Gilmour
 
Kotlin - Better Java
Kotlin - Better JavaKotlin - Better Java
Kotlin - Better Java
Dariusz Lorenc
 
Android with kotlin course
Android with kotlin courseAndroid with kotlin course
Android with kotlin course
Abdul Rahman Masri Attal
 
Introduction to kotlin
Introduction to kotlinIntroduction to kotlin
Introduction to kotlin
NAVER Engineering
 
Kotlin Language powerpoint show file
Kotlin Language powerpoint show fileKotlin Language powerpoint show file
Kotlin Language powerpoint show file
Saurabh Tripathi
 
Introduction to Kotlin coroutines
Introduction to Kotlin coroutinesIntroduction to Kotlin coroutines
Introduction to Kotlin coroutines
Roman Elizarov
 
Introduction to Kotlin
Introduction to KotlinIntroduction to Kotlin
Introduction to Kotlin
T.M. Ishrak Hussain
 
Kotlin vs Java | Edureka
Kotlin vs Java | EdurekaKotlin vs Java | Edureka
Kotlin vs Java | Edureka
Edureka!
 
Introduction to kotlin
Introduction to kotlinIntroduction to kotlin
Introduction to kotlin
Shaul Rosenzwieg
 
Kotlin
KotlinKotlin
Kotlin
Rory Preddy
 
Introduction to kotlin and OOP in Kotlin
Introduction to kotlin and OOP in KotlinIntroduction to kotlin and OOP in Kotlin
Introduction to kotlin and OOP in Kotlin
vriddhigupta
 
Android Development with Kotlin, Part 1 - Introduction
Android Development with Kotlin, Part 1 - IntroductionAndroid Development with Kotlin, Part 1 - Introduction
Android Development with Kotlin, Part 1 - Introduction
Andreas Jakl
 
Inline function
Inline functionInline function
Inline function
Tech_MX
 
Introduction to kotlin coroutines
Introduction to kotlin coroutinesIntroduction to kotlin coroutines
Introduction to kotlin coroutines
NAVER Engineering
 
Threading Made Easy! A Busy Developer’s Guide to Kotlin Coroutines
Threading Made Easy! A Busy Developer’s Guide to Kotlin CoroutinesThreading Made Easy! A Busy Developer’s Guide to Kotlin Coroutines
Threading Made Easy! A Busy Developer’s Guide to Kotlin Coroutines
Lauren Yew
 
Unit Testing in Kotlin
Unit Testing in KotlinUnit Testing in Kotlin
Unit Testing in Kotlin
Egor Andreevich
 
Coroutines for Kotlin Multiplatform in Practise
Coroutines for Kotlin Multiplatform in PractiseCoroutines for Kotlin Multiplatform in Practise
Coroutines for Kotlin Multiplatform in Practise
Christian Melchior
 
Kotlin
KotlinKotlin

What's hot (20)

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
 
Coroutines in Kotlin
Coroutines in KotlinCoroutines in Kotlin
Coroutines in Kotlin
 
Kotlin as a Better Java
Kotlin as a Better JavaKotlin as a Better Java
Kotlin as a Better Java
 
Kotlin - Better Java
Kotlin - Better JavaKotlin - Better Java
Kotlin - Better Java
 
Android with kotlin course
Android with kotlin courseAndroid with kotlin course
Android with kotlin course
 
Introduction to kotlin
Introduction to kotlinIntroduction to kotlin
Introduction to kotlin
 
Kotlin Language powerpoint show file
Kotlin Language powerpoint show fileKotlin Language powerpoint show file
Kotlin Language powerpoint show file
 
Introduction to Kotlin coroutines
Introduction to Kotlin coroutinesIntroduction to Kotlin coroutines
Introduction to Kotlin coroutines
 
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
 
Introduction to kotlin
Introduction to kotlinIntroduction to kotlin
Introduction to kotlin
 
Kotlin
KotlinKotlin
Kotlin
 
Introduction to kotlin and OOP in Kotlin
Introduction to kotlin and OOP in KotlinIntroduction to kotlin and OOP in Kotlin
Introduction to kotlin and OOP in Kotlin
 
Android Development with Kotlin, Part 1 - Introduction
Android Development with Kotlin, Part 1 - IntroductionAndroid Development with Kotlin, Part 1 - Introduction
Android Development with Kotlin, Part 1 - Introduction
 
Inline function
Inline functionInline function
Inline function
 
Introduction to kotlin coroutines
Introduction to kotlin coroutinesIntroduction to kotlin coroutines
Introduction to kotlin coroutines
 
Threading Made Easy! A Busy Developer’s Guide to Kotlin Coroutines
Threading Made Easy! A Busy Developer’s Guide to Kotlin CoroutinesThreading Made Easy! A Busy Developer’s Guide to Kotlin Coroutines
Threading Made Easy! A Busy Developer’s Guide to Kotlin Coroutines
 
Unit Testing in Kotlin
Unit Testing in KotlinUnit Testing in Kotlin
Unit Testing in Kotlin
 
Coroutines for Kotlin Multiplatform in Practise
Coroutines for Kotlin Multiplatform in PractiseCoroutines for Kotlin Multiplatform in Practise
Coroutines for Kotlin Multiplatform in Practise
 
Kotlin
KotlinKotlin
Kotlin
 

Similar to A quick and fast intro to Kotlin

Kotlin for Android Developers - 3
Kotlin for Android Developers - 3Kotlin for Android Developers - 3
Kotlin for Android Developers - 3
Mohamed Nabil, MSc.
 
Kotlin for Android devs
Kotlin for Android devsKotlin for Android devs
Kotlin for Android devs
Adit Lal
 
Introduction to Kotlin for Android developers
Introduction to Kotlin for Android developersIntroduction to Kotlin for Android developers
Introduction to Kotlin for Android developers
Mohamed Wael
 
What’s new in Kotlin?
What’s new in Kotlin?What’s new in Kotlin?
What’s new in Kotlin?
Squareboat
 
Kotlin- Basic to Advance
Kotlin- Basic to Advance Kotlin- Basic to Advance
Kotlin- Basic to Advance
Coder Tech
 
Kotlin: A pragmatic language by JetBrains
Kotlin: A pragmatic language by JetBrainsKotlin: A pragmatic language by JetBrains
Kotlin: A pragmatic language by JetBrains
Jigar Gosar
 
Intro to Kotlin
Intro to KotlinIntro to Kotlin
Intro to Kotlin
Magda Miu
 
Боремся с NPE вместе с Kotlin, Павел Шацких СберТех
Боремся с NPE вместе с Kotlin, Павел Шацких СберТехБоремся с NPE вместе с Kotlin, Павел Шацких СберТех
Боремся с NPE вместе с Kotlin, Павел Шацких СберТех
Сбертех | SberTech
 
Kotlin for Android - Vali Iorgu - mRready
Kotlin for Android - Vali Iorgu - mRreadyKotlin for Android - Vali Iorgu - mRready
Kotlin for Android - Vali Iorgu - mRready
MobileAcademy
 
Android Application Development (1).pptx
Android Application Development (1).pptxAndroid Application Development (1).pptx
Android Application Development (1).pptx
adityakale2110
 
Kotlin cheat sheet by ekito
Kotlin cheat sheet by ekitoKotlin cheat sheet by ekito
Kotlin cheat sheet by ekito
Arnaud Giuliani
 
KotlinForJavaDevelopers-UJUG.pptx
KotlinForJavaDevelopers-UJUG.pptxKotlinForJavaDevelopers-UJUG.pptx
KotlinForJavaDevelopers-UJUG.pptx
Ian Robertson
 
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
junaidhasan17
 
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
DILo Surabaya
 
Kotlin, smarter development for the jvm
Kotlin, smarter development for the jvmKotlin, smarter development for the jvm
Kotlin, smarter development for the jvm
Arnaud Giuliani
 
Introduction to clojure
Introduction to clojureIntroduction to clojure
Introduction to clojure
Abbas Raza
 
Kotlin
KotlinKotlin
Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...
Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...
Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...
Tudor Dragan
 
Kotlin 101 for Java Developers
Kotlin 101 for Java DevelopersKotlin 101 for Java Developers
Kotlin 101 for Java Developers
Christoph Pickl
 
Kotlin Basic & Android Programming
Kotlin Basic & Android ProgrammingKotlin Basic & Android Programming
Kotlin Basic & Android Programming
Kongu Engineering College, Perundurai, Erode
 

Similar to A quick and fast intro to Kotlin (20)

Kotlin for Android Developers - 3
Kotlin for Android Developers - 3Kotlin for Android Developers - 3
Kotlin for Android Developers - 3
 
Kotlin for Android devs
Kotlin for Android devsKotlin for Android devs
Kotlin for Android devs
 
Introduction to Kotlin for Android developers
Introduction to Kotlin for Android developersIntroduction to Kotlin for Android developers
Introduction to Kotlin for Android developers
 
What’s new in Kotlin?
What’s new in Kotlin?What’s new in Kotlin?
What’s new in Kotlin?
 
Kotlin- Basic to Advance
Kotlin- Basic to Advance Kotlin- Basic to Advance
Kotlin- Basic to Advance
 
Kotlin: A pragmatic language by JetBrains
Kotlin: A pragmatic language by JetBrainsKotlin: A pragmatic language by JetBrains
Kotlin: A pragmatic language by JetBrains
 
Intro to Kotlin
Intro to KotlinIntro to Kotlin
Intro to Kotlin
 
Боремся с NPE вместе с Kotlin, Павел Шацких СберТех
Боремся с NPE вместе с Kotlin, Павел Шацких СберТехБоремся с NPE вместе с Kotlin, Павел Шацких СберТех
Боремся с NPE вместе с Kotlin, Павел Шацких СберТех
 
Kotlin for Android - Vali Iorgu - mRready
Kotlin for Android - Vali Iorgu - mRreadyKotlin for Android - Vali Iorgu - mRready
Kotlin for Android - Vali Iorgu - mRready
 
Android Application Development (1).pptx
Android Application Development (1).pptxAndroid Application Development (1).pptx
Android Application Development (1).pptx
 
Kotlin cheat sheet by ekito
Kotlin cheat sheet by ekitoKotlin cheat sheet by ekito
Kotlin cheat sheet by ekito
 
KotlinForJavaDevelopers-UJUG.pptx
KotlinForJavaDevelopers-UJUG.pptxKotlinForJavaDevelopers-UJUG.pptx
KotlinForJavaDevelopers-UJUG.pptx
 
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
 
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
 
Kotlin, smarter development for the jvm
Kotlin, smarter development for the jvmKotlin, smarter development for the jvm
Kotlin, smarter development for the jvm
 
Introduction to clojure
Introduction to clojureIntroduction to clojure
Introduction to clojure
 
Kotlin
KotlinKotlin
Kotlin
 
Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...
Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...
Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...
 
Kotlin 101 for Java Developers
Kotlin 101 for Java DevelopersKotlin 101 for Java Developers
Kotlin 101 for Java Developers
 
Kotlin Basic & Android Programming
Kotlin Basic & Android ProgrammingKotlin Basic & Android Programming
Kotlin Basic & Android Programming
 

More from XPeppers

Yagni, You aren't gonna need it
Yagni, You aren't gonna need itYagni, You aren't gonna need it
Yagni, You aren't gonna need it
XPeppers
 
Jenkins Shared Libraries
Jenkins Shared LibrariesJenkins Shared Libraries
Jenkins Shared Libraries
XPeppers
 
The Continuous Delivery process
The Continuous Delivery processThe Continuous Delivery process
The Continuous Delivery process
XPeppers
 
How Agile Dev Teams work
How Agile Dev Teams workHow Agile Dev Teams work
How Agile Dev Teams work
XPeppers
 
The Phoenix Project: un romanzo sull'IT
The Phoenix Project: un romanzo sull'ITThe Phoenix Project: un romanzo sull'IT
The Phoenix Project: un romanzo sull'IT
XPeppers
 
Metriche per finanziare il cambiamento
Metriche per finanziare il cambiamentoMetriche per finanziare il cambiamento
Metriche per finanziare il cambiamento
XPeppers
 
How do you handle renaming of a resource in RESTful way
How do you handle renaming of a resource in RESTful wayHow do you handle renaming of a resource in RESTful way
How do you handle renaming of a resource in RESTful way
XPeppers
 
La tecnica del pomodoro - Come viene adottata in XPeppers
La tecnica del pomodoro - Come viene adottata in XPeppersLa tecnica del pomodoro - Come viene adottata in XPeppers
La tecnica del pomodoro - Come viene adottata in XPeppers
XPeppers
 
Collective code ownership in Extreme Programming
Collective code ownership in Extreme ProgrammingCollective code ownership in Extreme Programming
Collective code ownership in Extreme Programming
XPeppers
 
What is Agile?
What is Agile?What is Agile?
What is Agile?
XPeppers
 
Improve your TDD skills
Improve your TDD skillsImprove your TDD skills
Improve your TDD skills
XPeppers
 
Test driven infrastructure
Test driven infrastructureTest driven infrastructure
Test driven infrastructure
XPeppers
 
Banche agili un ossimoro?
Banche agili un ossimoro?Banche agili un ossimoro?
Banche agili un ossimoro?
XPeppers
 
Hiring Great People: how we improved our recruiting process to build and grow...
Hiring Great People: how we improved our recruiting process to build and grow...Hiring Great People: how we improved our recruiting process to build and grow...
Hiring Great People: how we improved our recruiting process to build and grow...
XPeppers
 
Continuous Delivery in Java
Continuous Delivery in JavaContinuous Delivery in Java
Continuous Delivery in Java
XPeppers
 
Life in XPeppers
Life in XPeppersLife in XPeppers
Life in XPeppers
XPeppers
 
Cloud e innovazione
Cloud e innovazioneCloud e innovazione
Cloud e innovazione
XPeppers
 
Company culture slides
Company culture slidesCompany culture slides
Company culture slides
XPeppers
 
Agileday2013 Bravi si diventa
Agileday2013 Bravi si diventaAgileday2013 Bravi si diventa
Agileday2013 Bravi si diventa
XPeppers
 
Agileday2013 pratiche agili applicate all'infrastruttura
Agileday2013 pratiche agili applicate all'infrastrutturaAgileday2013 pratiche agili applicate all'infrastruttura
Agileday2013 pratiche agili applicate all'infrastruttura
XPeppers
 

More from XPeppers (20)

Yagni, You aren't gonna need it
Yagni, You aren't gonna need itYagni, You aren't gonna need it
Yagni, You aren't gonna need it
 
Jenkins Shared Libraries
Jenkins Shared LibrariesJenkins Shared Libraries
Jenkins Shared Libraries
 
The Continuous Delivery process
The Continuous Delivery processThe Continuous Delivery process
The Continuous Delivery process
 
How Agile Dev Teams work
How Agile Dev Teams workHow Agile Dev Teams work
How Agile Dev Teams work
 
The Phoenix Project: un romanzo sull'IT
The Phoenix Project: un romanzo sull'ITThe Phoenix Project: un romanzo sull'IT
The Phoenix Project: un romanzo sull'IT
 
Metriche per finanziare il cambiamento
Metriche per finanziare il cambiamentoMetriche per finanziare il cambiamento
Metriche per finanziare il cambiamento
 
How do you handle renaming of a resource in RESTful way
How do you handle renaming of a resource in RESTful wayHow do you handle renaming of a resource in RESTful way
How do you handle renaming of a resource in RESTful way
 
La tecnica del pomodoro - Come viene adottata in XPeppers
La tecnica del pomodoro - Come viene adottata in XPeppersLa tecnica del pomodoro - Come viene adottata in XPeppers
La tecnica del pomodoro - Come viene adottata in XPeppers
 
Collective code ownership in Extreme Programming
Collective code ownership in Extreme ProgrammingCollective code ownership in Extreme Programming
Collective code ownership in Extreme Programming
 
What is Agile?
What is Agile?What is Agile?
What is Agile?
 
Improve your TDD skills
Improve your TDD skillsImprove your TDD skills
Improve your TDD skills
 
Test driven infrastructure
Test driven infrastructureTest driven infrastructure
Test driven infrastructure
 
Banche agili un ossimoro?
Banche agili un ossimoro?Banche agili un ossimoro?
Banche agili un ossimoro?
 
Hiring Great People: how we improved our recruiting process to build and grow...
Hiring Great People: how we improved our recruiting process to build and grow...Hiring Great People: how we improved our recruiting process to build and grow...
Hiring Great People: how we improved our recruiting process to build and grow...
 
Continuous Delivery in Java
Continuous Delivery in JavaContinuous Delivery in Java
Continuous Delivery in Java
 
Life in XPeppers
Life in XPeppersLife in XPeppers
Life in XPeppers
 
Cloud e innovazione
Cloud e innovazioneCloud e innovazione
Cloud e innovazione
 
Company culture slides
Company culture slidesCompany culture slides
Company culture slides
 
Agileday2013 Bravi si diventa
Agileday2013 Bravi si diventaAgileday2013 Bravi si diventa
Agileday2013 Bravi si diventa
 
Agileday2013 pratiche agili applicate all'infrastruttura
Agileday2013 pratiche agili applicate all'infrastrutturaAgileday2013 pratiche agili applicate all'infrastruttura
Agileday2013 pratiche agili applicate all'infrastruttura
 

Recently uploaded

Zaitechno Handheld Raman Spectrometer.pdf
Zaitechno Handheld Raman Spectrometer.pdfZaitechno Handheld Raman Spectrometer.pdf
Zaitechno Handheld Raman Spectrometer.pdf
AmandaCheung15
 
Perth MuleSoft Meetup July 2024
Perth MuleSoft Meetup July 2024Perth MuleSoft Meetup July 2024
Perth MuleSoft Meetup July 2024
Michael Price
 
History and Introduction for Generative AI ( GenAI )
History and Introduction for Generative AI ( GenAI )History and Introduction for Generative AI ( GenAI )
History and Introduction for Generative AI ( GenAI )
Badri_Bady
 
Choosing the Best Outlook OST to PST Converter: Key Features and Considerations
Choosing the Best Outlook OST to PST Converter: Key Features and ConsiderationsChoosing the Best Outlook OST to PST Converter: Key Features and Considerations
Choosing the Best Outlook OST to PST Converter: Key Features and Considerations
webbyacad software
 
It's your unstructured data: How to get your GenAI app to production (and spe...
It's your unstructured data: How to get your GenAI app to production (and spe...It's your unstructured data: How to get your GenAI app to production (and spe...
It's your unstructured data: How to get your GenAI app to production (and spe...
Zilliz
 
BLOCKCHAIN TECHNOLOGY - Advantages and Disadvantages
BLOCKCHAIN TECHNOLOGY - Advantages and DisadvantagesBLOCKCHAIN TECHNOLOGY - Advantages and Disadvantages
BLOCKCHAIN TECHNOLOGY - Advantages and Disadvantages
SAI KAILASH R
 
UX Webinar Series: Drive Revenue and Decrease Costs with Passkeys for Consume...
UX Webinar Series: Drive Revenue and Decrease Costs with Passkeys for Consume...UX Webinar Series: Drive Revenue and Decrease Costs with Passkeys for Consume...
UX Webinar Series: Drive Revenue and Decrease Costs with Passkeys for Consume...
FIDO Alliance
 
Develop Secure Enterprise Solutions with iOS Mobile App Development Services
Develop Secure Enterprise Solutions with iOS Mobile App Development ServicesDevelop Secure Enterprise Solutions with iOS Mobile App Development Services
Develop Secure Enterprise Solutions with iOS Mobile App Development Services
Damco Solutions
 
"Hands-on development experience using wasm Blazor", Furdak Vladyslav.pptx
"Hands-on development experience using wasm Blazor", Furdak Vladyslav.pptx"Hands-on development experience using wasm Blazor", Furdak Vladyslav.pptx
"Hands-on development experience using wasm Blazor", Furdak Vladyslav.pptx
Fwdays
 
LeadMagnet IQ Review: Unlock the Secret to Effortless Traffic and Leads.pdf
LeadMagnet IQ Review:  Unlock the Secret to Effortless Traffic and Leads.pdfLeadMagnet IQ Review:  Unlock the Secret to Effortless Traffic and Leads.pdf
LeadMagnet IQ Review: Unlock the Secret to Effortless Traffic and Leads.pdf
SelfMade bd
 
Scaling Vector Search: How Milvus Handles Billions+
Scaling Vector Search: How Milvus Handles Billions+Scaling Vector Search: How Milvus Handles Billions+
Scaling Vector Search: How Milvus Handles Billions+
Zilliz
 
Semantic-Aware Code Model: Elevating the Future of Software Development
Semantic-Aware Code Model: Elevating the Future of Software DevelopmentSemantic-Aware Code Model: Elevating the Future of Software Development
Semantic-Aware Code Model: Elevating the Future of Software Development
Baishakhi Ray
 
Uncharted Together- Navigating AI's New Frontiers in Libraries
Uncharted Together- Navigating AI's New Frontiers in LibrariesUncharted Together- Navigating AI's New Frontiers in Libraries
Uncharted Together- Navigating AI's New Frontiers in Libraries
Brian Pichman
 
CheckPoint Firewall Presentation CCSA.pdf
CheckPoint Firewall Presentation CCSA.pdfCheckPoint Firewall Presentation CCSA.pdf
CheckPoint Firewall Presentation CCSA.pdf
ssuser137992
 
Demystifying Neural Networks And Building Cybersecurity Applications
Demystifying Neural Networks And Building Cybersecurity ApplicationsDemystifying Neural Networks And Building Cybersecurity Applications
Demystifying Neural Networks And Building Cybersecurity Applications
Priyanka Aash
 
Camunda Chapter NY Meetup July 2024.pptx
Camunda Chapter NY Meetup July 2024.pptxCamunda Chapter NY Meetup July 2024.pptx
Camunda Chapter NY Meetup July 2024.pptx
ZachWylie3
 
Keynote : Presentation on SASE Technology
Keynote : Presentation on SASE TechnologyKeynote : Presentation on SASE Technology
Keynote : Presentation on SASE Technology
Priyanka Aash
 
Improving Learning Content Efficiency with Reusable Learning Content
Improving Learning Content Efficiency with Reusable Learning ContentImproving Learning Content Efficiency with Reusable Learning Content
Improving Learning Content Efficiency with Reusable Learning Content
Enterprise Knowledge
 
Mule Experience Hub and Release Channel with Java 17
Mule Experience Hub and Release Channel with Java 17Mule Experience Hub and Release Channel with Java 17
Mule Experience Hub and Release Channel with Java 17
Bhajan Mehta
 
The Path to General-Purpose Robots - Coatue
The Path to General-Purpose Robots - CoatueThe Path to General-Purpose Robots - Coatue
The Path to General-Purpose Robots - Coatue
Razin Mustafiz
 

Recently uploaded (20)

Zaitechno Handheld Raman Spectrometer.pdf
Zaitechno Handheld Raman Spectrometer.pdfZaitechno Handheld Raman Spectrometer.pdf
Zaitechno Handheld Raman Spectrometer.pdf
 
Perth MuleSoft Meetup July 2024
Perth MuleSoft Meetup July 2024Perth MuleSoft Meetup July 2024
Perth MuleSoft Meetup July 2024
 
History and Introduction for Generative AI ( GenAI )
History and Introduction for Generative AI ( GenAI )History and Introduction for Generative AI ( GenAI )
History and Introduction for Generative AI ( GenAI )
 
Choosing the Best Outlook OST to PST Converter: Key Features and Considerations
Choosing the Best Outlook OST to PST Converter: Key Features and ConsiderationsChoosing the Best Outlook OST to PST Converter: Key Features and Considerations
Choosing the Best Outlook OST to PST Converter: Key Features and Considerations
 
It's your unstructured data: How to get your GenAI app to production (and spe...
It's your unstructured data: How to get your GenAI app to production (and spe...It's your unstructured data: How to get your GenAI app to production (and spe...
It's your unstructured data: How to get your GenAI app to production (and spe...
 
BLOCKCHAIN TECHNOLOGY - Advantages and Disadvantages
BLOCKCHAIN TECHNOLOGY - Advantages and DisadvantagesBLOCKCHAIN TECHNOLOGY - Advantages and Disadvantages
BLOCKCHAIN TECHNOLOGY - Advantages and Disadvantages
 
UX Webinar Series: Drive Revenue and Decrease Costs with Passkeys for Consume...
UX Webinar Series: Drive Revenue and Decrease Costs with Passkeys for Consume...UX Webinar Series: Drive Revenue and Decrease Costs with Passkeys for Consume...
UX Webinar Series: Drive Revenue and Decrease Costs with Passkeys for Consume...
 
Develop Secure Enterprise Solutions with iOS Mobile App Development Services
Develop Secure Enterprise Solutions with iOS Mobile App Development ServicesDevelop Secure Enterprise Solutions with iOS Mobile App Development Services
Develop Secure Enterprise Solutions with iOS Mobile App Development Services
 
"Hands-on development experience using wasm Blazor", Furdak Vladyslav.pptx
"Hands-on development experience using wasm Blazor", Furdak Vladyslav.pptx"Hands-on development experience using wasm Blazor", Furdak Vladyslav.pptx
"Hands-on development experience using wasm Blazor", Furdak Vladyslav.pptx
 
LeadMagnet IQ Review: Unlock the Secret to Effortless Traffic and Leads.pdf
LeadMagnet IQ Review:  Unlock the Secret to Effortless Traffic and Leads.pdfLeadMagnet IQ Review:  Unlock the Secret to Effortless Traffic and Leads.pdf
LeadMagnet IQ Review: Unlock the Secret to Effortless Traffic and Leads.pdf
 
Scaling Vector Search: How Milvus Handles Billions+
Scaling Vector Search: How Milvus Handles Billions+Scaling Vector Search: How Milvus Handles Billions+
Scaling Vector Search: How Milvus Handles Billions+
 
Semantic-Aware Code Model: Elevating the Future of Software Development
Semantic-Aware Code Model: Elevating the Future of Software DevelopmentSemantic-Aware Code Model: Elevating the Future of Software Development
Semantic-Aware Code Model: Elevating the Future of Software Development
 
Uncharted Together- Navigating AI's New Frontiers in Libraries
Uncharted Together- Navigating AI's New Frontiers in LibrariesUncharted Together- Navigating AI's New Frontiers in Libraries
Uncharted Together- Navigating AI's New Frontiers in Libraries
 
CheckPoint Firewall Presentation CCSA.pdf
CheckPoint Firewall Presentation CCSA.pdfCheckPoint Firewall Presentation CCSA.pdf
CheckPoint Firewall Presentation CCSA.pdf
 
Demystifying Neural Networks And Building Cybersecurity Applications
Demystifying Neural Networks And Building Cybersecurity ApplicationsDemystifying Neural Networks And Building Cybersecurity Applications
Demystifying Neural Networks And Building Cybersecurity Applications
 
Camunda Chapter NY Meetup July 2024.pptx
Camunda Chapter NY Meetup July 2024.pptxCamunda Chapter NY Meetup July 2024.pptx
Camunda Chapter NY Meetup July 2024.pptx
 
Keynote : Presentation on SASE Technology
Keynote : Presentation on SASE TechnologyKeynote : Presentation on SASE Technology
Keynote : Presentation on SASE Technology
 
Improving Learning Content Efficiency with Reusable Learning Content
Improving Learning Content Efficiency with Reusable Learning ContentImproving Learning Content Efficiency with Reusable Learning Content
Improving Learning Content Efficiency with Reusable Learning Content
 
Mule Experience Hub and Release Channel with Java 17
Mule Experience Hub and Release Channel with Java 17Mule Experience Hub and Release Channel with Java 17
Mule Experience Hub and Release Channel with Java 17
 
The Path to General-Purpose Robots - Coatue
The Path to General-Purpose Robots - CoatueThe Path to General-Purpose Robots - Coatue
The Path to General-Purpose Robots - Coatue
 

A quick and fast intro to Kotlin

  • 2. KOTLIN ● Primary target JVM ● Javascript ● Compiled in Java byte code ● Created for industry Core goals is 100% Java interoperability.
  • 3. KOTLIN main features Concise Drastically reduce the amount of boilerplate code you need to write. Safe Avoid entire classes of errors such as null pointer exceptions. Interoperable Leverage existing frameworks and libraries of the JVM with 100% Java Interoperability.
  • 4. data class Person( var name: String, var surname: String, var age: Int) Create a POJO with: ● Getters ● Setters ● equals() ● hashCode() ● toString() ● copy() Concise public class Person { final String firstName; final String lastName; public Person(...) { ... } // Getters ... // Hashcode / equals ... // Tostring ... // Egh... }
  • 5. KOTLIN lambdas ● must always appear between curly brackets ● if there is a single parameter then it can be referred to by it Concise val list = (0..49).toList() val filtered = list .filter({ x -> x % 2 == 0 }) val list = (0..49).toList() val filtered = list .filter { it % 2 == 0 }
  • 10. Extend existing classes functionality Ability to extend a class with new functionality without having to inherit from the class ● does not modify classes ● are resolved statically
  • 11. Extend existing classes functionality fun String.lastChar() = this.charAt(this.length() - 1) // this can be omitted fun String.lastChar() = charAt(length() - 1) fun use(){ Val c: Char = "abc".lastChar() }
  • 12. Everything is an expression val max = if (a > b) a else b val hasPrefix = when(x) { is String -> x.startsWith("prefix") else -> false } when(x) { in 1..10 -> ... 102 -> ... else -> ... } boolean hasPrefix; if (x instanceof String) hasPrefix = x.startsWith("prefix"); else hasPrefix = false; switch (month) { case 1: ... break case 7: ... break default: ... }
  • 13. Default Parameters fun foo( i :Int, s: String = "", b: Boolean = true) {} fun usage(){ foo( 1, b = false) }
  • 14. for loop can iterate over any type that provides an iterator implementing next() and hasNext() for (item in collection) print(item) for ((index, value) in array.withIndex()) { println("the element at $index is $value") }
  • 15. Collections ● Made easy ● distinguishes between immutable and mutable collections val numbers: MutableList = mutableListOf(1, 2, 3) val readOnlyNumbers: List = numbers numbers.add(4) println(readOnlyView) // prints "[1, 2, 3, 4]" readOnlyNumbers.clear() // -> does not compile
  • 17. // Using R.layout.activity_main from the main source set import kotlinx.android.synthetic.main.activity_main.* class MyActivity : Activity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) textView.setText("Hello, world!") } } public class MyActivity extends Activity() { @override void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); TextView textView = (TextView) findViewById(R.id.textView); textView.setText("Hello, world!"); } } Kotlin Android Extensions
  • 18. Extension functions fun Fragment.toast(message: CharSequence, duration: Int = Toast.LENGTH_SHORT) { Toast.makeText(getActivity(), message, duration).show() } fragment.toast("Hello world!")
  • 19. Activities startActivity( intentFor< NewActivity > ("Answer" to 42) ) Intent intent = new Intent(this, NewActivity.class); intent.putExtra("Answer", 42); startActivity(intent);
  • 20. Functional support (Lambdas) view.setOnClickListener { toast("Hello world!") } View view = (View) findViewById(R.id.view); view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(this, "asdf", Toast.LENGTH_LONG) .show(); } });
  • 21. Dynamic Layout scrollView { linearLayout(LinearLayout.VERTICAL) { val label = textView("?") button("Click me!") { label.setText("Clicked!") } editText("Edit me!") // codice koltin // ... } }.style(...) ? Click me! Edit me!
  • 22. Easily mixed with Java ● Do not have to convert everything at once ● You can convert little portions ● Write kotlin code over the existing Java code Everything still works
  • 23. Kotlin costs nothing to adopt ● It’s open source ● There’s a high quality, one-click Java to Kotlin converter tool ● Can use all existing Java frameworks and libraries ● It integrates with Maven, Gradle and other build systems. ● Great for Android, compiles for java 6 byte code ● Very small runtime library 924 KB
  • 24. Kotlin usefull links ● A very well done documentation : Tutorial, Videos ● Kotlin Koans online ● Constantly updating in Github, kotlin-projects ● Talks: Kotlin in Action, Kotlin on Android
  • 25. What Java has that Kotlin does not https://kotlinlang.org/docs/reference/comparison-to-java.html
  • 26. Primitive Types Everything is an object we can call member functions and properties on any variable. What Java has that Kotlin does not val a: Int? = 1 val b: Long? = a print(a == b)
  • 27. Primitive Types Everything is an object we can call member functions and properties on any variable. What Java has that Kotlin does not val a: Int? = 1 val b: Long? = a print(a == b) // FALSE //
  • 28. Primitive Types Everything is an object we can call member functions and properties on any variable. What Java has that Kotlin does not val b: Byte = 1 val i: Int = b val i: Int = b.toInt() val a: Int? = 1 val b: Long? = a print(a == b) // FALSE //
  • 29. Primitive Types Everything is an object we can call member functions and properties on any variable. What Java has that Kotlin does not val b: Byte = 1 val i: Int = b // ERROR // val i: Int = b.toInt() // OK // val a: Int? = 1 val b: Long? = a print(a == b) // FALSE //
  • 30. Static Members class MyClass { companion object Factory { fun create(): MyClass = MyClass() } } val instance = MyClass.create() What Java has that Kotlin does not Singleton object MyClass { // .... }