SlideShare a Scribd company logo
1 of 67
Download to read offline
Kotlin: maybe it’s the right time
Davide Cerbo - Entaksi
CODEMOTION MILAN - SPECIAL EDITION
10 – 11 NOVEMBER 2017
Chi sono
Hi, my name is Davide and I’m
writing bad code since I was 7.
Since 2003 I’m paid for that.
Disclaimer
Here we have a lot of println, and some jokes.
My wife said that they aren’t funny.
C’era una volta OAK
It was 1992 and in Italy there
was a big scandal: Tangentopoli.
C’era una volta OAK Java
Borns in 1995
and now can
drink beers.
Il grande problema
Backward
compatibility
(The art of killing your app because the
environment evolve while you can’t)
JDK 1.0 (21 january 1996)
JDK 1.1 (19 february 1997)
J2SE 1.2 (8 december 1998)
J2SE 1.3 (8 my 2000)
J2SE 1.4 (6 february 2002)
J2SE 5.0 (30 september 2004)
Java SE 6 (11 december 2006)
Java SE 7 (28 july 2011)
Java SE 8 (18 march 2014)
Java SE 9 (26 september 2017)
Tutte compatibili!
JVM != Java
JAVA JVM
JVM != Java
class Hello {
fun sayHello(): String {
return "hello!"
}
}
public final class Hello {
// access flags 0x11
public final sayHello()Ljava/lang/String;
@Lorg/jetbrains/annotations/NotNull;() // invisible
L0
LINENUMBER 8 L0
LDC "hello!"
ARETURN
L1
LOCALVARIABLE this Ltotest/Hello; L0 L1 0
MAXSTACK = 1
MAXLOCALS = 1
// access flags 0x1
public <init>()V
L0
LINENUMBER 6 L0
ALOAD 0
INVOKESPECIAL java/lang/Object.<init> ()V
RETURN
L1
LOCALVARIABLE this L/Hello; L0 L1 0
MAXSTACK = 1
MAXLOCALS = 1
@Lkotlin/Metadata;(mv={1, 1, 1}, bv={1, 0, 2}, k=1,
d1={"u0000u0012nu0002u0018u0002nu0002u0010u0000nu0002
u0008u0002nu0002u0010u000enu0000u0018u00002u00020u00
01Bu0005u00a2u0006u0002u0010u0002Ju0006u0010u0003u001
au00020u0004u00a8u0006u0005", d2={"L/Hello;", "", "()V",
"sayHello", "", "production sources for module coroutine_main"})
// compiled from: Hello.kt
}
@Metadata(
mv = {1, 1, 7},
bv = {1, 0, 2},
k = 1,
d1 =
{"u0000u0012nu0002u0018u0002nu0002
u0005¢u0006u0002u0010u0002Ju0006u00
d2 = {"Ltotest/Hello;", "", "()V", "sayHello", "", "
)
public final class Hello {
@NotNull
public final String sayHello() {
return "hello!";
}
}
Compile Decompile
Machine code is not enought?
Assembly languages
Machine code
Logic languages
(Prolog)
Functional languages
(Haskell)
Procedural languages
(C)
Object-oriented languages
(Java)
The Case for Kotlin and Ceylon by Russel Winder
https://www.youtube.com/watch?v=cFL_DDXBkJQ
Why Kotlin?
Hey! People said the same about Scala in the
past. So why not Scala?
So, why not Scala?
Kotlin is a better Java while Scala is more powerful than Java, and
probably than Kotlin. But, Kotlin borns in the industry for the industry
and it evolves with the industry in mind, while Scala borns at the
university and it is adapted to the industry. Unfortunately, we work
for the industry.
https://agilewombat.com/2016/02/01/scala-vs-kotlin/
https://superkotlin.com/kotlin-vs-scala/
Kotlin is a statically-typed programming
language that runs on the Java Virtual Machine
and also can be compiled to JavaScript source
code or uses the LLVM compiler infrastructure.
https://dzone.com/articles/why-learn-kotlin-infographic
Since 2010(2012): KOTLIN!
04 Gennaio 2017
Introducing Kotlin support
in Spring Framework 5.0
https://spring.io/blog/2017/01/04/introducing-kotlin-support-in-spring-framework-5-0
https://github.com/sdeleuze/spring-kotlin-deepdive
17 Maggio 2017
Kotlin on Android. Now official
https://blog.jetbrains.com/kotlin/2017/05/kotlin-on-android-now-official/
http://nilhcem.com/swift-is-like-kotlin/
5 Giugno 2017
kotlin-react borns!
https://github.com/JetBrains/kotlin-wrappers/commits/master/kotlin-react
https://github.com/JetBrains/create-react-kotlin-app
1.0 Release
1.1 Release
Kotlin is born
Gradle
Android
Official
Spring
Statische download
Please shutdown the lights
Var o Val
var serie = "B"
var a = "Salernitana will win Serie $serie"
val b = "Salernitana will win Serie $serie"
Fun
fun main(args: Array<String>){
hello("Davide", "Salerno")
}
fun hello(name: String, city: String){
println("Hello $name from $city")
}
Fun fun functions
fun hello(name: String, city: String = "Salerno") = println("Hello $name from $city")
hello("Davide", "Salerno")
hello(name = "Davide")
hello(city = "Salerno", name = "Valentina")
fun Int.multilpy(x: Int): Int = this * x // 5.multilpy(10)
infix fun Int.multilpy(x: Int): Int = this * x // 5 multilpy 10
Aiuta anche nel refactoring!
E gli operatori?
data class Point(val x: Int, val y: Int) {
operator fun plus(a: Point) = Point(x + a.x, y + a.y)
}
operator fun Point.unaryMinus() = Point(-x, -y)
val point = Point(10, 20)
println(point + point + point) //Point(x=30, y=60)
println(-point) // Point(x=-10, y=-20)
Tailrec
● Rercursion, in some language, can cause: StackOverflow!
● Reduce stack execution.
● Tailrec will resolve this issue only if the recursive call is the last one.
● How? Transform your code in imperative code. Less readable, but more fast.
● Performance improvement
fun factorial(n: Long): Long = if (n <= 1L) n else n * factorial(n - 1)
tailrec fun factorial(n: Long, accumulator: Long = 1): Long = if (n <= 1L) accumulator
else factorial(n - 1, accumulator * n)
Tailrec cannot
applicable
“If” will return the verified condition value
Tailrec decompiled
public static final long factorial(long n, long accumulator) {
while(n > 1L) {
long var10000 = n - 1L;
accumulator *= n;
n = var10000;
}
return accumulator;
}
public static long factorial$default(long var0, long var2, int var4, Object
var5) {
if((var4 & 2) != 0) {
var2 = 1L;
}
return factorial(var0, var2);
}
}
public static final long factorial(long n, long accumulator) {
return n <= 1L?accumulator:factorial(n - 1L, accumulator * n);
}
public static long factorial$default(long var0, long var2, int var4, Object
var5) {
if((var4 & 2) != 0) {
var2 = 1L;
}
return factorial(var0, var2);
}
With
Tailrec
Without
Tailrec
StackOverflow
Tools > Kotlin > Show Kotlin Bytecode > Decompile
Class
open class Person(val name: String) {
init { println("init…") }
open fun speak() { println("Hi $name!") }
infix fun and(o: Person) = "Hi ${o.name} & ${this.name}"
}
fun main(args: Array<String>) {
Person("Davide") and Person("Valentina")
val p = Person("Jack")
p.speak()
}
Class
class Customer(name: String) : Person(name) {
override fun speak() {
println("Welcome $name!")
}
}
class CustomerDavide : Person("Davide") {
override fun speak() {
println("Welcome $name!")
}
}
Equals, hashCode, toString e copy, nevermore!
data class User(val name: String, val age: Int)
val davide = User("Davide", 35)
val davideJunior = davide.copy(age=0)
fun main(args: Array<String>) {
val (name, age) = davide
println("$name $age years old")
}
deconstructing
Nothing is equal as appear
data class Point(val x: Int, val y: Int)
val a = Point(1, 2)
val b = Point(1, 2)
val c = a
println(a === b) // false
println(a == b) // true
println(a === c) // true
println(a == c) // true
Controlla il riferimento
.equals(...)
Lambda
fun main(args: Array<String>) {
arrayOf("Valentina", "Davide").forEach { println("Hello $it!") }
val ints = arrayOf(1, 2, 3)
val logger = { msg: Any -> println("log $msg") }
ints.map { value -> value * 2 }.map { v -> logger(v) }
ints.map { it * 2 }.map { logger(it) }
}
Lambda
class Customer(val name: String) {
fun forEach(action: (char: Char) -> Unit) = name.forEach(action)
fun hello(callback: (name: String) -> Unit) = callback(name)
fun upperCaseAndConcat(callback: () -> String) = "${callback()} $name".toUpperCase()
}
fun main(args: Array<String>) {
val customer = Customer("Davide")
customer.hello { println("Ciao $it") }
println(customer.upperCaseAndConcat { "Cerbo" })
customer.forEach { println(it) }
}
È il tipo con un solo valore vuoto.
Corrisponde a void in Java.
Lambda & Function Label
fun forEachTest() {
val numbers = 1..100
numbers.forEach {
if (it == 25) {
return
}
println("index $it")
}
println("Hello")
}
fun forEachTest() {
val numbers = 1..100
numbers.forEach {
if (it == 25) {
return@forEach
}
println("index $it")
}
println("Hello")
}
Vs.
Tell me when, when?
fun describe(obj: Any): String = when (obj) {
1 -> "One"
"Hello" -> "Greeting"
is Long -> "Long"
!is String -> "Not a string"
else -> "Unknown"
}
describe(Person("davide"))
Null is safe!
var testA:String = "ciao"
var testB:String? = "ciao"
testB = null
val nullableList: List<Int?> =
listOf(1, 2, null, 4)
val intList: List<Int> =
nullableList.filterNotNull()
println("a0 ${testA.length}")
println("a1 ${testA?.length}")
println("a2 ${testA!!.length}")
println("b0 ${testB.length}")
// ^ Not safe! Compile time error! ^
println("b1 ${testB?.length}")
println("b2 ${testB!!.length}")
// ^ KotlinNullPointerException ^
// NPE Lovers
Null is safe!
val nullableList: List<Int?> = listOf(1, 2, null, 4)
val intList: List<Int> = nullableList.filterNotNull() // [1, 2, 4]
val aInt: Int? = b as? Int
// If b is null, normally we will will have a NullPointerException, while if the type is
differente we will have a ClassCastExeption. Usin “as?” we haven’t exception, we
will have a null value assigned to the aInt value.
Null è sicuro
data class Person(val name: String, val age: Int?)
val person:Person? = Person("Jack", 1)
if (person?.age != null) {
println("The person is aged ${person?.age}")
}
//oppure
person?.age?.let {
println("The person is aged $it")
}
?:
Elvis operator
val davide = Person(testA)
val elvis = Person(testB ?: "Elvis")
println(jack.name)
Get & Set
class Strange(var value: Long) {
var strangeValue: Long
get() = value * 2
set(value){
if(value > 5) this.value = value
}
}
fun main(args: Array<String>) {
val customer = Strange(10)
println(customer.strangeValue) //20
customer.strangeValue = 3
println(customer.strangeValue) //20
customer.strangeValue = 6
println(customer.strangeValue) //12
}
Delegated properties: non può farlo qualcun altro?
class Delegate {
operator fun getValue(thisRef: Any?, property: KProperty<*>): String {
return "$thisRef, thank you for delegating '${property.name}' to me!"
}
operator fun setValue(thisRef: Any?, property: KProperty<*>, value: String) {
println("$value has been assigned to '${property.name} in $thisRef.'")
}
}
class Example {
var p: String by Delegate()
}
Delegated properties: il pigro e l’osservabile
val lazyValue: String by lazy {
println("computed!")
"Hello"
}
fun main(args: Array<String>) {
println(lazyValue)
println(lazyValue)
}
class User {
var n: String by Delegates.observable("empty") {
prop, old, new -> println("$old -> $new")
}
}
fun main(args: Array<String>) {
val user = User()
user.n = "first"
user.n = "second"
}
Coroutine
Coroutine ⋍ light-weight thread
● Are like threads, they run in parallel, wait for each other and they communicate.
● Area cheap, we can create many of those without having performance issues.
● Are executed in a thread pool.
● A thread can handle more than one coroutine.
● The thread became free while a coroutine is in waiting when the coroutine will return active, it
will use a free thread in the pool.
https://github.com/Kotlin/kotlinx.coroutines/blob/master/coroutines-guide.md
https://proandroiddev.com/approaching-kotlin-coroutines-an-extensive-feature-concurrent-programming-in-kotlin-eaaa19b003d2
Coroutine sono oneste
fun main(args: Array<String>) = runBlocking {
val jobs = List(100_000) {
launch {
delay(1000L)
print(".")
}
}
jobs.forEach { it.join() }
}
fun main(args: Array<String>) {
val jobs = List(100_000) {
thread(start = true) {
Thread.sleep(1000L)
print(".")
}
}
jobs.forEach { it.join() }
}
OUT OF MEMORY!!!
Coroutine: suspend, async / await
fun main(args: Array<String>) = runBlocking<Unit> {
val time = measureTimeMillis {
val one = doSomethingUsefulOne()
val two = doSomethingUsefulTwo()
println("The answer is ${one + two}")
}
println("Completed in $time ms")
}
suspend fun doSomethingUsefulOne(): Int {
delay(1000L)
return 13
}
suspend fun doSomethingUsefulTwo(): Int {
delay(1000L)
return 29
}
fun main(args: Array<String>) = runBlocking<Unit> {
val time = measureTimeMillis {
val one = async { doSomethingUsefulOne() }
val two = async { doSomethingUsefulTwo() }
println("The answer is ${one.await() + two.await()}")
}
println("Completed in $time ms")
}
suspend fun doSomethingUsefulOne(): Int {
delay(1000L)
return 13
}
suspend fun doSomethingUsefulTwo(): Int {
delay(1000L)
return 29
}
~2 sec.
~1 sec.
Coroutine is the basement
Coroutine
Actors
Communication
Sequence
Process
?
Testing
class GreeterTest {
@Mock
lateinit var user: User
lateinit var tested: Greeter
@Before
fun setUp() {
MockitoAnnotations.initMocks(this)
tested = Greeter(user)
}
@Test
fun englishGreetIsCorrect() {
whenever(user.fullName()).thenReturn("Codemotion")
assertEquals("Hello Codemotion!", tested.getGreeting())
}
}
all values are final by default. With lateinit the
compiler knows that someone will intialize it later.
Mockito.`when` is not the best choice with Kotlin. The
cause is that Kotlin avoid null, and can cause issues with
.any() mehtod. The “whenever” method is part of
mockito-kotlin libary.
backticks are used when
the method name is a
reserved word.
Testing: Mockito-Kotlin
class GreeterTest {
val user: User = mock {
on { fullName() }.then { "Codemotion" }
}
val tested: Greeter = Greeter(user)
@Test
fun `english greeting is correct`() {
assertEquals("Hello, Codemotion!", tested.getGreeting())
}
}
Testing: Kluent
class GreeterTest3 {
val user: User = mock {
on { fullName() }.then { "Codemotion" }
}
val tested: Greeter = Greeter(user)
@Test
fun `english greeting is correct`() {
tested.getGreeting() `should equal` "Hello, Codemotion!"
}
@Test
fun `cannot smoke`() {
val davide = User("Davide", "Cerbo")
val davideSmoke = { davide.smoke() }
davideSmoke `should throw` RuntimeException::class `with message` "Cannot smoke!"
}
}
Testing
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
testCompile "org.mockito:mockito-core:2.8.9"
testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
testCompile 'de.jodamob.kotlin:kotlin-runner-junit4:0.3.1'
testCompile "com.nhaarman:mockito-kotlin-kt1.1:1.5.0"
testCompile 'org.amshove.kluent:kluent:1.30'
}
https://proandroiddev.com/improve-your-tests-with-kotlin-in-android-pt-1-6d0b04017e80
https://proandroiddev.com/improve-your-tests-with-kotlin-in-android-pt-2-f3594e5e7bfd
https://proandroiddev.com/improve-your-tests-with-kotlin-in-android-pt-3-104e1c9f77cc
Now is the time to remember that Kotlin is good
because the trade-off between synthesis and
readable code is really good.
Automatic restart
Webapp: Gradle
buildscript {
...
dependencies {
...
classpath "org.jetbrains.kotlin:kotlin-noarg:$kotlinVersion"
}
}
...
apply plugin: "kotlin-jpa"
group = 'it.devday'
version = '0.0.1-SNAPSHOT'
...
}
JPA need an empty constructor in some entities,
and Kotlin objects don’t have. To solve this issue
we can use this plugin that will create an empty
constructor in any object, without any change to
our codebase.
Webapp: Domain & Repository
import it.devday.kotlincodemotion.domain.Contact
import org.springframework.data....JpaRepository
interface ContactRepository: JpaRepository<Contact, Long>
import javax.persistence.Entity
import javax.persistence.GeneratedValue
import javax.persistence.Id
@Entity
data class Contact(
@Id
@GeneratedValue
val id: Long,
val name: String,
val surname: String)
Webapp: Resource 1/2
@RestController
@RequestMapping("/contacts")
class ContactResource(val contactRepository: ContactRepository) {
@GetMapping //curl -XGET http://localhost:8080/contacts
fun getAll() = contactRepository.findAll()
@GetMapping("/{id}") //curl -XGET http://localhost:8080/contacts/1
fun getAll(@PathVariable id: Long) = contactRepository.findById(id)
Webapp: Resource 2/2
@PostMapping //curl -XPOST http://localhost:8080/contacts -H 'Content-Type: application/json' -d
'{"name":"Davide", "surname":"Cerbo"}'
fun insert(@RequestBody contact: Contact) = contactRepository.save(contact)
@DeleteMapping("/{id}") //curl -XDELETE http://localhost:8080/contacts/1
fun delete(@PathVariable id: Long) {
val contact = contactRepository.findById(id).unwrap()
contact?.let { contactRepository.delete(contact) }
}
}
aspetta...unwrap() non esiste su Optional
Webapp: Application
@SpringBootApplication
class KotlinCodemotionApplication
fun <T> Optional<T>.unwrap(): T? = orElse(null)
fun main(args: Array<String>) {
runApplication<KotlinCodemotionApplication>(*args)
}
ecco unwrap()!
array is passed element by element, it is used with vararg arguments
public inline fun <reified T : kotlin.Any> runApplication(vararg args: kotlin.String)
The generic type will be avaible in the method. Wow!
Hey, I’m a frontend developer,
where is my code?
$ create-react-kotlin-app kotlin-codemotion-front
$ cd kotlin-codemotion-from
$ yarn start
https://github.com/jetbrains/create-react-kotlin-app
https://github.com/JetBrains/kotlin-wrappers/blob/master/kotlin-react/README.md
https://github.com/JetBrains/kotlin-wrappers/blob/master/kotlin-react-dom/README.md
https://github.com/Kotlin/kotlin-fullstack-sample
https://github.com/JetBrains/kotlinconf-app
https://blog.frankel.ch/kotlin-front-end-developers/#gsc.tab=0
https://github.com/sdeleuze/spring-kotlin-deepdive
Kotlin React: Application
React is a framework made by Facebook to build UI. Is the
View in the MVC pattern.
It simple associate a state to a specific UI. Your UI will change
regarding your state.
Kotlin React: Stop! What is React?
{name: “Davide”, color: “red”}
Hi Davide!
{name: “Jack”, color: “green”}
Hi Jack!
Kotlin React: Application: Component definition
interface ContactListProps : RProps {
var owner: String
}
interface ContactListState : RState {
var list: Array<Contact>
}
class ContactList(props: ContactListProps) : RComponent<ContactListProps, ContactListState>(props) {
override fun ContactListState.init(props: ContactListProps) {
list = emptyArray()
}
...
Kotlin React: Application: Data loading
override fun componentDidMount() {
async {
val listData = httpGet("/contacts")
setState { list = JSON.parse<Array<Contact>>(listData) }
}
}
remember to define the proxy in package.json:
"proxy": "http://localhost:8080"
Kotlin React: Application: UI rendering
override fun RBuilder.render() {
div("ContactList-header") {
key = "contactListHeader"
h2 { +"${props.owner}'s contact list" }
ul {
for (c in state.list) {
li { +"${c.id}: ${c.name} ${c.surname}" }
}
}
} } }
fun RBuilder.contactList(owner: String = "No-name") = child(ContactList::class) {
attrs.owner = owner
}
STOP!
What we miss?
● Spring WebFlux
● Reactor
● Android + Kotlin
● Native + Kotlin
#byebyejava
Everything is here:
https://github.com/jesty/kotlin-fossavotabona
Questions
@davide_cerbo
@devdayit
http://slack.devday.it
Useful resources
https://kotlinlang.org/docs/reference/
https://spring.io/blog/2017/01/04/introducing-kotlin-support-in-spring-framework-5-0
https://blog.jetbrains.com/kotlin/2017/05/kotlin-on-android-now-official/
https://dev.to/lovis/gang-of-four-patterns-in-kotlin
https://github.com/volodymyrprokopyuk/kotlin-sdp
https://github.com/gradle/gradle-script-kotlin
https://speakerdeck.com/sdeleuze/functional-web-applications-with-spring-and-kotlin
https://kotlinlang.org/docs/tutorials/httpservlets.html
http://thetechnocafe.com/more-about-functions-in-kotlin/
https://nklmish.wordpress.com/2017/10/22/deprecated-in-kotlin/
https://kotlinlang.org/docs/tutorials/command-line.html
https://agilewombat.com/2016/02/01/scala-vs-kotlin/
https://superkotlin.com/kotlin-vs-scala/
https://kotlinlang.org/docs/reference/type-safe-builders.html
Useful resources

More Related Content

What's hot

Starting with Scala : Frontier Developer's Meetup December 2010
Starting with Scala : Frontier Developer's Meetup December 2010Starting with Scala : Frontier Developer's Meetup December 2010
Starting with Scala : Frontier Developer's Meetup December 2010Derek Chen-Becker
 
Introduction to Scala for JCConf Taiwan
Introduction to Scala for JCConf TaiwanIntroduction to Scala for JCConf Taiwan
Introduction to Scala for JCConf TaiwanJimin Hsieh
 
An introduction to scala
An introduction to scalaAn introduction to scala
An introduction to scalaXing
 
Feel of Kotlin (Berlin JUG 16 Apr 2015)
Feel of Kotlin (Berlin JUG 16 Apr 2015)Feel of Kotlin (Berlin JUG 16 Apr 2015)
Feel of Kotlin (Berlin JUG 16 Apr 2015)intelliyole
 
Kotlin Basics - Apalon Kotlin Sprint Part 2
Kotlin Basics - Apalon Kotlin Sprint Part 2Kotlin Basics - Apalon Kotlin Sprint Part 2
Kotlin Basics - Apalon Kotlin Sprint Part 2Kirill Rozov
 
Kotlin: forse è la volta buona (Trento)
Kotlin: forse è la volta buona (Trento)Kotlin: forse è la volta buona (Trento)
Kotlin: forse è la volta buona (Trento)Davide Cerbo
 
Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)Jonas Bonér
 
Scala for Java programmers
Scala for Java programmersScala for Java programmers
Scala for Java programmers輝 子安
 
An Introduction to Scala (2014)
An Introduction to Scala (2014)An Introduction to Scala (2014)
An Introduction to Scala (2014)William Narmontas
 
Kotlin: a better Java
Kotlin: a better JavaKotlin: a better Java
Kotlin: a better JavaNils Breunese
 
Taking the boilerplate out of your tests with Sourcery
Taking the boilerplate out of your tests with SourceryTaking the boilerplate out of your tests with Sourcery
Taking the boilerplate out of your tests with SourceryVincent Pradeilles
 
Polyglot Programming in the JVM
Polyglot Programming in the JVMPolyglot Programming in the JVM
Polyglot Programming in the JVMAndres Almiray
 
Idiomatic Kotlin
Idiomatic KotlinIdiomatic Kotlin
Idiomatic Kotlinintelliyole
 
Kotlin Programming Language. What it is all about. Roman Belov, PMM in Kotlin
Kotlin Programming Language. What it is all about. Roman Belov, PMM in KotlinKotlin Programming Language. What it is all about. Roman Belov, PMM in Kotlin
Kotlin Programming Language. What it is all about. Roman Belov, PMM in KotlinJetBrains Russia
 

What's hot (19)

Starting with Scala : Frontier Developer's Meetup December 2010
Starting with Scala : Frontier Developer's Meetup December 2010Starting with Scala : Frontier Developer's Meetup December 2010
Starting with Scala : Frontier Developer's Meetup December 2010
 
Introduction to Scala for JCConf Taiwan
Introduction to Scala for JCConf TaiwanIntroduction to Scala for JCConf Taiwan
Introduction to Scala for JCConf Taiwan
 
An introduction to scala
An introduction to scalaAn introduction to scala
An introduction to scala
 
Scala vs java 8
Scala vs java 8Scala vs java 8
Scala vs java 8
 
Joy of scala
Joy of scalaJoy of scala
Joy of scala
 
Feel of Kotlin (Berlin JUG 16 Apr 2015)
Feel of Kotlin (Berlin JUG 16 Apr 2015)Feel of Kotlin (Berlin JUG 16 Apr 2015)
Feel of Kotlin (Berlin JUG 16 Apr 2015)
 
Kotlin Basics - Apalon Kotlin Sprint Part 2
Kotlin Basics - Apalon Kotlin Sprint Part 2Kotlin Basics - Apalon Kotlin Sprint Part 2
Kotlin Basics - Apalon Kotlin Sprint Part 2
 
Kotlin: forse è la volta buona (Trento)
Kotlin: forse è la volta buona (Trento)Kotlin: forse è la volta buona (Trento)
Kotlin: forse è la volta buona (Trento)
 
Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)
 
Scala for Java programmers
Scala for Java programmersScala for Java programmers
Scala for Java programmers
 
Polyglot JVM
Polyglot JVMPolyglot JVM
Polyglot JVM
 
An Introduction to Scala (2014)
An Introduction to Scala (2014)An Introduction to Scala (2014)
An Introduction to Scala (2014)
 
scala
scalascala
scala
 
Kotlin: a better Java
Kotlin: a better JavaKotlin: a better Java
Kotlin: a better Java
 
Taking the boilerplate out of your tests with Sourcery
Taking the boilerplate out of your tests with SourceryTaking the boilerplate out of your tests with Sourcery
Taking the boilerplate out of your tests with Sourcery
 
Polyglot Programming in the JVM
Polyglot Programming in the JVMPolyglot Programming in the JVM
Polyglot Programming in the JVM
 
Idiomatic Kotlin
Idiomatic KotlinIdiomatic Kotlin
Idiomatic Kotlin
 
Kotlin Programming Language. What it is all about. Roman Belov, PMM in Kotlin
Kotlin Programming Language. What it is all about. Roman Belov, PMM in KotlinKotlin Programming Language. What it is all about. Roman Belov, PMM in Kotlin
Kotlin Programming Language. What it is all about. Roman Belov, PMM in Kotlin
 
Effective Scala @ Jfokus
Effective Scala @ JfokusEffective Scala @ Jfokus
Effective Scala @ Jfokus
 

Viewers also liked

From 0 to React with ES6 and Tests
From 0 to React with ES6 and TestsFrom 0 to React with ES6 and Tests
From 0 to React with ES6 and TestsDavide Cerbo
 
Principles of microservices XP Days Ukraine
Principles of microservices   XP Days UkrainePrinciples of microservices   XP Days Ukraine
Principles of microservices XP Days UkraineSam Newman
 
Realizzare applicazioni desktop con Electron e Angular
Realizzare applicazioni desktop con Electron e AngularRealizzare applicazioni desktop con Electron e Angular
Realizzare applicazioni desktop con Electron e AngularMichele Aponte
 
Cloud architecture with the ArchiMate Language
Cloud architecture with the ArchiMate LanguageCloud architecture with the ArchiMate Language
Cloud architecture with the ArchiMate LanguageIver Band
 
Migrating Enterprise Applications to AWS: Best Practices & Techniques (ENT303...
Migrating Enterprise Applications to AWS: Best Practices & Techniques (ENT303...Migrating Enterprise Applications to AWS: Best Practices & Techniques (ENT303...
Migrating Enterprise Applications to AWS: Best Practices & Techniques (ENT303...Amazon Web Services
 
Taming the ever-evolving Compliance Beast : Lessons learnt at LinkedIn [Strat...
Taming the ever-evolving Compliance Beast : Lessons learnt at LinkedIn [Strat...Taming the ever-evolving Compliance Beast : Lessons learnt at LinkedIn [Strat...
Taming the ever-evolving Compliance Beast : Lessons learnt at LinkedIn [Strat...Shirshanka Das
 

Viewers also liked (9)

From 0 to React with ES6 and Tests
From 0 to React with ES6 and TestsFrom 0 to React with ES6 and Tests
From 0 to React with ES6 and Tests
 
Di cosa parlano?
Di cosa parlano?Di cosa parlano?
Di cosa parlano?
 
Principles of microservices XP Days Ukraine
Principles of microservices   XP Days UkrainePrinciples of microservices   XP Days Ukraine
Principles of microservices XP Days Ukraine
 
Realizzare applicazioni desktop con Electron e Angular
Realizzare applicazioni desktop con Electron e AngularRealizzare applicazioni desktop con Electron e Angular
Realizzare applicazioni desktop con Electron e Angular
 
Cloud architecture with the ArchiMate Language
Cloud architecture with the ArchiMate LanguageCloud architecture with the ArchiMate Language
Cloud architecture with the ArchiMate Language
 
Boot camp - Migration to AWS
Boot camp - Migration to AWSBoot camp - Migration to AWS
Boot camp - Migration to AWS
 
Application Portfolio Migration
Application Portfolio MigrationApplication Portfolio Migration
Application Portfolio Migration
 
Migrating Enterprise Applications to AWS: Best Practices & Techniques (ENT303...
Migrating Enterprise Applications to AWS: Best Practices & Techniques (ENT303...Migrating Enterprise Applications to AWS: Best Practices & Techniques (ENT303...
Migrating Enterprise Applications to AWS: Best Practices & Techniques (ENT303...
 
Taming the ever-evolving Compliance Beast : Lessons learnt at LinkedIn [Strat...
Taming the ever-evolving Compliance Beast : Lessons learnt at LinkedIn [Strat...Taming the ever-evolving Compliance Beast : Lessons learnt at LinkedIn [Strat...
Taming the ever-evolving Compliance Beast : Lessons learnt at LinkedIn [Strat...
 

Similar to Kotlin: maybe it's the right time

Davide Cerbo - Kotlin: forse è la volta buona - Codemotion Milan 2017
Davide Cerbo - Kotlin: forse è la volta buona - Codemotion Milan 2017 Davide Cerbo - Kotlin: forse è la volta buona - Codemotion Milan 2017
Davide Cerbo - Kotlin: forse è la volta buona - Codemotion Milan 2017 Codemotion
 
Scala @ TechMeetup Edinburgh
Scala @ TechMeetup EdinburghScala @ TechMeetup Edinburgh
Scala @ TechMeetup EdinburghStuart Roebuck
 
What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)Pavlo Baron
 
여자개발자모임터 6주년 개발 세미나 - Scala Language
여자개발자모임터 6주년 개발 세미나 - Scala Language여자개발자모임터 6주년 개발 세미나 - Scala Language
여자개발자모임터 6주년 개발 세미나 - Scala LanguageAshal aka JOKER
 
Kotlin Language Features - A Java comparison
Kotlin Language Features - A Java comparisonKotlin Language Features - A Java comparison
Kotlin Language Features - A Java comparisonEd Austin
 
Why Scala is the better Java
Why Scala is the better JavaWhy Scala is the better Java
Why Scala is the better JavaThomas Kaiser
 
Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1Troy Miles
 
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.
 
NUS iOS Swift Talk
NUS iOS Swift TalkNUS iOS Swift Talk
NUS iOS Swift TalkGabriel Lim
 
The Future of JVM Languages
The Future of JVM Languages The Future of JVM Languages
The Future of JVM Languages VictorSzoltysek
 
(How) can we benefit from adopting scala?
(How) can we benefit from adopting scala?(How) can we benefit from adopting scala?
(How) can we benefit from adopting scala?Tomasz Wrobel
 
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfpragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfHiroshi Ono
 
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfpragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfHiroshi Ono
 
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfpragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfHiroshi Ono
 
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfpragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfHiroshi Ono
 
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
 

Similar to Kotlin: maybe it's the right time (20)

Davide Cerbo - Kotlin: forse è la volta buona - Codemotion Milan 2017
Davide Cerbo - Kotlin: forse è la volta buona - Codemotion Milan 2017 Davide Cerbo - Kotlin: forse è la volta buona - Codemotion Milan 2017
Davide Cerbo - Kotlin: forse è la volta buona - Codemotion Milan 2017
 
Scala @ TechMeetup Edinburgh
Scala @ TechMeetup EdinburghScala @ TechMeetup Edinburgh
Scala @ TechMeetup Edinburgh
 
What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)
 
여자개발자모임터 6주년 개발 세미나 - Scala Language
여자개발자모임터 6주년 개발 세미나 - Scala Language여자개발자모임터 6주년 개발 세미나 - Scala Language
여자개발자모임터 6주년 개발 세미나 - Scala Language
 
Kotlin Language Features - A Java comparison
Kotlin Language Features - A Java comparisonKotlin Language Features - A Java comparison
Kotlin Language Features - A Java comparison
 
Why Scala is the better Java
Why Scala is the better JavaWhy Scala is the better Java
Why Scala is the better Java
 
Scala in Practice
Scala in PracticeScala in Practice
Scala in Practice
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1
 
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...
 
NUS iOS Swift Talk
NUS iOS Swift TalkNUS iOS Swift Talk
NUS iOS Swift Talk
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
The Future of JVM Languages
The Future of JVM Languages The Future of JVM Languages
The Future of JVM Languages
 
(How) can we benefit from adopting scala?
(How) can we benefit from adopting scala?(How) can we benefit from adopting scala?
(How) can we benefit from adopting scala?
 
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfpragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
 
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfpragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
 
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfpragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
 
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfpragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
 
SDC - Einführung in Scala
SDC - Einführung in ScalaSDC - Einführung in Scala
SDC - Einführung in Scala
 
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
 

More from Davide Cerbo

Kotlin: foss' a vota bona (could be the right time)
Kotlin: foss' a vota bona (could be the right time)Kotlin: foss' a vota bona (could be the right time)
Kotlin: foss' a vota bona (could be the right time)Davide Cerbo
 
Il web intelligente
Il web intelligenteIl web intelligente
Il web intelligenteDavide Cerbo
 
Working between the clouds (versione completa)
Working between the clouds (versione completa)Working between the clouds (versione completa)
Working between the clouds (versione completa)Davide Cerbo
 
The Hitchhiker's Guide to testable code: semplici regole per scrivere codice ...
The Hitchhiker's Guide to testable code: semplici regole per scrivere codice ...The Hitchhiker's Guide to testable code: semplici regole per scrivere codice ...
The Hitchhiker's Guide to testable code: semplici regole per scrivere codice ...Davide Cerbo
 
Working between the clouds
Working between the cloudsWorking between the clouds
Working between the cloudsDavide Cerbo
 
Non Conventional Android Programming (English)
Non Conventional Android Programming (English)Non Conventional Android Programming (English)
Non Conventional Android Programming (English)Davide Cerbo
 
Non Conventional Android Programming (Italiano)
Non Conventional Android Programming (Italiano)Non Conventional Android Programming (Italiano)
Non Conventional Android Programming (Italiano)Davide Cerbo
 

More from Davide Cerbo (8)

Kotlin: foss' a vota bona (could be the right time)
Kotlin: foss' a vota bona (could be the right time)Kotlin: foss' a vota bona (could be the right time)
Kotlin: foss' a vota bona (could be the right time)
 
Adesso In Onda
Adesso In OndaAdesso In Onda
Adesso In Onda
 
Il web intelligente
Il web intelligenteIl web intelligente
Il web intelligente
 
Working between the clouds (versione completa)
Working between the clouds (versione completa)Working between the clouds (versione completa)
Working between the clouds (versione completa)
 
The Hitchhiker's Guide to testable code: semplici regole per scrivere codice ...
The Hitchhiker's Guide to testable code: semplici regole per scrivere codice ...The Hitchhiker's Guide to testable code: semplici regole per scrivere codice ...
The Hitchhiker's Guide to testable code: semplici regole per scrivere codice ...
 
Working between the clouds
Working between the cloudsWorking between the clouds
Working between the clouds
 
Non Conventional Android Programming (English)
Non Conventional Android Programming (English)Non Conventional Android Programming (English)
Non Conventional Android Programming (English)
 
Non Conventional Android Programming (Italiano)
Non Conventional Android Programming (Italiano)Non Conventional Android Programming (Italiano)
Non Conventional Android Programming (Italiano)
 

Recently uploaded

SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfRTS corp
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencessuser9e7c64
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?Alexandre Beguel
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptxVinzoCenzo
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldRoberto Pérez Alcolea
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shardsChristopher Curtin
 
VictoriaMetrics Anomaly Detection Updates: Q1 2024
VictoriaMetrics Anomaly Detection Updates: Q1 2024VictoriaMetrics Anomaly Detection Updates: Q1 2024
VictoriaMetrics Anomaly Detection Updates: Q1 2024VictoriaMetrics
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesKrzysztofKkol1
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxRTS corp
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogueitservices996
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITmanoharjgpsolutions
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slidesvaideheekore1
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfkalichargn70th171
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 

Recently uploaded (20)

SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conference
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptx
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository world
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards
 
VictoriaMetrics Anomaly Detection Updates: Q1 2024
VictoriaMetrics Anomaly Detection Updates: Q1 2024VictoriaMetrics Anomaly Detection Updates: Q1 2024
VictoriaMetrics Anomaly Detection Updates: Q1 2024
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogue
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh IT
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slides
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 

Kotlin: maybe it's the right time

  • 1. Kotlin: maybe it’s the right time Davide Cerbo - Entaksi CODEMOTION MILAN - SPECIAL EDITION 10 – 11 NOVEMBER 2017
  • 2. Chi sono Hi, my name is Davide and I’m writing bad code since I was 7. Since 2003 I’m paid for that.
  • 3. Disclaimer Here we have a lot of println, and some jokes. My wife said that they aren’t funny.
  • 4. C’era una volta OAK It was 1992 and in Italy there was a big scandal: Tangentopoli.
  • 5. C’era una volta OAK Java Borns in 1995 and now can drink beers.
  • 6. Il grande problema Backward compatibility (The art of killing your app because the environment evolve while you can’t) JDK 1.0 (21 january 1996) JDK 1.1 (19 february 1997) J2SE 1.2 (8 december 1998) J2SE 1.3 (8 my 2000) J2SE 1.4 (6 february 2002) J2SE 5.0 (30 september 2004) Java SE 6 (11 december 2006) Java SE 7 (28 july 2011) Java SE 8 (18 march 2014) Java SE 9 (26 september 2017) Tutte compatibili!
  • 8. JVM != Java class Hello { fun sayHello(): String { return "hello!" } } public final class Hello { // access flags 0x11 public final sayHello()Ljava/lang/String; @Lorg/jetbrains/annotations/NotNull;() // invisible L0 LINENUMBER 8 L0 LDC "hello!" ARETURN L1 LOCALVARIABLE this Ltotest/Hello; L0 L1 0 MAXSTACK = 1 MAXLOCALS = 1 // access flags 0x1 public <init>()V L0 LINENUMBER 6 L0 ALOAD 0 INVOKESPECIAL java/lang/Object.<init> ()V RETURN L1 LOCALVARIABLE this L/Hello; L0 L1 0 MAXSTACK = 1 MAXLOCALS = 1 @Lkotlin/Metadata;(mv={1, 1, 1}, bv={1, 0, 2}, k=1, d1={"u0000u0012nu0002u0018u0002nu0002u0010u0000nu0002 u0008u0002nu0002u0010u000enu0000u0018u00002u00020u00 01Bu0005u00a2u0006u0002u0010u0002Ju0006u0010u0003u001 au00020u0004u00a8u0006u0005", d2={"L/Hello;", "", "()V", "sayHello", "", "production sources for module coroutine_main"}) // compiled from: Hello.kt } @Metadata( mv = {1, 1, 7}, bv = {1, 0, 2}, k = 1, d1 = {"u0000u0012nu0002u0018u0002nu0002 u0005¢u0006u0002u0010u0002Ju0006u00 d2 = {"Ltotest/Hello;", "", "()V", "sayHello", "", " ) public final class Hello { @NotNull public final String sayHello() { return "hello!"; } } Compile Decompile
  • 9. Machine code is not enought? Assembly languages Machine code Logic languages (Prolog) Functional languages (Haskell) Procedural languages (C) Object-oriented languages (Java) The Case for Kotlin and Ceylon by Russel Winder https://www.youtube.com/watch?v=cFL_DDXBkJQ
  • 10. Why Kotlin? Hey! People said the same about Scala in the past. So why not Scala?
  • 11. So, why not Scala? Kotlin is a better Java while Scala is more powerful than Java, and probably than Kotlin. But, Kotlin borns in the industry for the industry and it evolves with the industry in mind, while Scala borns at the university and it is adapted to the industry. Unfortunately, we work for the industry. https://agilewombat.com/2016/02/01/scala-vs-kotlin/ https://superkotlin.com/kotlin-vs-scala/
  • 12.
  • 13. Kotlin is a statically-typed programming language that runs on the Java Virtual Machine and also can be compiled to JavaScript source code or uses the LLVM compiler infrastructure.
  • 15. 04 Gennaio 2017 Introducing Kotlin support in Spring Framework 5.0 https://spring.io/blog/2017/01/04/introducing-kotlin-support-in-spring-framework-5-0 https://github.com/sdeleuze/spring-kotlin-deepdive
  • 16. 17 Maggio 2017 Kotlin on Android. Now official https://blog.jetbrains.com/kotlin/2017/05/kotlin-on-android-now-official/ http://nilhcem.com/swift-is-like-kotlin/
  • 17. 5 Giugno 2017 kotlin-react borns! https://github.com/JetBrains/kotlin-wrappers/commits/master/kotlin-react https://github.com/JetBrains/create-react-kotlin-app
  • 18. 1.0 Release 1.1 Release Kotlin is born Gradle Android Official Spring Statische download
  • 20. Var o Val var serie = "B" var a = "Salernitana will win Serie $serie" val b = "Salernitana will win Serie $serie"
  • 21. Fun fun main(args: Array<String>){ hello("Davide", "Salerno") } fun hello(name: String, city: String){ println("Hello $name from $city") }
  • 22. Fun fun functions fun hello(name: String, city: String = "Salerno") = println("Hello $name from $city") hello("Davide", "Salerno") hello(name = "Davide") hello(city = "Salerno", name = "Valentina") fun Int.multilpy(x: Int): Int = this * x // 5.multilpy(10) infix fun Int.multilpy(x: Int): Int = this * x // 5 multilpy 10 Aiuta anche nel refactoring!
  • 23. E gli operatori? data class Point(val x: Int, val y: Int) { operator fun plus(a: Point) = Point(x + a.x, y + a.y) } operator fun Point.unaryMinus() = Point(-x, -y) val point = Point(10, 20) println(point + point + point) //Point(x=30, y=60) println(-point) // Point(x=-10, y=-20)
  • 24. Tailrec ● Rercursion, in some language, can cause: StackOverflow! ● Reduce stack execution. ● Tailrec will resolve this issue only if the recursive call is the last one. ● How? Transform your code in imperative code. Less readable, but more fast. ● Performance improvement fun factorial(n: Long): Long = if (n <= 1L) n else n * factorial(n - 1) tailrec fun factorial(n: Long, accumulator: Long = 1): Long = if (n <= 1L) accumulator else factorial(n - 1, accumulator * n) Tailrec cannot applicable “If” will return the verified condition value
  • 25. Tailrec decompiled public static final long factorial(long n, long accumulator) { while(n > 1L) { long var10000 = n - 1L; accumulator *= n; n = var10000; } return accumulator; } public static long factorial$default(long var0, long var2, int var4, Object var5) { if((var4 & 2) != 0) { var2 = 1L; } return factorial(var0, var2); } } public static final long factorial(long n, long accumulator) { return n <= 1L?accumulator:factorial(n - 1L, accumulator * n); } public static long factorial$default(long var0, long var2, int var4, Object var5) { if((var4 & 2) != 0) { var2 = 1L; } return factorial(var0, var2); } With Tailrec Without Tailrec StackOverflow Tools > Kotlin > Show Kotlin Bytecode > Decompile
  • 26. Class open class Person(val name: String) { init { println("init…") } open fun speak() { println("Hi $name!") } infix fun and(o: Person) = "Hi ${o.name} & ${this.name}" } fun main(args: Array<String>) { Person("Davide") and Person("Valentina") val p = Person("Jack") p.speak() }
  • 27. Class class Customer(name: String) : Person(name) { override fun speak() { println("Welcome $name!") } } class CustomerDavide : Person("Davide") { override fun speak() { println("Welcome $name!") } }
  • 28. Equals, hashCode, toString e copy, nevermore! data class User(val name: String, val age: Int) val davide = User("Davide", 35) val davideJunior = davide.copy(age=0) fun main(args: Array<String>) { val (name, age) = davide println("$name $age years old") } deconstructing
  • 29. Nothing is equal as appear data class Point(val x: Int, val y: Int) val a = Point(1, 2) val b = Point(1, 2) val c = a println(a === b) // false println(a == b) // true println(a === c) // true println(a == c) // true Controlla il riferimento .equals(...)
  • 30. Lambda fun main(args: Array<String>) { arrayOf("Valentina", "Davide").forEach { println("Hello $it!") } val ints = arrayOf(1, 2, 3) val logger = { msg: Any -> println("log $msg") } ints.map { value -> value * 2 }.map { v -> logger(v) } ints.map { it * 2 }.map { logger(it) } }
  • 31. Lambda class Customer(val name: String) { fun forEach(action: (char: Char) -> Unit) = name.forEach(action) fun hello(callback: (name: String) -> Unit) = callback(name) fun upperCaseAndConcat(callback: () -> String) = "${callback()} $name".toUpperCase() } fun main(args: Array<String>) { val customer = Customer("Davide") customer.hello { println("Ciao $it") } println(customer.upperCaseAndConcat { "Cerbo" }) customer.forEach { println(it) } } È il tipo con un solo valore vuoto. Corrisponde a void in Java.
  • 32. Lambda & Function Label fun forEachTest() { val numbers = 1..100 numbers.forEach { if (it == 25) { return } println("index $it") } println("Hello") } fun forEachTest() { val numbers = 1..100 numbers.forEach { if (it == 25) { return@forEach } println("index $it") } println("Hello") } Vs.
  • 33. Tell me when, when? fun describe(obj: Any): String = when (obj) { 1 -> "One" "Hello" -> "Greeting" is Long -> "Long" !is String -> "Not a string" else -> "Unknown" } describe(Person("davide"))
  • 34. Null is safe! var testA:String = "ciao" var testB:String? = "ciao" testB = null val nullableList: List<Int?> = listOf(1, 2, null, 4) val intList: List<Int> = nullableList.filterNotNull() println("a0 ${testA.length}") println("a1 ${testA?.length}") println("a2 ${testA!!.length}") println("b0 ${testB.length}") // ^ Not safe! Compile time error! ^ println("b1 ${testB?.length}") println("b2 ${testB!!.length}") // ^ KotlinNullPointerException ^ // NPE Lovers
  • 35. Null is safe! val nullableList: List<Int?> = listOf(1, 2, null, 4) val intList: List<Int> = nullableList.filterNotNull() // [1, 2, 4] val aInt: Int? = b as? Int // If b is null, normally we will will have a NullPointerException, while if the type is differente we will have a ClassCastExeption. Usin “as?” we haven’t exception, we will have a null value assigned to the aInt value.
  • 36. Null è sicuro data class Person(val name: String, val age: Int?) val person:Person? = Person("Jack", 1) if (person?.age != null) { println("The person is aged ${person?.age}") } //oppure person?.age?.let { println("The person is aged $it") }
  • 37. ?: Elvis operator val davide = Person(testA) val elvis = Person(testB ?: "Elvis") println(jack.name)
  • 38. Get & Set class Strange(var value: Long) { var strangeValue: Long get() = value * 2 set(value){ if(value > 5) this.value = value } } fun main(args: Array<String>) { val customer = Strange(10) println(customer.strangeValue) //20 customer.strangeValue = 3 println(customer.strangeValue) //20 customer.strangeValue = 6 println(customer.strangeValue) //12 }
  • 39. Delegated properties: non può farlo qualcun altro? class Delegate { operator fun getValue(thisRef: Any?, property: KProperty<*>): String { return "$thisRef, thank you for delegating '${property.name}' to me!" } operator fun setValue(thisRef: Any?, property: KProperty<*>, value: String) { println("$value has been assigned to '${property.name} in $thisRef.'") } } class Example { var p: String by Delegate() }
  • 40. Delegated properties: il pigro e l’osservabile val lazyValue: String by lazy { println("computed!") "Hello" } fun main(args: Array<String>) { println(lazyValue) println(lazyValue) } class User { var n: String by Delegates.observable("empty") { prop, old, new -> println("$old -> $new") } } fun main(args: Array<String>) { val user = User() user.n = "first" user.n = "second" }
  • 41. Coroutine Coroutine ⋍ light-weight thread ● Are like threads, they run in parallel, wait for each other and they communicate. ● Area cheap, we can create many of those without having performance issues. ● Are executed in a thread pool. ● A thread can handle more than one coroutine. ● The thread became free while a coroutine is in waiting when the coroutine will return active, it will use a free thread in the pool. https://github.com/Kotlin/kotlinx.coroutines/blob/master/coroutines-guide.md https://proandroiddev.com/approaching-kotlin-coroutines-an-extensive-feature-concurrent-programming-in-kotlin-eaaa19b003d2
  • 42. Coroutine sono oneste fun main(args: Array<String>) = runBlocking { val jobs = List(100_000) { launch { delay(1000L) print(".") } } jobs.forEach { it.join() } } fun main(args: Array<String>) { val jobs = List(100_000) { thread(start = true) { Thread.sleep(1000L) print(".") } } jobs.forEach { it.join() } } OUT OF MEMORY!!!
  • 43. Coroutine: suspend, async / await fun main(args: Array<String>) = runBlocking<Unit> { val time = measureTimeMillis { val one = doSomethingUsefulOne() val two = doSomethingUsefulTwo() println("The answer is ${one + two}") } println("Completed in $time ms") } suspend fun doSomethingUsefulOne(): Int { delay(1000L) return 13 } suspend fun doSomethingUsefulTwo(): Int { delay(1000L) return 29 } fun main(args: Array<String>) = runBlocking<Unit> { val time = measureTimeMillis { val one = async { doSomethingUsefulOne() } val two = async { doSomethingUsefulTwo() } println("The answer is ${one.await() + two.await()}") } println("Completed in $time ms") } suspend fun doSomethingUsefulOne(): Int { delay(1000L) return 13 } suspend fun doSomethingUsefulTwo(): Int { delay(1000L) return 29 } ~2 sec. ~1 sec.
  • 44. Coroutine is the basement Coroutine Actors Communication Sequence Process ?
  • 45. Testing class GreeterTest { @Mock lateinit var user: User lateinit var tested: Greeter @Before fun setUp() { MockitoAnnotations.initMocks(this) tested = Greeter(user) } @Test fun englishGreetIsCorrect() { whenever(user.fullName()).thenReturn("Codemotion") assertEquals("Hello Codemotion!", tested.getGreeting()) } } all values are final by default. With lateinit the compiler knows that someone will intialize it later. Mockito.`when` is not the best choice with Kotlin. The cause is that Kotlin avoid null, and can cause issues with .any() mehtod. The “whenever” method is part of mockito-kotlin libary. backticks are used when the method name is a reserved word.
  • 46. Testing: Mockito-Kotlin class GreeterTest { val user: User = mock { on { fullName() }.then { "Codemotion" } } val tested: Greeter = Greeter(user) @Test fun `english greeting is correct`() { assertEquals("Hello, Codemotion!", tested.getGreeting()) } }
  • 47. Testing: Kluent class GreeterTest3 { val user: User = mock { on { fullName() }.then { "Codemotion" } } val tested: Greeter = Greeter(user) @Test fun `english greeting is correct`() { tested.getGreeting() `should equal` "Hello, Codemotion!" } @Test fun `cannot smoke`() { val davide = User("Davide", "Cerbo") val davideSmoke = { davide.smoke() } davideSmoke `should throw` RuntimeException::class `with message` "Cannot smoke!" } }
  • 48. Testing dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version" testCompile "org.mockito:mockito-core:2.8.9" testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version" testCompile 'de.jodamob.kotlin:kotlin-runner-junit4:0.3.1' testCompile "com.nhaarman:mockito-kotlin-kt1.1:1.5.0" testCompile 'org.amshove.kluent:kluent:1.30' } https://proandroiddev.com/improve-your-tests-with-kotlin-in-android-pt-1-6d0b04017e80 https://proandroiddev.com/improve-your-tests-with-kotlin-in-android-pt-2-f3594e5e7bfd https://proandroiddev.com/improve-your-tests-with-kotlin-in-android-pt-3-104e1c9f77cc
  • 49. Now is the time to remember that Kotlin is good because the trade-off between synthesis and readable code is really good.
  • 51. Webapp: Gradle buildscript { ... dependencies { ... classpath "org.jetbrains.kotlin:kotlin-noarg:$kotlinVersion" } } ... apply plugin: "kotlin-jpa" group = 'it.devday' version = '0.0.1-SNAPSHOT' ... } JPA need an empty constructor in some entities, and Kotlin objects don’t have. To solve this issue we can use this plugin that will create an empty constructor in any object, without any change to our codebase.
  • 52. Webapp: Domain & Repository import it.devday.kotlincodemotion.domain.Contact import org.springframework.data....JpaRepository interface ContactRepository: JpaRepository<Contact, Long> import javax.persistence.Entity import javax.persistence.GeneratedValue import javax.persistence.Id @Entity data class Contact( @Id @GeneratedValue val id: Long, val name: String, val surname: String)
  • 53. Webapp: Resource 1/2 @RestController @RequestMapping("/contacts") class ContactResource(val contactRepository: ContactRepository) { @GetMapping //curl -XGET http://localhost:8080/contacts fun getAll() = contactRepository.findAll() @GetMapping("/{id}") //curl -XGET http://localhost:8080/contacts/1 fun getAll(@PathVariable id: Long) = contactRepository.findById(id)
  • 54. Webapp: Resource 2/2 @PostMapping //curl -XPOST http://localhost:8080/contacts -H 'Content-Type: application/json' -d '{"name":"Davide", "surname":"Cerbo"}' fun insert(@RequestBody contact: Contact) = contactRepository.save(contact) @DeleteMapping("/{id}") //curl -XDELETE http://localhost:8080/contacts/1 fun delete(@PathVariable id: Long) { val contact = contactRepository.findById(id).unwrap() contact?.let { contactRepository.delete(contact) } } } aspetta...unwrap() non esiste su Optional
  • 55. Webapp: Application @SpringBootApplication class KotlinCodemotionApplication fun <T> Optional<T>.unwrap(): T? = orElse(null) fun main(args: Array<String>) { runApplication<KotlinCodemotionApplication>(*args) } ecco unwrap()! array is passed element by element, it is used with vararg arguments public inline fun <reified T : kotlin.Any> runApplication(vararg args: kotlin.String) The generic type will be avaible in the method. Wow!
  • 56. Hey, I’m a frontend developer, where is my code?
  • 57. $ create-react-kotlin-app kotlin-codemotion-front $ cd kotlin-codemotion-from $ yarn start https://github.com/jetbrains/create-react-kotlin-app https://github.com/JetBrains/kotlin-wrappers/blob/master/kotlin-react/README.md https://github.com/JetBrains/kotlin-wrappers/blob/master/kotlin-react-dom/README.md https://github.com/Kotlin/kotlin-fullstack-sample https://github.com/JetBrains/kotlinconf-app https://blog.frankel.ch/kotlin-front-end-developers/#gsc.tab=0 https://github.com/sdeleuze/spring-kotlin-deepdive Kotlin React: Application
  • 58. React is a framework made by Facebook to build UI. Is the View in the MVC pattern. It simple associate a state to a specific UI. Your UI will change regarding your state. Kotlin React: Stop! What is React? {name: “Davide”, color: “red”} Hi Davide! {name: “Jack”, color: “green”} Hi Jack!
  • 59. Kotlin React: Application: Component definition interface ContactListProps : RProps { var owner: String } interface ContactListState : RState { var list: Array<Contact> } class ContactList(props: ContactListProps) : RComponent<ContactListProps, ContactListState>(props) { override fun ContactListState.init(props: ContactListProps) { list = emptyArray() } ...
  • 60. Kotlin React: Application: Data loading override fun componentDidMount() { async { val listData = httpGet("/contacts") setState { list = JSON.parse<Array<Contact>>(listData) } } } remember to define the proxy in package.json: "proxy": "http://localhost:8080"
  • 61. Kotlin React: Application: UI rendering override fun RBuilder.render() { div("ContactList-header") { key = "contactListHeader" h2 { +"${props.owner}'s contact list" } ul { for (c in state.list) { li { +"${c.id}: ${c.name} ${c.surname}" } } } } } } fun RBuilder.contactList(owner: String = "No-name") = child(ContactList::class) { attrs.owner = owner }
  • 62. STOP!
  • 63. What we miss? ● Spring WebFlux ● Reactor ● Android + Kotlin ● Native + Kotlin #byebyejava
  • 66. Useful resources https://kotlinlang.org/docs/reference/ https://spring.io/blog/2017/01/04/introducing-kotlin-support-in-spring-framework-5-0 https://blog.jetbrains.com/kotlin/2017/05/kotlin-on-android-now-official/ https://dev.to/lovis/gang-of-four-patterns-in-kotlin https://github.com/volodymyrprokopyuk/kotlin-sdp https://github.com/gradle/gradle-script-kotlin https://speakerdeck.com/sdeleuze/functional-web-applications-with-spring-and-kotlin https://kotlinlang.org/docs/tutorials/httpservlets.html http://thetechnocafe.com/more-about-functions-in-kotlin/ https://nklmish.wordpress.com/2017/10/22/deprecated-in-kotlin/ https://kotlinlang.org/docs/tutorials/command-line.html https://agilewombat.com/2016/02/01/scala-vs-kotlin/ https://superkotlin.com/kotlin-vs-scala/ https://kotlinlang.org/docs/reference/type-safe-builders.html