News for hackers. Stuff that matters.
Re:Half a million lines of Go by dragonwriter on Sunday May 16, 2021 @10:39PM (#27179566)
> That complaint is as old as the language

I’m not making a complaint, I’m pointing out a fact without a value judgement.

> At any rate: the person asking the question is wondering how you manage to have performant containers with reasonable interfaces in a language without generics.

Uh, I don’t see either “performant” or “with reasonable interfaces” there, the question is: “How do container types, like arrays or hashmaps work without generics? Do you basically have to declare and implement types/methods for each different contained type?”

The answer is, for built-in containers, “no, because they use special-purpose generics”. For custom containers, its basically “yes”, but you probably only want a single contained type with an appropriate interface anyway. In neither case is “basically the same as Python” particularly accurate, though I suppose the former case is similar to typed python using generics in the same way as any language with generics would be, while the latter is loosely similar to bare Python or typed Python using protocols instead of generics. But only loosely.

Re:Half a million lines of Go by masklinn on Monday May 17, 2021 @04:42AM (#27181290)
> The answer is, for built-in containers, “no, because they use special-purpose generics”.

Unless you want to implement utility helpers working on them then it’s yes again, because Go doesn’t have generic functions either, so while it does have a few builtin generic containers, you can’t operate genetically over them.

Re:Half a million lines of Go by tptacek on Monday May 17, 2021 @12:18AM (#27180008)
Yeah, I'm choosing not to die on this hill. I'm just saying that Go has first-class table and resizable array ADTs.
Re:Half a million lines of Go by masklinn on Monday May 17, 2021 @04:45AM (#27181306)
They’re not first class though: you can not take in, return, or work with the ADTs, only with concrete instances of them.
Re:Half a million lines of Go by tptacek on Monday May 17, 2021 @03:30PM (#27187345)
Hey, there, I'm over on this other hill now, not dying on that one. :)