SlideShare a Scribd company logo
1 of 33
Download to read offline
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?

More Related Content

What's hot

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
Bartosz Kosarzycki
 
The Kotlin Programming Language
The Kotlin Programming LanguageThe Kotlin Programming Language
The Kotlin Programming Language
intelliyole
 
Kotlin Slides from Devoxx 2011
Kotlin Slides from Devoxx 2011Kotlin Slides from Devoxx 2011
Kotlin Slides from Devoxx 2011
Andrey Breslav
 

What's hot (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
 

Viewers also liked

Viewers also liked (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)
 

Similar to Taking Kotlin to production, Seriously

Polyglot Programming @ Jax.de 2010
Polyglot Programming @ Jax.de 2010Polyglot Programming @ Jax.de 2010
Polyglot Programming @ Jax.de 2010
Andres Almiray
 
Polyglot Programming in the JVM
Polyglot Programming in the JVMPolyglot Programming in the JVM
Polyglot Programming in the JVM
Andres Almiray
 

Similar to 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...
 

More from Haim Yadid

More from 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
 

Recently uploaded

%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 

Recently uploaded (20)

tonesoftg
tonesoftgtonesoftg
tonesoftg
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 

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 } }