← Back to context

Comment by pshirshov

3 days ago

> AFAIK, types are erased by JVM compilers...

Not in all the cases (it keeps type parameters for anonymous classes) and there are various workarounds.

Also, essentially, it's not a problem at all for a compiler, you are free to render applied type constructors as regular classes with mangled names.

The parent poster is correct. We do monomorphization, hence Flix types are unboxed. For example, a `List[Int32]` is a list of primitive integers. There is no boxing and no overhead. The upshot is that sometimes we are faster than Java (which has to do boxing). The downside is larger bytecode size-- which is less of a factor these days.

Caveat: Flix sometimes has to box values on the boundary between Flix and Java code -- e.g. when calling a Java library methods that requires a java.lang.Object due to erasure in Java.

  • Java shouldn’t have boxing “soon”. If we ever see the results of Valhalla.