Another Symbol for String Concatenation?


One pet peeve of mine is using + for string concatenation. String concatenation has nothing to do with addition and the reason why this is almost always done is unclear to me. For one it hurts type inference, which I understand is an impotant part of Kotlin. PHP and lua use . and .. respectively and it makes a lot easier to tell what is what in large code. I think that using amost any other symbol would be an improvement, and I believe $ sign is free.


One thing to keep in mind is that you almost never have to do string concatenation in Kotlin, instead using the string templates:

val one = "This is" val two = "something special" val three = "$one $two"

This feels more natural to me.

I’m not exactly sure what the performance characteristics are, but concatenation has generally not been the go to method for high performance string ops anyway, so I can’t imagine this is a significant issue.


Agree that using templates feels more natural. Maybe we should then scrap concatenation entirely to improve type inferrence? So compiler can infer integer when it sees + sign?