is there any micro improvement to use explicit typ...
# announcements
p
is there any micro improvement to use explicit types in relation to compilation time? In Swift you can get faster compilation time if you set explicit types, I am not sure how Kotlin deals with it.
e
I think Its true in every programming language? Not 100% sure though
g
In theory it should be faster, but I never saw any evidences that explicit type somehow helps with compilation time. I wouldn’t recommend to use this approach. Better to spend time on optimisation that really can help, such as modularisation of your project or even just profiling your build
p
Thank you. I am not having problems with the compile time, I am just curious.
in Swift, if you don't set the type of your array, the compiler gets super slow and sometimes crash
you can't do
let d = [foo, bar, fee]
with many items. The compiler never finishes the compilation. You need to do:
var d: [Int] = []; d += foo; d += bar; d += fee
😱 5
e
Really?
Read about Collection literals
String concatenation also suffer this problem, this is hilarious: https://stackoverflow.com/a/48916182/2430555 "Expression was too complex to be solved in reasonable time"
I did this once and the compiler running on a CI took 30 minutes to compile a single line. 🧌
g
Wow
It has to do with type inference. Each time you use the + operator, Swift has to search through all of the possible overloads for + and infer which version of + you are using
is this because of explicit imports are not required by default?
p
probably, this could be solved with caching...