are companion objects really that bad? 1 reply har...
# announcements
k
are companion objects really that bad? 1 reply harmony: A couple of points I want to make: Don't worry about optimizing everything, code clarity is way more important in most cases. Only optimise code that is raw very often (1000+ times a second) and that is actually too slow. The linked article has a deeply flawed approach: it only looks at the generated bytecode to determine performance, but it doesn't take into account that the JIT is able to optimize a lot of things away at runtime. For example, the article complains a lot about getters, but performance is identical to direct field accesses: https://stackoverflow.com/questions/23931546/java-getter-and-setter-faster-than-direct-access A new article has been written that does use benchmarks, altrough @benleggiero has found that there are some wrong conclusions there too: https://sites.google.com/a/athaydes.com/renato-athaydes/posts/kotlinshiddencosts-benchmarks I'd say you don't have to worry about companion objects most of the time 🙂