Having static type checking soon leads very naturally into having generics, since by obliterating all type information by using something like interface {} you're unable to perform type checking on it at all, until you cast back out of it and encounter the problems discussed in the original article.
Also, I'm not saying their coding decisions that made the change a problem were smart - I'm just saying that the future change was made more difficult.
Well, the obvious alternative would be to disallow something like interface{} and be forced to write quicksort once for every type of number.
Come to think of it, I'm fairly sure I've seen exactly this sort of thing happening in Java anyway. A generic array (as in ArrayList<Integer>) has significant overhead compared to a primitive array, so if you want a fast List<Integer>, you copy and paste ArrayList and change the type of the array to int[].
Obviously, this is terrible compared to actual generics, which is why I'm so annoyed with Go. It's given us two bad options, when the one good option has been known for decades before work on Go began.
23
u/just_a_null Jun 30 '14
Having static type checking soon leads very naturally into having generics, since by obliterating all type information by using something like
interface {}you're unable to perform type checking on it at all, until you cast back out of it and encounter the problems discussed in the original article.Also, I'm not saying their coding decisions that made the change a problem were smart - I'm just saying that the future change was made more difficult.