# Performance problems when dealing with deliberately type-unstable code. How to use type knowledge better?

**URL:** <https://discourse.julialang.org/t/performance-problems-when-dealing-with-deliberately-type-unstable-code-how-to-use-type-knowledge-better/52535>\
**Category:** Performance\
**Created:** [December 28, 2020, 8:40pm UTC](https://discourse.julialang.org/t/performance-problems-when-dealing-with-deliberately-type-unstable-code-how-to-use-type-knowledge-better/52535 "2020-12-28T20:40:37Z")\
**Posts on this page:** 1\
**Showing post:** 22

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [December 29, 2020, 2:43pm UTC](https://discourse.julialang.org/t/performance-problems-when-dealing-with-deliberately-type-unstable-code-how-to-use-type-knowledge-better/52535/22 "2020-12-29T14:43:01Z")

</div>

> [@jules](#):
>
> How do other languages deal with this problem?

I this other thread an alternative in Java was tested:

> [@Performance drawback with subtyping](https://discourse.julialang.org/t/performance-drawback-with-subtyping/51939/20):
>
> For feed our discussion, I tried to reconstruct Leandro Martinez’s experiment with 5 lines types and n = 1,000,000 in Java language. If I was unfair at some point, please tell me. The results were: Naivesum Mean Duration: 15.65 ms OO Mean Duration with objects: 19.513 ms The Code import java.util.List; import java.util.ArrayList; import java.util.Random; abstract class LineAbstract { public abstract Float getLength(); public abstract void setLength(Float l); } class Line1 extends …

But the conclusion (unexpected according to the author) was that it was slower than any of the Julia alternatives.

In that thread about the ray tracer someone suggests that C++ has a better way to deal with that, but we didn’t see that actually implemented. I think that this is a problem that deserves some attention, at least for a definitive answer and advice be available.

---

_[View the full topic](https://discourse.julialang.org/t/performance-problems-when-dealing-with-deliberately-type-unstable-code-how-to-use-type-knowledge-better/52535)._
