5 ms·
Why is this a concern with generics, but not with e.g. if statements? They too can be over-used (i.e. over-nested)
by tomp 5y ago
Why is this a concern with generics, but not with e.g. if statements? They too can be over-used (i.e. over-nested)
- laumars 5y agoYour example here is a little on the absurd side don’t you think? While the lack of generics in a language can be annoying for some people it’s not a showstopper for most use cases. Whereas removing conditionals would make it a non-starter for most people. And the fact that Go does now have generics should demonstrate that the language is trying to be pragmatic rather than just trolling the community. It’s worth noting that Go vetting tools do capture a few instances of “misusing” ‘if’ statements so taking your comment sincerely (which is more than it deserves imo), your worst case scenario is already covered.
- cannabis_sam 5y ago> Your example here is a little on the absurd side don’t you think? While the lack of generics in a language can be annoying for some people it’s not a showstopper for most use cases. Whereas removing conditionals would make it a non-starter for most people. I don’t want if-statements at all in my code, if-expressions at the most, but they are strictly worse than pattern matching anyways.
- laumars 5y agoCongratulations on being the exception that demonstrates why I said “most people”. The great thing about our current era is that you have more choices in languages and compilers than you have hours in your life to learn them all. So you can be as fussy as you want and there will still be an ecosystem out there for you. There wasn’t nearly this many choices when I started out in IT. And most of the options that weren’t even free.
- erik_seaberg 5y agoMy company has choices; I don’t. I joined an explicitly Java-centric team (even Scala for some use cases) yet Go is getting harder to avoid.
- laumars 5y agoIt’s never been a better time to be a developer with regards to choice of employment and pay so boohoo for your entitled first world problems. Go cry me a river.
- cannabis_sam 5y ago> Congratulations on being the exception that demonstrates why I said “most people”. You said it would be a showstopper for most people, suggesting that a lack of if-statements is a fundamental problem that needs to be worked around. I just showed that there exists serious, non-absurd arguments against if-statements, namely that they are strictly inferior to if-expressions, which again are strictly inferior to pattern matching, since they significantly reduces boolean blindness. At some point (or rather for over a 1000 years) “most” people computed π by polygon approximation, but it turns out that method has severe limitations that more modern methods avoid. Should we still have chosen the method that “most” people were familiar with, over applying infinite series to the problem?
- Beltalowda 5y agoIf statements are not an abstraction though. But I do actually try to minimize them, to the extent that's reasonably possible. And will especially try to minimize "else if" and "else", when reasonable, since I find it increases the cognitive load when reading something. Interfaces are a better comparison. Interfaces are very useful and I've often used them with great success, but with generally see if other simpler "more direct" solutions work before using interfaces, as those solutions typically less abstract and easier to understand. I've definitely seen some code with "interface overuse" where it could be quite hard to find out what "foo.InterfaceMethod()" actually really does.
- djur 5y agoIf statements are an abstraction over conditional jumps.