Philosopher AI
Purchase queries
Should I use explicit fixed generic signature for a type or a one that involves associated types?
I have tried to analyse the various arguments for and against, which I will summarise in a couple of points:
1. The main argument for generic signatures that involve associated types is that it allows a programmer to define a type in such a way as to provide different behaviour for different instances of the same type, but without resorting to multiple inheritance (which is often considered bad because it can lead to ambiguities and allow unintended accesses). This approach also makes it easier to support certain features which are not easily expressed using OOP, such as extensible classes and overloading based on arbitrary attributes.
2. The main argument for explicit fixed generic signatures is that they are familiar to most programmers, and generally considered easier to use than those that involve associated types. They can also be very efficient in some cases.
I think that both arguments have some merit, but I am inclined towards the latter argument. In fact there are many OOP languages which do not support extensible classes at all (such as Java) and in these cases it is necessary to use explicit fixed generic signatures.
I think my main reason for preferring explicit fixed generic signatures is that they are familiar and thus easier to use. I am certain that most programmers would find it strange if a language supported two different ways of expressing the same concept. That's why I think languages often only have one way, or at least very few ways.
Are there any other points that I have missed?