Why you should adapt Kotlin now

“Code on a computer” by Markus Spiske on Unsplash

Kotlin is more concise

// Java Person
public final class Person {
private String name;

public Person(String name) {
this.name = name
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

@Override
public String toString() { /* Implement this */ }

@Override
public boolean equals(Object o) { /* Implement this */ }

@Override
public int hashCode() { /* Implement this */ }
}

// Kotlin Person
data class Person(var name: String)

NULL safety

Person person = null; 
person.getName(); // throws NullPointer Exception
val person : Person; 
person = null; // compilation error
val person : Person? = null; // this is legal
val person : Person? = null;

if (null != person) {
val name = person.getName();
}

Java interoperability

// Person.java
class Person {
private String name;

public String getName() {
return name;
}
}

// Person.kt
fun doSomething() {
// using Person from Java code
val person = Person();

// we can call Java getter as attributes
val name = person.name;
}

Easy to adapt

Full stack development

Officially supported by Google

Conclusion

--

--

Lead Software Engineer at A Cloud Guru

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store