4. • Statically typed programming language targeting
the JVM
• Support for functional and OO paradigms
• Pragmatic, safe, concise, great Java interop
• Free and open-source
• In public beta, 1.0 coming Real Soon Now
4
5. Outline
• Why Kotlin was created
• Kotlin feature highlights
• How and why we’re using Kotlin
• Where Kotlin works best
• How you can benefit from Kotlin in your projects
5
10. Thought Leadership
• Programming languages are a popular discussion
topic
• IntelliJ IDEA is always going to have best support
for Kotlin
10
11. Good chance of success
• Technical: experience building intelligent tools to
support other languages
• Marketing: company reputation and user trust
11
27. Nullability
class TreeNode(val parent: TreeNode?,
val left: TreeNode?,
val right: TreeNode?) {
fun depth(): Int {
val parentDepth = if (parent != null)
parent.depth()
else
0
return parentDepth + 1
}
}
35. Projects Using Kotlin
• Kotlin
• JetProfile (CRM, sales and license management)
• IntelliJ IDEA 15
• YouTrack v.next
• 2 new unannounced projects
• Research projects related to bioinformatics
• Plugins, Intranet services etc.
35
40. Kotlin in IntelliJ IDEA
• In tests since version 14, in production since 15
• 74k LOC in Kotlin, out of which 18k in tests
• A few developers actively using Kotlin
• Kotlin team provides support with updating to new
Kotlin versions
40
42. The Strengths of Kotlin
• Modeling the data of your application concisely
and expressively
• Creating reusable abstractions using functional
programming techniques
• Creating expressive domain-specific languages
43. Kotlin on the Server Side
• Java interop ensures that all existing Java
frameworks can be used
• No rewrite required to start using Kotlin in existing
codebase
• Existing investment is fully preserved
44. Server-side Kotlin
Frameworks
• Kara: Web framework powering JetProfile
https://github.com/shafirov/kara
• Exposed: Database access framework
https://github.com/JetBrains/exposed
• Ktor: Experimental next generation Web framework
https://github.com/kotlin/ktor
45. Kara: HTML Builders
fun HtmlBodyTag.renderPersonList(
persons: Collection<Person>)
{
table {
for (person in persons) {
tr {
td { +person.name }
td { +person.age }
}
}
}
}
45
46. Kara: HTML Builders
fun HtmlBodyTag.renderPersonList(
persons: Collection<Person>)
{
table {
for (person in persons) {
tr {
td { +person.name }
td { +person.age }
}
}
}
}
46
47. Exposed: Table structure
object CountryTable : IdTable() {
val name = varchar("name", 250)
.uniqueIndex()
val iso = varchar("iso", 3)
.uniqueIndex()
val currency = varchar("currency", 3)
}
47
48. Exposed: Entities
class Country(id: EntityID) : Entity(id) {
var name: String by CountryTable.name
val allCustomers by Customer.referrersOn(
CustomerTable.country_id)
}
48
50. Kotlin for Android
• Compatible with Java 6
• Small runtime library
• Great tooling in Android Studio
• Compatible with existing Java libraries and tools
• 100% Java performance
51. Kotlin Tools for Android
• Kotlin Android Extensions: no more findViewById()
• Anko: DSL for UI, extension functions
https://github.com/jetbrains/anko
• KApt: annotation processing
52. Kotlin Android Extensions
import kotlinx.android.synthetic.activity_main.click_me_button
public class MainActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
click_me_button.onClick {
toast("Thank you!")
}
}
}
53. Kotlin Android Extensions
import kotlinx.android.synthetic.activity_main.click_me_button
public class MainActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
click_me_button.onClick {
toast("Thank you!")
}
}
}
54. Kotlin Android Extensions
import kotlinx.android.synthetic.activity_main.click_me_button
public class MainActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
click_me_button.onClick {
toast("Thank you!")
}
}
}
59. Take initiative
• Kotlin is not a silver bullet and not a magical
solution for the problems of your project
• Kotlin makes you more productive and your work
more enjoyable
• Try it and share the results with your teammates
59
60. Don’t wait for a new project
• Kotlin can be easily integrated into existing Java
codebases
60
61. Where to start using Kotlin
• Tests - OK not informative
• Plugins and utilities - better
• Core and frameworks - best
61
62. Don’t fear the learning curve
• At JetBrains, summer interns become productive
with Kotlin very quickly and deliver great results
62
63. Use the Java to Kotlin
converter
• Convert only the classes that you’re going to
modify
• Cleanup and refactor the code produced by the
converter
63
65. Summary
• JetBrains entrusts the most business-critical tasks
to Kotlin
• Kotlin works great for both server-side and Android
development
• Take initiative and start using Kotlin today!
65