SlideShare une entreprise Scribd logo
1  sur  33
Télécharger pour lire hors ligne
Haim Yadid / Next Insurance
mapOf(
taking?. kotlin to production
)
Seriously!!
Disclaimer
‫בה‬ ‫לנאמר‬ ‫לייחס‬ ‫ואין‬ ‫סאטירה‬ ‫תוכנית‬ ‫הינה‬ ‫זו‬ ‫תוכנית‬
‫כלשהי‬ ‫תכנות‬ ‫בשפת‬ ‫לפגוע‬ ‫ניסיון‬ ‫או‬ ‫אחרת‬ ‫משמעות‬ ‫שום‬
‫בה‬ ‫המופיעים‬ ‫מהתכנים‬ ‫נפגע‬ ‫חש‬ ‫הנך‬ ‫זאת‬ ‫בכל‬ ‫אם‬
‫מראש‬ ‫מתנצלים‬ ‫אנו‬ ‫בסקאלה‬ ‫מתכנת‬ ‫אתה‬ ‫אם‬ ‫או‬
About Me
❖ Developing software since 1984 (Boy, am I getting old?)
❖ Basic -> Pascal -> C -> C++ -> Java -> Kotlin
❖ Architect in Mercury
❖ Independent performance expert for 7 years
❖ Backend developer in
❖ Founded in the Beginning of 2016
❖ HQ@Palo Alto RnD@Kfar Saba
❖ Aims to disrupt the Small businesses insurance field
❖ Providing online experience which is simple fast and
transparent
❖ We started to write real code on May 2016
Kotlin
Java
Javascript
Node.JS
Dropwizard
RDS (mysql)
What is Kotlin ?
❖ Statically typed programming language
❖ for the JVM, Android and the browser (JS)
❖ 100% interoperable with Java™ (well almost)
❖ Developed by Jetbrains
❖ Revealed as an open source in July 2011
❖ v1.0 Release on Feb 2016
❖ 1.0.5 current stable version (28.11.2016)
Kotlin Features
❖ Concise
❖ Safe
❖ Versatile
❖ Practical
❖ Interoperable
Why Kotlin
Java Scala Cloju
Groovy/
JRuby
Java8
Strongly

Typed
Loosely

Typed
OO/verbose Functional/Rich
)))))))))))))))))))))))))))))))
Why Kotlin
Java Scala Cloju
Groovy/
JRuby
Java8
Strongly

Typed
Loosely

Typed
OO/verbose Functional/Rich
Kotlin )))))))))))))))))))))))))))))))
Scala can do it !! ?
❖ Yes Scala can do it
❖ Academic / Complicated
❖ Scala compile time is horrific
❖ Operator overloading -> OMG
Getting Started
❖ Kotlin has very lightweight standard library
❖ Mostly rely on Java collections for good (interop) and for
bad (all the rest)
❖ Kotlin compiles to Java6 byte code
❖ Has no special build tool just use Maven / Gradle
Kotlin & Android
❖ Kotlin got widely accepted on the android community
❖ Runtime has low footprint
❖ Compiles to …. Java 6
❖ Brings lambdas to Android dev and a lot of cool features
Trivial Stuff
❖ No new keyword
❖ No checked exceptions
❖ == structural equality
❖ === referencial equality
❖ No primitives (only under the hood)
❖ No arrays they are classes
❖ Any ~ java.lang.Object
Fun
❖ Functions are denoted with the fun keyword
❖ They can be member of a class
❖ Or top level functions inside a kotlin file
❖ can support tail recursion
❖ can be inlined
❖ fun funny(funnier: String) = "Hello world"
Fun Parameters
❖ Pascal notation
❖ Function parameters may have default values
❖ Call to function can be done using parameter names
fun mergeUser(first: String = "a", last: String) = first + last



fun foo() {

mergeUser(first="Albert",last= "Einstein")

mergeUser(last= "Einstein")

}
Extension functions
❖ Not like ruby monkey patching
❖ Only extend functionality cannot override
❖ Not part of the class
❖ Static methods with the receiver as first a parameter
fun String.double(sep: String) = "$this$sep$this"
❖ variables are declared using the keywords
❖ val (immutable)
❖ var (mutable)
❖
fun funny(funnier: String): String {

val x = "Hello world"

return x

}
val /var
Classes
❖ less verbose than Java
❖ no static members (use companion object)
❖ public is default
❖ Must be declared open to be overridden
❖ override keyword is mandatory
class Producer(val name:String, val value: Int)
Properties
❖ All members of classes are access via proper accessors
(getter and setters)
❖ The usage of getters and setters is implicit
❖ one can override implementation of setters and getters
Delegate Class
interface Foo {

fun funfun()

}



class FooImpl(val x: Int) : Foo {

override fun funfun() = print(x)

}



class Wrapper(f: Foo) : Foo by f



fun main(args: Array<String>) {

val f = FooImpl(10)

val wf = Wrapper(f)

wf.funfun() // prints 10

}
Smart Casts
❖ If you check that a class is of a certain type no need to
cast it
open class A {

fun smile() { println(":)")}

}



class B : A() {

fun laugh() = println("ha ha ha")

}



fun funnier(a: A) {

if (a is B ) {

a.laugh()

}

}
Null Safety
❖ Nullability part of the type of an object
❖ Option[T] Optional<T>
❖ Swift anyone ?
var msg : String = "Welcome"

msg = null
val nullableMsg : String? = null
Safe operator ?.
❖ The safe accessor operator ?. will result null
❖ Elvis operator for default
fun funny(funnier: String?): Int? {



println(x?.length ?: "")

return x?.length

}
Bang Bang !!
❖ The bang bang !! throws an NPE if object is null
fun funny(funnier: String?): String {

return funnier!!

}
Data classes
❖ Less powerful version of to case classes in Scala
❖ Implementation of
❖ hashcode() equals()
❖ copy()
❖ de structuring (component1 component2 …)
data class User(val firstName: String, val lastName:
String)



fun smile(user: User) {

val (first,last) = user

}
When
❖ Reminds Scala’s pattern matching but not as strong
❖ More capable than select in java
when (x) {

is Int -> print(x + 1)

is String -> print(x.length + 1)

is IntArray -> print(x.sum())

}
Sane Operator Overloading
❖ override only a set of the predefined operators
❖ By implementing the method with the correct name
Expression Translated to
a + b a.plus(b)
a - b a.minus(b)
a * b a.times(b)
a / b a.div(b)
a % b a.mod(b)
a..b a.rangeTo(b)
Sane Operator Overloading
data class Complex(val x: Double, val y: Double) {

operator fun inc(): Complex {

return Complex(x + 1, y + 1)

}



infix operator fun plus(c: Complex): Complex {

return (Complex(c.x + x, c.y + y))

}



}
Collections
❖ no language operators for construction of lists and maps
❖ using underlying java collections
❖ Have two versions mutable and immutable
❖ Immutability is a lie at least ATM it is only an immutable
view of a mutable collection.
Collections
val chars = mapOf("Terion" to "Lannister", "John" to "Snow")

chars["Terion"]

chars["Aria"] = “Stark"




val chars2 = mutableMapOf<String,String>()

chars2["A girl"] = "has no name"



val sigils = listOf("Direwolf", "Lion", "Dragon", "Flower")

println(sigils[0])
Kotlin 1.1
❖ Java 7/8 support -> generate J8 class files
❖ Coroutines : async / await (stackless continuations)
❖ Generators: Yield
❖ inheritance of data classes
Generators (yield)
val fibonacci: Sequence<Int> = generate {
yield(1) // first Fibonacci number
var cur = 1
var next = 1
while (true) {
yield(next) // next Fibonacci number
val tmp = cur + next
cur = next
next = tmp
}
}
Questions?

Contenu connexe

Tendances

Kotlin advanced - language reference for android developers
Kotlin advanced - language reference for android developersKotlin advanced - language reference for android developers
Kotlin advanced - language reference for android developersBartosz Kosarzycki
 
2017: Kotlin - now more than ever
2017: Kotlin - now more than ever2017: Kotlin - now more than ever
2017: Kotlin - now more than everKai Koenig
 
eMan Dev Meetup: Kotlin - A Language we should know it exists (part 02/03) 18...
eMan Dev Meetup: Kotlin - A Language we should know it exists (part 02/03) 18...eMan Dev Meetup: Kotlin - A Language we should know it exists (part 02/03) 18...
eMan Dev Meetup: Kotlin - A Language we should know it exists (part 02/03) 18...eMan s.r.o.
 
The Kotlin Programming Language
The Kotlin Programming LanguageThe Kotlin Programming Language
The Kotlin Programming Languageintelliyole
 
Develop your next app with kotlin @ AndroidMakersFr 2017
Develop your next app with kotlin @ AndroidMakersFr 2017Develop your next app with kotlin @ AndroidMakersFr 2017
Develop your next app with kotlin @ AndroidMakersFr 2017Arnaud Giuliani
 
Kotlin: Why Do You Care?
Kotlin: Why Do You Care?Kotlin: Why Do You Care?
Kotlin: Why Do You Care?intelliyole
 
Kotlin in action
Kotlin in actionKotlin in action
Kotlin in actionCiro Rizzo
 
Kotlin hands on - MorningTech ekito 2017
Kotlin hands on - MorningTech ekito 2017Kotlin hands on - MorningTech ekito 2017
Kotlin hands on - MorningTech ekito 2017Arnaud Giuliani
 
K is for Kotlin
K is for KotlinK is for Kotlin
K is for KotlinTechMagic
 
Introduction to kotlin + spring boot demo
Introduction to kotlin + spring boot demoIntroduction to kotlin + spring boot demo
Introduction to kotlin + spring boot demoMuhammad Abdullah
 
Kotlin: Challenges in JVM language design
Kotlin: Challenges in JVM language designKotlin: Challenges in JVM language design
Kotlin: Challenges in JVM language designAndrey Breslav
 
No excuses, switch to kotlin
No excuses, switch to kotlinNo excuses, switch to kotlin
No excuses, switch to kotlinThijs Suijten
 
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 Slides from Devoxx 2011
Kotlin Slides from Devoxx 2011Kotlin Slides from Devoxx 2011
Kotlin Slides from Devoxx 2011Andrey Breslav
 
Kotlin cheat sheet by ekito
Kotlin cheat sheet by ekitoKotlin cheat sheet by ekito
Kotlin cheat sheet by ekitoArnaud Giuliani
 
Kotlin for Android - Vali Iorgu - mRready
Kotlin for Android - Vali Iorgu - mRreadyKotlin for Android - Vali Iorgu - mRready
Kotlin for Android - Vali Iorgu - mRreadyMobileAcademy
 
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
 

Tendances (20)

Kotlin advanced - language reference for android developers
Kotlin advanced - language reference for android developersKotlin advanced - language reference for android developers
Kotlin advanced - language reference for android developers
 
Introduction to kotlin
Introduction to kotlinIntroduction to kotlin
Introduction to kotlin
 
2017: Kotlin - now more than ever
2017: Kotlin - now more than ever2017: Kotlin - now more than ever
2017: Kotlin - now more than ever
 
eMan Dev Meetup: Kotlin - A Language we should know it exists (part 02/03) 18...
eMan Dev Meetup: Kotlin - A Language we should know it exists (part 02/03) 18...eMan Dev Meetup: Kotlin - A Language we should know it exists (part 02/03) 18...
eMan Dev Meetup: Kotlin - A Language we should know it exists (part 02/03) 18...
 
The Kotlin Programming Language
The Kotlin Programming LanguageThe Kotlin Programming Language
The Kotlin Programming Language
 
Develop your next app with kotlin @ AndroidMakersFr 2017
Develop your next app with kotlin @ AndroidMakersFr 2017Develop your next app with kotlin @ AndroidMakersFr 2017
Develop your next app with kotlin @ AndroidMakersFr 2017
 
Kotlin: Why Do You Care?
Kotlin: Why Do You Care?Kotlin: Why Do You Care?
Kotlin: Why Do You Care?
 
Kotlin in action
Kotlin in actionKotlin in action
Kotlin in action
 
Kotlin hands on - MorningTech ekito 2017
Kotlin hands on - MorningTech ekito 2017Kotlin hands on - MorningTech ekito 2017
Kotlin hands on - MorningTech ekito 2017
 
K is for Kotlin
K is for KotlinK is for Kotlin
K is for Kotlin
 
Introduction to kotlin + spring boot demo
Introduction to kotlin + spring boot demoIntroduction to kotlin + spring boot demo
Introduction to kotlin + spring boot demo
 
Kotlin Overview
Kotlin OverviewKotlin Overview
Kotlin Overview
 
Kotlin: Challenges in JVM language design
Kotlin: Challenges in JVM language designKotlin: Challenges in JVM language design
Kotlin: Challenges in JVM language design
 
No excuses, switch to kotlin
No excuses, switch to kotlinNo excuses, switch to kotlin
No excuses, switch 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 Slides from Devoxx 2011
Kotlin Slides from Devoxx 2011Kotlin Slides from Devoxx 2011
Kotlin Slides from Devoxx 2011
 
Kotlin cheat sheet by ekito
Kotlin cheat sheet by ekitoKotlin cheat sheet by ekito
Kotlin cheat sheet by ekito
 
Kotlin for Android - Vali Iorgu - mRready
Kotlin for Android - Vali Iorgu - mRreadyKotlin for Android - Vali Iorgu - mRready
Kotlin for Android - Vali Iorgu - mRready
 
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
 

En vedette

The Future of Futures - A Talk About Java 8 CompletableFutures
The Future of Futures - A Talk About Java 8 CompletableFuturesThe Future of Futures - A Talk About Java 8 CompletableFutures
The Future of Futures - A Talk About Java 8 CompletableFuturesHaim Yadid
 
Kotlin в production. Как и зачем?
Kotlin в production. Как и зачем?Kotlin в production. Как и зачем?
Kotlin в production. Как и зачем?DotNetConf
 
JVM Garbage Collection logs, you do not want to ignore them! - Reversim Summi...
JVM Garbage Collection logs, you do not want to ignore them! - Reversim Summi...JVM Garbage Collection logs, you do not want to ignore them! - Reversim Summi...
JVM Garbage Collection logs, you do not want to ignore them! - Reversim Summi...Haim Yadid
 
#MBLTdev: Kotlin для Android, или лёгкий способ перестать программировать на ...
#MBLTdev: Kotlin для Android, или лёгкий способ перестать программировать на ...#MBLTdev: Kotlin для Android, или лёгкий способ перестать программировать на ...
#MBLTdev: Kotlin для Android, или лёгкий способ перестать программировать на ...e-Legion
 
Tales About Scala Performance
Tales About Scala PerformanceTales About Scala Performance
Tales About Scala PerformanceHaim Yadid
 
mjprof: Monadic approach for JVM profiling
mjprof: Monadic approach for JVM profilingmjprof: Monadic approach for JVM profiling
mjprof: Monadic approach for JVM profilingHaim Yadid
 
Kotlin Bytecode Generation and Runtime Performance
Kotlin Bytecode Generation and Runtime PerformanceKotlin Bytecode Generation and Runtime Performance
Kotlin Bytecode Generation and Runtime Performanceintelliyole
 
The Wix Microservice Stack
The Wix Microservice StackThe Wix Microservice Stack
The Wix Microservice StackTomer Gabel
 
Java 8 Launch - MetaSpaces
Java 8 Launch - MetaSpacesJava 8 Launch - MetaSpaces
Java 8 Launch - MetaSpacesHaim Yadid
 
A topology of memory leaks on the JVM
A topology of memory leaks on the JVMA topology of memory leaks on the JVM
A topology of memory leaks on the JVMRafael Winterhalter
 
Let's talk about Garbage Collection
Let's talk about Garbage CollectionLet's talk about Garbage Collection
Let's talk about Garbage CollectionHaim Yadid
 
Building Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJavaBuilding Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJavaRick Warren
 
Memory Management: What You Need to Know When Moving to Java 8
Memory Management: What You Need to Know When Moving to Java 8Memory Management: What You Need to Know When Moving to Java 8
Memory Management: What You Need to Know When Moving to Java 8AppDynamics
 
JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)
JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)
JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)Stephen Chin
 

En vedette (16)

The Future of Futures - A Talk About Java 8 CompletableFutures
The Future of Futures - A Talk About Java 8 CompletableFuturesThe Future of Futures - A Talk About Java 8 CompletableFutures
The Future of Futures - A Talk About Java 8 CompletableFutures
 
Kotlin в production. Как и зачем?
Kotlin в production. Как и зачем?Kotlin в production. Как и зачем?
Kotlin в production. Как и зачем?
 
JVM Garbage Collection logs, you do not want to ignore them! - Reversim Summi...
JVM Garbage Collection logs, you do not want to ignore them! - Reversim Summi...JVM Garbage Collection logs, you do not want to ignore them! - Reversim Summi...
JVM Garbage Collection logs, you do not want to ignore them! - Reversim Summi...
 
#MBLTdev: Kotlin для Android, или лёгкий способ перестать программировать на ...
#MBLTdev: Kotlin для Android, или лёгкий способ перестать программировать на ...#MBLTdev: Kotlin для Android, или лёгкий способ перестать программировать на ...
#MBLTdev: Kotlin для Android, или лёгкий способ перестать программировать на ...
 
Tales About Scala Performance
Tales About Scala PerformanceTales About Scala Performance
Tales About Scala Performance
 
mjprof: Monadic approach for JVM profiling
mjprof: Monadic approach for JVM profilingmjprof: Monadic approach for JVM profiling
mjprof: Monadic approach for JVM profiling
 
Kotlin Bytecode Generation and Runtime Performance
Kotlin Bytecode Generation and Runtime PerformanceKotlin Bytecode Generation and Runtime Performance
Kotlin Bytecode Generation and Runtime Performance
 
The Wix Microservice Stack
The Wix Microservice StackThe Wix Microservice Stack
The Wix Microservice Stack
 
Java 8 Launch - MetaSpaces
Java 8 Launch - MetaSpacesJava 8 Launch - MetaSpaces
Java 8 Launch - MetaSpaces
 
A topology of memory leaks on the JVM
A topology of memory leaks on the JVMA topology of memory leaks on the JVM
A topology of memory leaks on the JVM
 
ClassLoader Leaks
ClassLoader LeaksClassLoader Leaks
ClassLoader Leaks
 
The Java Memory Model
The Java Memory ModelThe Java Memory Model
The Java Memory Model
 
Let's talk about Garbage Collection
Let's talk about Garbage CollectionLet's talk about Garbage Collection
Let's talk about Garbage Collection
 
Building Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJavaBuilding Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJava
 
Memory Management: What You Need to Know When Moving to Java 8
Memory Management: What You Need to Know When Moving to Java 8Memory Management: What You Need to Know When Moving to Java 8
Memory Management: What You Need to Know When Moving to Java 8
 
JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)
JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)
JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)
 

Similaire à Taking Kotlin to production, Seriously

Polyglot Programming @ Jax.de 2010
Polyglot Programming @ Jax.de 2010Polyglot Programming @ Jax.de 2010
Polyglot Programming @ Jax.de 2010Andres Almiray
 
Polyglot Programming in the JVM
Polyglot Programming in the JVMPolyglot Programming in the JVM
Polyglot Programming in the JVMAndres Almiray
 
Kotlin: A pragmatic language by JetBrains
Kotlin: A pragmatic language by JetBrainsKotlin: A pragmatic language by JetBrains
Kotlin: A pragmatic language by JetBrainsJigar Gosar
 
Kotlin Language Features - A Java comparison
Kotlin Language Features - A Java comparisonKotlin Language Features - A Java comparison
Kotlin Language Features - A Java comparisonEd Austin
 
Kotlin for Android Developers - 3
Kotlin for Android Developers - 3Kotlin for Android Developers - 3
Kotlin for Android Developers - 3Mohamed Nabil, MSc.
 
Introduction to Scala for JCConf Taiwan
Introduction to Scala for JCConf TaiwanIntroduction to Scala for JCConf Taiwan
Introduction to Scala for JCConf TaiwanJimin Hsieh
 
2022 May - Shoulders of Giants - Amsterdam - Kotlin Dev Day.pdf
2022 May - Shoulders of Giants - Amsterdam - Kotlin Dev Day.pdf2022 May - Shoulders of Giants - Amsterdam - Kotlin Dev Day.pdf
2022 May - Shoulders of Giants - Amsterdam - Kotlin Dev Day.pdfAndrey Breslav
 
JVM languages "flame wars"
JVM languages "flame wars"JVM languages "flame wars"
JVM languages "flame wars"Gal Marder
 
Getting Fired with Java Types
Getting Fired with Java TypesGetting Fired with Java Types
Getting Fired with Java TypesJoe Mathes
 
SE 20016 - programming languages landscape.
SE 20016 - programming languages landscape.SE 20016 - programming languages landscape.
SE 20016 - programming languages landscape.Ruslan Shevchenko
 
Introduction to Kotlin for Android developers
Introduction to Kotlin for Android developersIntroduction to Kotlin for Android developers
Introduction to Kotlin for Android developersMohamed Wael
 
Programming Android Application in Scala.
Programming Android Application in Scala.Programming Android Application in Scala.
Programming Android Application in Scala.Brian Hsu
 
Polyglot Programming in the JVM - Øredev
Polyglot Programming in the JVM - ØredevPolyglot Programming in the JVM - Øredev
Polyglot Programming in the JVM - ØredevAndres Almiray
 
Kotlin For Android - Properties (part 4 of 7)
Kotlin For Android - Properties (part 4 of 7)Kotlin For Android - Properties (part 4 of 7)
Kotlin For Android - Properties (part 4 of 7)Gesh Markov
 
The best of AltJava is Xtend
The best of AltJava is XtendThe best of AltJava is Xtend
The best of AltJava is Xtendtakezoe
 
Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...
Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...
Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...lennartkats
 

Similaire à Taking Kotlin to production, Seriously (20)

Polyglot Programming @ Jax.de 2010
Polyglot Programming @ Jax.de 2010Polyglot Programming @ Jax.de 2010
Polyglot Programming @ Jax.de 2010
 
Polyglot Programming in the JVM
Polyglot Programming in the JVMPolyglot Programming in the JVM
Polyglot Programming in the JVM
 
Kotlin: A pragmatic language by JetBrains
Kotlin: A pragmatic language by JetBrainsKotlin: A pragmatic language by JetBrains
Kotlin: A pragmatic language by JetBrains
 
Kotlin Language Features - A Java comparison
Kotlin Language Features - A Java comparisonKotlin Language Features - A Java comparison
Kotlin Language Features - A Java comparison
 
Kotlin for Android Developers - 3
Kotlin for Android Developers - 3Kotlin for Android Developers - 3
Kotlin for Android Developers - 3
 
Introduction to Scala for JCConf Taiwan
Introduction to Scala for JCConf TaiwanIntroduction to Scala for JCConf Taiwan
Introduction to Scala for JCConf Taiwan
 
2022 May - Shoulders of Giants - Amsterdam - Kotlin Dev Day.pdf
2022 May - Shoulders of Giants - Amsterdam - Kotlin Dev Day.pdf2022 May - Shoulders of Giants - Amsterdam - Kotlin Dev Day.pdf
2022 May - Shoulders of Giants - Amsterdam - Kotlin Dev Day.pdf
 
Java Full Throttle
Java Full ThrottleJava Full Throttle
Java Full Throttle
 
JVM languages "flame wars"
JVM languages "flame wars"JVM languages "flame wars"
JVM languages "flame wars"
 
Getting Fired with Java Types
Getting Fired with Java TypesGetting Fired with Java Types
Getting Fired with Java Types
 
Dart
DartDart
Dart
 
SE 20016 - programming languages landscape.
SE 20016 - programming languages landscape.SE 20016 - programming languages landscape.
SE 20016 - programming languages landscape.
 
Introduction to Kotlin for Android developers
Introduction to Kotlin for Android developersIntroduction to Kotlin for Android developers
Introduction to Kotlin for Android developers
 
Lecture19.07.2014
Lecture19.07.2014Lecture19.07.2014
Lecture19.07.2014
 
Programming Android Application in Scala.
Programming Android Application in Scala.Programming Android Application in Scala.
Programming Android Application in Scala.
 
Polyglot Programming in the JVM - Øredev
Polyglot Programming in the JVM - ØredevPolyglot Programming in the JVM - Øredev
Polyglot Programming in the JVM - Øredev
 
Kotlin For Android - Properties (part 4 of 7)
Kotlin For Android - Properties (part 4 of 7)Kotlin For Android - Properties (part 4 of 7)
Kotlin For Android - Properties (part 4 of 7)
 
Java For Automation
Java   For AutomationJava   For Automation
Java For Automation
 
The best of AltJava is Xtend
The best of AltJava is XtendThe best of AltJava is Xtend
The best of AltJava is Xtend
 
Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...
Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...
Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...
 

Plus de Haim Yadid

Loom me up Scotty! Project Loom - What's in it for Me?
Loom me up Scotty!  Project Loom - What's in it for Me?Loom me up Scotty!  Project Loom - What's in it for Me?
Loom me up Scotty! Project Loom - What's in it for Me?Haim Yadid
 
“Show Me the Garbage!”, Garbage Collection a Friend or a Foe
“Show Me the Garbage!”, Garbage Collection a Friend or a Foe“Show Me the Garbage!”, Garbage Collection a Friend or a Foe
“Show Me the Garbage!”, Garbage Collection a Friend or a FoeHaim Yadid
 
Kotlin Backend Development 6 Yrs Recap. The Good, the Bad and the Ugly
Kotlin Backend Development 6 Yrs Recap. The Good, the Bad and the UglyKotlin Backend Development 6 Yrs Recap. The Good, the Bad and the Ugly
Kotlin Backend Development 6 Yrs Recap. The Good, the Bad and the UglyHaim Yadid
 
“Show Me the Garbage!”, Understanding Garbage Collection
“Show Me the Garbage!”, Understanding Garbage Collection“Show Me the Garbage!”, Understanding Garbage Collection
“Show Me the Garbage!”, Understanding Garbage CollectionHaim Yadid
 
Java Memory Structure
Java Memory Structure Java Memory Structure
Java Memory Structure Haim Yadid
 
Basic JVM Troubleshooting With Jmx
Basic JVM Troubleshooting With JmxBasic JVM Troubleshooting With Jmx
Basic JVM Troubleshooting With JmxHaim Yadid
 
The Freelancer Journey
The Freelancer JourneyThe Freelancer Journey
The Freelancer JourneyHaim Yadid
 
Java 8 - Stamped Lock
Java 8 - Stamped LockJava 8 - Stamped Lock
Java 8 - Stamped LockHaim Yadid
 
Concurrency and Multithreading Demistified - Reversim Summit 2014
Concurrency and Multithreading Demistified - Reversim Summit 2014Concurrency and Multithreading Demistified - Reversim Summit 2014
Concurrency and Multithreading Demistified - Reversim Summit 2014Haim Yadid
 
A short Intro. to Java Mission Control
A short Intro. to Java Mission ControlA short Intro. to Java Mission Control
A short Intro. to Java Mission ControlHaim Yadid
 
Java Enterprise Edition Concurrency Misconceptions
Java Enterprise Edition Concurrency Misconceptions Java Enterprise Edition Concurrency Misconceptions
Java Enterprise Edition Concurrency Misconceptions Haim Yadid
 
Israeli JUG - IL JUG presentation
Israeli JUG -  IL JUG presentation Israeli JUG -  IL JUG presentation
Israeli JUG - IL JUG presentation Haim Yadid
 

Plus de Haim Yadid (12)

Loom me up Scotty! Project Loom - What's in it for Me?
Loom me up Scotty!  Project Loom - What's in it for Me?Loom me up Scotty!  Project Loom - What's in it for Me?
Loom me up Scotty! Project Loom - What's in it for Me?
 
“Show Me the Garbage!”, Garbage Collection a Friend or a Foe
“Show Me the Garbage!”, Garbage Collection a Friend or a Foe“Show Me the Garbage!”, Garbage Collection a Friend or a Foe
“Show Me the Garbage!”, Garbage Collection a Friend or a Foe
 
Kotlin Backend Development 6 Yrs Recap. The Good, the Bad and the Ugly
Kotlin Backend Development 6 Yrs Recap. The Good, the Bad and the UglyKotlin Backend Development 6 Yrs Recap. The Good, the Bad and the Ugly
Kotlin Backend Development 6 Yrs Recap. The Good, the Bad and the Ugly
 
“Show Me the Garbage!”, Understanding Garbage Collection
“Show Me the Garbage!”, Understanding Garbage Collection“Show Me the Garbage!”, Understanding Garbage Collection
“Show Me the Garbage!”, Understanding Garbage Collection
 
Java Memory Structure
Java Memory Structure Java Memory Structure
Java Memory Structure
 
Basic JVM Troubleshooting With Jmx
Basic JVM Troubleshooting With JmxBasic JVM Troubleshooting With Jmx
Basic JVM Troubleshooting With Jmx
 
The Freelancer Journey
The Freelancer JourneyThe Freelancer Journey
The Freelancer Journey
 
Java 8 - Stamped Lock
Java 8 - Stamped LockJava 8 - Stamped Lock
Java 8 - Stamped Lock
 
Concurrency and Multithreading Demistified - Reversim Summit 2014
Concurrency and Multithreading Demistified - Reversim Summit 2014Concurrency and Multithreading Demistified - Reversim Summit 2014
Concurrency and Multithreading Demistified - Reversim Summit 2014
 
A short Intro. to Java Mission Control
A short Intro. to Java Mission ControlA short Intro. to Java Mission Control
A short Intro. to Java Mission Control
 
Java Enterprise Edition Concurrency Misconceptions
Java Enterprise Edition Concurrency Misconceptions Java Enterprise Edition Concurrency Misconceptions
Java Enterprise Edition Concurrency Misconceptions
 
Israeli JUG - IL JUG presentation
Israeli JUG -  IL JUG presentation Israeli JUG -  IL JUG presentation
Israeli JUG - IL JUG presentation
 

Dernier

Generative AI for Cybersecurity - EC-Council
Generative AI for Cybersecurity - EC-CouncilGenerative AI for Cybersecurity - EC-Council
Generative AI for Cybersecurity - EC-CouncilVICTOR MAESTRE RAMIREZ
 
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...OnePlan Solutions
 
Streamlining Your Application Builds with Cloud Native Buildpacks
Streamlining Your Application Builds  with Cloud Native BuildpacksStreamlining Your Application Builds  with Cloud Native Buildpacks
Streamlining Your Application Builds with Cloud Native BuildpacksVish Abrams
 
Understanding Native Mobile App Development
Understanding Native Mobile App DevelopmentUnderstanding Native Mobile App Development
Understanding Native Mobile App DevelopmentMobulous Technologies
 
AI Embracing Every Shade of Human Beauty
AI Embracing Every Shade of Human BeautyAI Embracing Every Shade of Human Beauty
AI Embracing Every Shade of Human BeautyRaymond Okyere-Forson
 
online pdf editor software solutions.pdf
online pdf editor software solutions.pdfonline pdf editor software solutions.pdf
online pdf editor software solutions.pdfMeon Technology
 
Vectors are the new JSON in PostgreSQL (SCaLE 21x)
Vectors are the new JSON in PostgreSQL (SCaLE 21x)Vectors are the new JSON in PostgreSQL (SCaLE 21x)
Vectors are the new JSON in PostgreSQL (SCaLE 21x)Jonathan Katz
 
React 19: Revolutionizing Web Development
React 19: Revolutionizing Web DevelopmentReact 19: Revolutionizing Web Development
React 19: Revolutionizing Web DevelopmentBOSC Tech Labs
 
Watermarking in Source Code: Applications and Security Challenges
Watermarking in Source Code: Applications and Security ChallengesWatermarking in Source Code: Applications and Security Challenges
Watermarking in Source Code: Applications and Security ChallengesShyamsundar Das
 
Top Software Development Trends in 2024
Top Software Development Trends in  2024Top Software Development Trends in  2024
Top Software Development Trends in 2024Mind IT Systems
 
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...Jaydeep Chhasatia
 
IA Generativa y Grafos de Neo4j: RAG time
IA Generativa y Grafos de Neo4j: RAG timeIA Generativa y Grafos de Neo4j: RAG time
IA Generativa y Grafos de Neo4j: RAG timeNeo4j
 
How Does the Epitome of Spyware Differ from Other Malicious Software?
How Does the Epitome of Spyware Differ from Other Malicious Software?How Does the Epitome of Spyware Differ from Other Malicious Software?
How Does the Epitome of Spyware Differ from Other Malicious Software?AmeliaSmith90
 
Deep Learning for Images with PyTorch - Datacamp
Deep Learning for Images with PyTorch - DatacampDeep Learning for Images with PyTorch - Datacamp
Deep Learning for Images with PyTorch - DatacampVICTOR MAESTRE RAMIREZ
 
OpenChain Webinar: Universal CVSS Calculator
OpenChain Webinar: Universal CVSS CalculatorOpenChain Webinar: Universal CVSS Calculator
OpenChain Webinar: Universal CVSS CalculatorShane Coughlan
 
New ThousandEyes Product Features and Release Highlights: March 2024
New ThousandEyes Product Features and Release Highlights: March 2024New ThousandEyes Product Features and Release Highlights: March 2024
New ThousandEyes Product Features and Release Highlights: March 2024ThousandEyes
 
ERP For Electrical and Electronics manufecturing.pptx
ERP For Electrical and Electronics manufecturing.pptxERP For Electrical and Electronics manufecturing.pptx
ERP For Electrical and Electronics manufecturing.pptxAutus Cyber Tech
 
Cybersecurity Challenges with Generative AI - for Good and Bad
Cybersecurity Challenges with Generative AI - for Good and BadCybersecurity Challenges with Generative AI - for Good and Bad
Cybersecurity Challenges with Generative AI - for Good and BadIvo Andreev
 
Your Vision, Our Expertise: TECUNIQUE's Tailored Software Teams
Your Vision, Our Expertise: TECUNIQUE's Tailored Software TeamsYour Vision, Our Expertise: TECUNIQUE's Tailored Software Teams
Your Vision, Our Expertise: TECUNIQUE's Tailored Software TeamsJaydeep Chhasatia
 

Dernier (20)

Generative AI for Cybersecurity - EC-Council
Generative AI for Cybersecurity - EC-CouncilGenerative AI for Cybersecurity - EC-Council
Generative AI for Cybersecurity - EC-Council
 
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...
 
Streamlining Your Application Builds with Cloud Native Buildpacks
Streamlining Your Application Builds  with Cloud Native BuildpacksStreamlining Your Application Builds  with Cloud Native Buildpacks
Streamlining Your Application Builds with Cloud Native Buildpacks
 
Understanding Native Mobile App Development
Understanding Native Mobile App DevelopmentUnderstanding Native Mobile App Development
Understanding Native Mobile App Development
 
AI Embracing Every Shade of Human Beauty
AI Embracing Every Shade of Human BeautyAI Embracing Every Shade of Human Beauty
AI Embracing Every Shade of Human Beauty
 
online pdf editor software solutions.pdf
online pdf editor software solutions.pdfonline pdf editor software solutions.pdf
online pdf editor software solutions.pdf
 
Vectors are the new JSON in PostgreSQL (SCaLE 21x)
Vectors are the new JSON in PostgreSQL (SCaLE 21x)Vectors are the new JSON in PostgreSQL (SCaLE 21x)
Vectors are the new JSON in PostgreSQL (SCaLE 21x)
 
React 19: Revolutionizing Web Development
React 19: Revolutionizing Web DevelopmentReact 19: Revolutionizing Web Development
React 19: Revolutionizing Web Development
 
Watermarking in Source Code: Applications and Security Challenges
Watermarking in Source Code: Applications and Security ChallengesWatermarking in Source Code: Applications and Security Challenges
Watermarking in Source Code: Applications and Security Challenges
 
Salesforce AI Associate Certification.pptx
Salesforce AI Associate Certification.pptxSalesforce AI Associate Certification.pptx
Salesforce AI Associate Certification.pptx
 
Top Software Development Trends in 2024
Top Software Development Trends in  2024Top Software Development Trends in  2024
Top Software Development Trends in 2024
 
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...
 
IA Generativa y Grafos de Neo4j: RAG time
IA Generativa y Grafos de Neo4j: RAG timeIA Generativa y Grafos de Neo4j: RAG time
IA Generativa y Grafos de Neo4j: RAG time
 
How Does the Epitome of Spyware Differ from Other Malicious Software?
How Does the Epitome of Spyware Differ from Other Malicious Software?How Does the Epitome of Spyware Differ from Other Malicious Software?
How Does the Epitome of Spyware Differ from Other Malicious Software?
 
Deep Learning for Images with PyTorch - Datacamp
Deep Learning for Images with PyTorch - DatacampDeep Learning for Images with PyTorch - Datacamp
Deep Learning for Images with PyTorch - Datacamp
 
OpenChain Webinar: Universal CVSS Calculator
OpenChain Webinar: Universal CVSS CalculatorOpenChain Webinar: Universal CVSS Calculator
OpenChain Webinar: Universal CVSS Calculator
 
New ThousandEyes Product Features and Release Highlights: March 2024
New ThousandEyes Product Features and Release Highlights: March 2024New ThousandEyes Product Features and Release Highlights: March 2024
New ThousandEyes Product Features and Release Highlights: March 2024
 
ERP For Electrical and Electronics manufecturing.pptx
ERP For Electrical and Electronics manufecturing.pptxERP For Electrical and Electronics manufecturing.pptx
ERP For Electrical and Electronics manufecturing.pptx
 
Cybersecurity Challenges with Generative AI - for Good and Bad
Cybersecurity Challenges with Generative AI - for Good and BadCybersecurity Challenges with Generative AI - for Good and Bad
Cybersecurity Challenges with Generative AI - for Good and Bad
 
Your Vision, Our Expertise: TECUNIQUE's Tailored Software Teams
Your Vision, Our Expertise: TECUNIQUE's Tailored Software TeamsYour Vision, Our Expertise: TECUNIQUE's Tailored Software Teams
Your Vision, Our Expertise: TECUNIQUE's Tailored Software Teams
 

Taking Kotlin to production, Seriously

  • 1. Haim Yadid / Next Insurance mapOf( taking?. kotlin to production ) Seriously!!
  • 2. Disclaimer ‫בה‬ ‫לנאמר‬ ‫לייחס‬ ‫ואין‬ ‫סאטירה‬ ‫תוכנית‬ ‫הינה‬ ‫זו‬ ‫תוכנית‬ ‫כלשהי‬ ‫תכנות‬ ‫בשפת‬ ‫לפגוע‬ ‫ניסיון‬ ‫או‬ ‫אחרת‬ ‫משמעות‬ ‫שום‬ ‫בה‬ ‫המופיעים‬ ‫מהתכנים‬ ‫נפגע‬ ‫חש‬ ‫הנך‬ ‫זאת‬ ‫בכל‬ ‫אם‬ ‫מראש‬ ‫מתנצלים‬ ‫אנו‬ ‫בסקאלה‬ ‫מתכנת‬ ‫אתה‬ ‫אם‬ ‫או‬
  • 3. About Me ❖ Developing software since 1984 (Boy, am I getting old?) ❖ Basic -> Pascal -> C -> C++ -> Java -> Kotlin ❖ Architect in Mercury ❖ Independent performance expert for 7 years ❖ Backend developer in
  • 4. ❖ Founded in the Beginning of 2016 ❖ HQ@Palo Alto RnD@Kfar Saba ❖ Aims to disrupt the Small businesses insurance field ❖ Providing online experience which is simple fast and transparent ❖ We started to write real code on May 2016
  • 6. What is Kotlin ? ❖ Statically typed programming language ❖ for the JVM, Android and the browser (JS) ❖ 100% interoperable with Java™ (well almost) ❖ Developed by Jetbrains ❖ Revealed as an open source in July 2011 ❖ v1.0 Release on Feb 2016 ❖ 1.0.5 current stable version (28.11.2016)
  • 7. Kotlin Features ❖ Concise ❖ Safe ❖ Versatile ❖ Practical ❖ Interoperable
  • 8. Why Kotlin Java Scala Cloju Groovy/ JRuby Java8 Strongly
 Typed Loosely
 Typed OO/verbose Functional/Rich )))))))))))))))))))))))))))))))
  • 9. Why Kotlin Java Scala Cloju Groovy/ JRuby Java8 Strongly
 Typed Loosely
 Typed OO/verbose Functional/Rich Kotlin )))))))))))))))))))))))))))))))
  • 10. Scala can do it !! ? ❖ Yes Scala can do it ❖ Academic / Complicated ❖ Scala compile time is horrific ❖ Operator overloading -> OMG
  • 11. Getting Started ❖ Kotlin has very lightweight standard library ❖ Mostly rely on Java collections for good (interop) and for bad (all the rest) ❖ Kotlin compiles to Java6 byte code ❖ Has no special build tool just use Maven / Gradle
  • 12. Kotlin & Android ❖ Kotlin got widely accepted on the android community ❖ Runtime has low footprint ❖ Compiles to …. Java 6 ❖ Brings lambdas to Android dev and a lot of cool features
  • 13. Trivial Stuff ❖ No new keyword ❖ No checked exceptions ❖ == structural equality ❖ === referencial equality ❖ No primitives (only under the hood) ❖ No arrays they are classes ❖ Any ~ java.lang.Object
  • 14. Fun ❖ Functions are denoted with the fun keyword ❖ They can be member of a class ❖ Or top level functions inside a kotlin file ❖ can support tail recursion ❖ can be inlined ❖ fun funny(funnier: String) = "Hello world"
  • 15. Fun Parameters ❖ Pascal notation ❖ Function parameters may have default values ❖ Call to function can be done using parameter names fun mergeUser(first: String = "a", last: String) = first + last
 
 fun foo() {
 mergeUser(first="Albert",last= "Einstein")
 mergeUser(last= "Einstein")
 }
  • 16. Extension functions ❖ Not like ruby monkey patching ❖ Only extend functionality cannot override ❖ Not part of the class ❖ Static methods with the receiver as first a parameter fun String.double(sep: String) = "$this$sep$this"
  • 17. ❖ variables are declared using the keywords ❖ val (immutable) ❖ var (mutable) ❖ fun funny(funnier: String): String {
 val x = "Hello world"
 return x
 } val /var
  • 18. Classes ❖ less verbose than Java ❖ no static members (use companion object) ❖ public is default ❖ Must be declared open to be overridden ❖ override keyword is mandatory class Producer(val name:String, val value: Int)
  • 19. Properties ❖ All members of classes are access via proper accessors (getter and setters) ❖ The usage of getters and setters is implicit ❖ one can override implementation of setters and getters
  • 20. Delegate Class interface Foo {
 fun funfun()
 }
 
 class FooImpl(val x: Int) : Foo {
 override fun funfun() = print(x)
 }
 
 class Wrapper(f: Foo) : Foo by f
 
 fun main(args: Array<String>) {
 val f = FooImpl(10)
 val wf = Wrapper(f)
 wf.funfun() // prints 10
 }
  • 21. Smart Casts ❖ If you check that a class is of a certain type no need to cast it open class A {
 fun smile() { println(":)")}
 }
 
 class B : A() {
 fun laugh() = println("ha ha ha")
 }
 
 fun funnier(a: A) {
 if (a is B ) {
 a.laugh()
 }
 }
  • 22. Null Safety ❖ Nullability part of the type of an object ❖ Option[T] Optional<T> ❖ Swift anyone ? var msg : String = "Welcome"
 msg = null val nullableMsg : String? = null
  • 23. Safe operator ?. ❖ The safe accessor operator ?. will result null ❖ Elvis operator for default fun funny(funnier: String?): Int? {
 
 println(x?.length ?: "")
 return x?.length
 }
  • 24. Bang Bang !! ❖ The bang bang !! throws an NPE if object is null fun funny(funnier: String?): String {
 return funnier!!
 }
  • 25. Data classes ❖ Less powerful version of to case classes in Scala ❖ Implementation of ❖ hashcode() equals() ❖ copy() ❖ de structuring (component1 component2 …) data class User(val firstName: String, val lastName: String)
 
 fun smile(user: User) {
 val (first,last) = user
 }
  • 26. When ❖ Reminds Scala’s pattern matching but not as strong ❖ More capable than select in java when (x) {
 is Int -> print(x + 1)
 is String -> print(x.length + 1)
 is IntArray -> print(x.sum())
 }
  • 27. Sane Operator Overloading ❖ override only a set of the predefined operators ❖ By implementing the method with the correct name Expression Translated to a + b a.plus(b) a - b a.minus(b) a * b a.times(b) a / b a.div(b) a % b a.mod(b) a..b a.rangeTo(b)
  • 28. Sane Operator Overloading data class Complex(val x: Double, val y: Double) {
 operator fun inc(): Complex {
 return Complex(x + 1, y + 1)
 }
 
 infix operator fun plus(c: Complex): Complex {
 return (Complex(c.x + x, c.y + y))
 }
 
 }
  • 29. Collections ❖ no language operators for construction of lists and maps ❖ using underlying java collections ❖ Have two versions mutable and immutable ❖ Immutability is a lie at least ATM it is only an immutable view of a mutable collection.
  • 30. Collections val chars = mapOf("Terion" to "Lannister", "John" to "Snow")
 chars["Terion"]
 chars["Aria"] = “Stark" 
 
 val chars2 = mutableMapOf<String,String>()
 chars2["A girl"] = "has no name"
 
 val sigils = listOf("Direwolf", "Lion", "Dragon", "Flower")
 println(sigils[0])
  • 31. Kotlin 1.1 ❖ Java 7/8 support -> generate J8 class files ❖ Coroutines : async / await (stackless continuations) ❖ Generators: Yield ❖ inheritance of data classes
  • 32. Generators (yield) val fibonacci: Sequence<Int> = generate { yield(1) // first Fibonacci number var cur = 1 var next = 1 while (true) { yield(next) // next Fibonacci number val tmp = cur + next cur = next next = tmp } }