so our team (mostly me) just finished a 4-month pi...
# getting-started
s
so our team (mostly me) just finished a 4-month piece by piece conversion of a 4000-line Java project to Kotlin. There was also some development going on, but not too much and I thought it would be interessting to look at the code statistics:
Copy code
Language     files      blank      comment     code
---------------------------------------------------
Java          80         1028        333       4075     before
Kotlin        80          643        330       4185     after
so we see a collapse of blank lines by 35%, but why did the codelines not decrease, despite my feeling that kotlin code is more compact than Java code? I think it's because of my love of the trailing comma 😅 A lot of parameter lists went from e.g.
Copy code
public String getAccessToken(byte[] pkcs12, String keyStorePw, String privateKeyPw, String fd) {
to looking like this:
Copy code
fun getAccessToken(
        pkcs12: ByteArray,
        keyStorePw: String,
        privateKeyPw: String,
        fd: String,
    ): String {
K 6
t
ahahah, I am also fighting internally between trailing commas and what I call reading disposition. the style of "vertical writing" kinda bothers me, I am used to read left to right, not top to bottom 😄
c
Personally, I much prefer having an element per line for large functions, because the diff becomes much easier to read when you add or remove arguments
5
k
Perhaps another useful comparative metric would be file size. Total number of characters rather than number of lines, since the lines are shorter in Kotlin.
h
@CLOVIS One could argue you shouldn't have functions that large… I mostly hit this formatting with data class constructors and such. Unfortunately, as soon as the precedent was set, this became the default for my colleagues and now every method parameter is a new line, often even when it's the only one 😞
🧞 1
s
I think a lines-of-code with a function body might be an interesting metric. If it's just one parameter, I put it all in one line, but as soon as I have two there's a good chance each get's their own line 🤷‍♂️
k
Even with the change to one parameter per line, I'm still surprised that going to Kotlin resulted in more lines of code instead of fewer.