This is (should be) the exact equivalent of the Cilia code in Kotlin:
- Types
Int,Long,Float
- Variables
var x: Int = 42var x = 42val x = 42var words: MutableList<String> = mutableListOf()(anArraywould have a fixed size)var names: MutableSet<String> = mutableSetOf()var contactInfoForID: MutableMap<String, ContactInfo> = mutableMapOf()
- Functions
fun multiply(a: Int, b: Int): Int { return a * b }fun print(a: ContactInfo) { ... }fun concat(a: String, b: String): String { return ... }
- Loops
for (i in 1..10) { ... }for (i in 0 until words.size) { ... }for (i in listOf(5, 7, 11, 13)) { ... }for (word in words) { ... }
In Kotlin Int and 42 are 32 bit wide, not 64 bits.
That’s Ok, this is a syntax comparison, not a performance benchmark.