|
|
|
|
|
by codygman
4129 days ago
|
|
Every small min function that you ride has the potential to have bugs. In a language with generics there is only one min function meaning only one source of potential bugs. So is it simpler to have all these little functions doing basically the same thing with the chance of bugs or 1 generic implementation that works for all of them? Looking at things in this light bug potential in Go is O(n) whereas a language with generics is O(1). The point being that without generics you end up implementing lots of these small similar functions and making lots of potential sources of bugs. Idiomatic Go encourages writing easy and simple to fix code, which is good. However what I get for all this is go allows me to write the simple and easy to fix code that could potentially have bugs everywhere. Hope this makes sense, haven't used voice typing for anything this large yet. |
|
I do understand where you're coming from. More code means more code that can have bugs, I totally agree.
However, more complicated code also means more bugs, and generic code is definitely more complicated and non-generic code (in all but the most simplistic cases). So, I don't think it's necessarily as straight forward as O(n) vs O(1).... and also for small values of n, O(n) is pretty close to O(1)... and my contention is that n is almost always small.
So, I don't think you're wrong, per se, I just think that in real life, it's not so black and white, and in my experience, the kind of code I have to duplicate is the dumb stuff, like min, which is nearly impossible to screw up, and if you do, it's immediately obvious in any kind of basic test of the surrounding code.