Do you know what monomorphization is?
Monomorphization is the process of turning generic code into specific code by filling in the concrete types that are used, at compile time. The compiler does the opposite of the steps we took to make the function generic.
Why? Performance. Knowing what the type actually is makes the program faster at runtime.
So why write generic code at all?
If the compiler rolls it back anyway, why do we need generic types in the first place?
You can argue that it is for maintainability, clean code and so on. All of these are about development time. They concern communication between the developers of the code. (A solo developer communicates with their future self through the code, too.)
And when the reader is an LLM?
Then the question becomes: for LLM-assisted coding, do we still need generic types, clean code and DRY in the same form?
I am not sure. If an LLM creates, reads and updates the code, we may want to design a new way of structuring code for LLMs. Current design patterns were made for human readers, and I suspect that many of the bugs in LLM-written code come from this mismatch.
What do you think?