I recently attempted to write a kotlin based minimal game engine. However I ran into efficiency problems. I found that if I replaced all lists by arrays in my code I got a got a more efficient solution. However Kotlin doesnt support arrays that much since they are considered a low level feature. I implemented vectors and other baic math using value classes and endid up implementing the List interface that has the highest level of support.
I suggest that typed and primitive arrays also implement List to bind them into the ecosystem.
This way we get the efficiency and the flexibility together.
I also ran into problems regarding mutability and value classes.
By using mutable collections I ran into efficiency problems and hidden bugs, by using lists I ran into efficiency problems, by arrays I ran into hidden bugs. Therefor I implemented immutable arrays that are safe and efficient. However I can’t make arrays a subtype of immutable arrays similar to lists and mutable lists.
I suggest that immutable arrays should exist so efficency and immutability can be forced in advanced libraries for gaming and AI without value classes and other adapters.
When I try to use my custom collections (value classes) with json libraries they dont recognize them as the wrapped class.
I consider this sumwhat a bug.
I ended up creating a data class without the custom collections just to load the json and then convert it to the other class.
I suggest that value classes should be seen also as the original class regarding equals, hash and serialization
When I implement an extention for typed arrays I implement it for all primitive arrays as well.
This means I have to make 9 implementations for all extentions.
It would be nice to get common interfaces for these types.
When implementing the value classes many functions are delegated to the wrapped class.
It would be nice to get better support for this delegation.
Like:
fun f(a:A):B by wrappedClass
Value classes should be able to extend the wrapped class even if it is not open!