Fork me on GitHub
#clara
<
2016-09-08
>
flavio12:09:50

@mikerod, is it generally good practise to type-hint for perfomance reasons? Are you guys recommending it? or, why should I not do it?

wparker20:09:43

I suggest reading https://kotka.de/blog/2012/06/Did_you_know_IX.html . A very short explanation is that the JVM can compile something like (.someMethod x) to run faster if the type of x is known at compile time. In absolute terms, though, even without type hints the calls are still fast. In our codebase we make a point of avoiding reflection since 1. We work at a very large scale that makes such bottlenecks matter. 2. It is easier to avoid reflection entirely than to have to release our code again when it turns out there is a major perf problem. What you should do depends on your use-case and the attendant tradeoffs; some people don’t (and shouldn’t for their use-cases) care about reflection