9 ms·
I don't understand how not having generics is at all acceptable. But maybe that's because I come from a functional programming perspective.
by alexandercrohde 8y ago
I don't understand how not having generics is at all acceptable. But maybe that's because I come from a functional programming perspective.
- dana321 8y agousing interface{} and reflect is good enough for the many problems of using X datatype
- mixedCase 8y agoOne of Go's tennets is "clear is better than clever", followed by "reflection is never clear". So no, idiomatic Go is not about using reflection, it's what we have to resort to because the language is so limited.
- dana321 8y agoWe're talking about simple reflection here, pass in the value, infer the type and cast to that type. Most people are totally confused by generics, i personally don't have a problem using them or not. At the end of the day, its just template metaprogramming.
- aikah 8y agoNo it is not. What's the point of a compiler if you check types at runtime? It's just that a lot of things in Go weren't carefully designed and now the price of adding something to the language is the price of dealing with technical debt. For instance Go has a form of exception (panics), returning errors is purely a convention. But panics aren't very good at exceptions either.
- dana321 8y agoWell, what was the point of adding std::any in C++17? Generics aren't a cure-all, they merely duplicate code and change the type. Its not much better than copy-paste and replace the type names.
- aikah 8y ago> Generics aren't a cure-all, they merely duplicate code and change the type. Its not much better than copy-paste and replace the type names. Nobody ever said that. > . Its not much better than copy-paste and replace the type names. Yes it is. You let the compiler do the job, instead of doing it manually.
- dana321 8y agoOk, well i just said it, so somebody did. There is no difference whatsoever between the same function duplicated with different types.
- aikah 8y ago> Ok, well i just said it, so somebody did. Don't be obtuse, nobody ever said "Generics are a cure-all". > There is no difference whatsoever between the same function duplicated with different types. Yes there is, it's called polymorphism.
- andy_ppp 8y agoIt's because Go is a brutalist hipster language - simplicity above utility. Forget a lack of generics, you don't even get proper error messages.
- jstimpfle 8y agoIs "hipster" a label you would like to apply to e.g. Russ Cox? Maybe the designers of Go have design goals that are different than what you have in mind. Maybe they don't see it as "simplicity vs utility", but more as "utility through simplicity".
- deleted 8y ago[deleted]
- andy_ppp 8y ago"Hipster: A person who follows the latest trends and fashions, especially those regarded as being outside the cultural mainstream." Yep. Go is a hipster language, even if you don't like it.
- jstimpfle 8y ago"The latest trends"? To me Go is particularly conservative. I don't feel like arguing over a word that has become essentially meaningless over time, but I think you have seriously misunderstood what hipster means or was once supposed to mean. Either that, or you don't really know about Go and are just judging it by its marketing's design aesthetics (Gopher, fonts etc. following a trendy googley style).
- andy_ppp 8y agoGo is trendy and Go is outside of the mainstream in it's minimalist design choices. Are you trying to say that Go is not in fashion and has made mainstream language choices? I think you're just upset about the choice of the word hipster but as with all words it's a shortcut to actual meaning. It was intended with a hint of playfulness and not intended to make you feel bad, even if you don't agree with the choice of word.
- Insanity 8y agoI programmed in Java and Haskell and have made the switch to Go some time ago for my current position. I don't miss them - it's just a different way of programming but I've not ran into a problem that I couldn't overcome because they are missing. OTOH, I've shot myself in the foot quite a few times with Generics. Honestly, just _try_ it for longer than an exploratory session. Try to build something big with it, and see if you still miss it.
- alexandercrohde 8y agoAs a rule I don't learn "trendy" things until the fad period dies off (be it a netflix show, a product, an app, a diet, or a language). But basically lodash is my bread-and-butter. Could such a library even exist in a language without generics?
- Insanity 8y agoThe question is, why _should_ such a thing exist in a language without generics? It's just a different programming paradigm. Program into a language, don't program in a language. The functional approach is just one way to solve the problem. Also, as a side-note, when I program at home I'll often take a functional language. It's just a different way of programming and I do like FP (Haskell mainly). But Go is different, not worse or better.
- alexandercrohde 8y agoI will probably never opt-into a language for the rest of my life that is not-hybrid (able to be functional or procedural). Because hybrid is objectively better than only supporting one.
- Insanity 8y agoIt's not 'objectively better' to be honest. Offering two ways of doing the same thing can lead to a non-uniform codebase, and can lead to people being 'experts' in functional and others being experts in procedural. And at some point, the procedural guys will get a mindfuck reading the functional people their code. (We had something similar happen).
- h8hawk 8y agoAs I understand many Go devs are former python/ruby devs. Its limited static analysis is even great compare their former languages, There are many articles which notice type safety as advantage of Go. So they have easy to learn, very fast language with good support for concurrency/parallelism (Consider what goroutines offer compare to GIL).
- throwaway415415 8y agoYou code without them. Ends up making your code clearer in a lot of case, it's pretty good actually. I think a lot of people complaining about generics here are not writing Go