Live data from Hacker News

Generics enabled by default in Go tip

go-review.googlesource.com

351–360 of 378 posts

Re: Generics enabled by default in Go tip

#351

Language flamewars on internet forums are... strange. Why have we all so strongly coupled our identities as programmers to the language we use? Sense of community and a perceived need to defend it? I don't think Go needs generics, but I'm not about to invent obscure edge cases to justify for/against the idea. That's a recurring theme in all defenses of any language. It's not helpful. Use Go if you like the "clarity",…

Human nature though. When a topic is extremely complicated, or there’s some kind of power to be gained, we resort to tribalism. Both are present in software.

We’ve made societal progress on a lot of things, but not so much on this one.

For me, I always try and be conscious of that, and I tell coworkers when something that I’m suggesting is just preference over objective fact. For example, I prefer Ruby as a scripting language. My first job used it for various automations, and I got used to it. It has absolutely no value over Python as a scripting language for example. It’s just my preference.

Re: Generics enabled by default in Go tip

#352
post #350

Earlier quoted context omitted.

Yeah, too bad I can't build a decent team to develop a distributed scalable application in FreePascal.

That is a failing on your part given that the tools are available.

As much as i value your insights and historical addendums, your tone is often offputting to me.

Re: Generics enabled by default in Go tip

#353

Earlier quoted context omitted.

> If you're referring to map[K]V, that's not true. Go doesn't have generics, it uses some compiler magic under the hood specifically for the map type [0]. They're not generic (aka userland) generics, but they're still generics: parametric types, and functions able to work on them generically (you don't have a separate `append` function for every type you might put in a slice). > The generics proposal is being impleme…

> the builtins are ad-hoc and half-assed In what way are slices and maps half-assed?

I’m sure they mean that because they are not applicable to the rest of the language. It’s like, the Go creators recognized the situation where generics were necessary, but only used it for slices and maps.

I really don’t think they were saying that slices and maps themselves are bad. They function perfectly. I’m sure they meant that it’s just silly to confine quasi-generics to those 2 places.

Re: Generics enabled by default in Go tip

#354
post #316
post #301

Earlier quoted context omitted.

There's some pain in writing generic data structure algorithms for sure. It would have been an interesting experiment though if the Go authors would have tried to improve the tooling around code generation and making it easier to use, as an alternative avenue to generics as code generation might satisfy some of the cases likely to trigger those complains. Anyway, interesting to see how far they will take the generics…

It isn't as if previous languages did not used code generators before generics were a thing on them.

Yea but, it has never been a particularly popular approach.

Re: Generics enabled by default in Go tip

#355

Earlier quoted context omitted.

That’s because “HN threads” represents a lot of different people with different needs and opinions. It’s not a monolithic block at all, and people are more likely to react to complain.

> people are more likely to react to complain. You hit the nail on the head. This is broadly true across virtually everything--at least in most of Western culture (as this is the only one I'm most familiar with). Anger seems to provoke a more actionable response whereas satisfaction does not (generally speaking). Is someone more apt to call a business over lousy service or great service? Why is it that giving a compl…

My guess would be it has biological/physiological reasons. Negative stimuli create a greater urge to act. Tabloids selling more newspapers with bad news than good ones, because the individuals that gave higher weight to birdsong than the signs of a predator approaching did not procreate, evolution at work.

It is possible to change though, patiently putting your own focus on positive things, which there are so many of. Takes work, but sooo worth it. Life is more fun that way too.

Re: Generics enabled by default in Go tip

#357
Generics introduce complexity. That’s pretty undeniable. There are also cases where generics provide much better solutions to problems. That is also undeniable.

As someone who’s working in a Go codebase at work, I’m happy they added generics, especially in the way they did. It’s a pretty minimal subset of generic functionality. I will apply it in certain cases, mostly to reusable code. I think it’s a big win overall though, without introducing too much complexity to the language.

Re: Generics enabled by default in Go tip

#358
post #352
post #350

Earlier quoted context omitted.

That is a failing on your part given that the tools are available.

As much as i value your insights and historical addendums, your tone is often offputting to me.

As it may me, that is how I see the world.

Tooling is available, books are available, 30 years of libraries are around.

If with all of that you can't find a team, it certainly isn't because of tooling.

Re: Generics enabled by default in Go tip

#359
post #98
post #96

Earlier quoted context omitted.

There are certain things that just can’t be done without generics, though. Type safe higher order functions, type safe custom collections, etc. Of course, perhaps these are all just subjective to you, because you can still write any program you need without them. But not having this feature does constrain the set of type-safe programs you can write quite a bit.

I feel like it pretty much always turns out that the things you can't do without generics are, like, second-order things. Higher order functions, type safe custom collections, those are tools. What we care about mostly is what we actually build , and people build pretty much everything in every language, generics or not.

Sure, but programming languages are also tools. Why bother having this discussion at all, if you don't care about tools?

Re: Generics enabled by default in Go tip

#360
post #345
post #286

Earlier quoted context omitted.

Not in the commonly understood sense of "generics", no. You get to switch on a type, but you don't have generic functions or types. A reusable, type-safe Vec or HashMap are still not possible in C...

Kind of, now that typeof is going to be part of the language, that coupled with the preprocessor, does allow exactly that. Although in typical C fashion is a bit of kludge.

"coupled with the preprocessor" is a bit of a cop-out :-). Do you have a concrete example of what typeof would enable? Like a basic implementation of a vector type?
Post reply on HN