Earlier quoted context omitted.
To be fair, a lot of those concepts were invented, at very least popularized, by the members of the Go team 30+ years ago. Go is their chance to carefully bundle those ideas together, not just throw every random idea they can think of into a language and end up with a big ball of mud like so many others want to do. There are already plenty of ball of mud languages, if that's what you're looking for.
> To be fair, a lot of those concepts were invented, at very least popularized, by the members of the Go team 30+ years ago. Er... no? Not even remotely?
Hacking Go's runtime with generics
101–110 of 113 posts
Re: Hacking Go's runtime with generics
#102Earlier quoted context omitted.
You'd be hard pressed to name anything in IT that wasn't "discovered" in the 60s-80s but implemented/re-implemented recently
We're not talking bleeding edge CS topics here mate, we're talking "hashability is a useful property because hashmaps", that was standard >25 years ago. Java had hashCode in 1.0, GvR added __hash__ to Python in March 1993 and shipped it in 0.9.9. Hash maps are 69 years old (nice). Bespoke key types (and thus the requirement for user-defined hash functions) is probably the more recent of the two.
> Java had hashCode in 1.0, GvR added __hash__ to Python in March 1993 and shipped it in 0.9.9.
is not doing that. It is just providing an interface that happens to be filled for builtin types
Also Go is not object oriented language and types don't have default set of methods returning things so having type.hash() like Java or Python would make no sense. Whether that's a good or bad call is another discussion but writing generic Hash[T] is few lines of code and would be just encoding/gob into hash of your choosing.
There is a case for providing that in function doing what the dolt guys are doing but that would be "just" optimization.
Re: Hacking Go's runtime with generics
#103Earlier quoted context omitted.
We're not talking bleeding edge CS topics here mate, we're talking "hashability is a useful property because hashmaps", that was standard >25 years ago. Java had hashCode in 1.0, GvR added __hash__ to Python in March 1993 and shipped it in 0.9.9. Hash maps are 69 years old (nice). Bespoke key types (and thus the requirement for user-defined hash functions) is probably the more recent of the two.
So you don't understand what's happening here. They are not "hashing a structure", they are digging into internal implementation to reuse code that runtime uses to hash the structure. > Java had hashCode in 1.0, GvR added __hash__ to Python in March 1993 and shipped it in 0.9.9. is not doing that. It is just providing an interface that happens to be filled for builtin types Also Go is not object oriented language and…
Because Go does not expose the builtin hash function.
> is not doing that.
It's doing that without the feature existing.
> Also Go is not object oriented language
Which is not actually relevant, it clearly knows about "comparable" (which it also considers to mean "hashable"). It just refuses to expose that information.
> so having type.hash() like Java or Python would make no sense.
Are you wilfully picking at the tree's bark in order to avoid considering the forest for a single second?
> Whether that's a good or bad call is another discussion but writing generic Hash[T] is few lines of code and would be just encoding/gob into hash of your choosing.
And lose the benefit of the way the entire ecosystem works.
On the plus side, it would let you have keys with bespoke equality and hashing semantics, but that's clearly not what TFA is looking for.
It also can't be combined with go's own hashable because you can't involve either "comparable" or an interface with methods in a union, so there is no way to accept a "comparable|Hash" in order to leverage both.
And obviously by doing so you'd open the door to them being inconsistent. Which is also the point of using Go's own concept of hashability.
Re: Hacking Go's runtime with generics
#104I do not understand the appeal of go. > The proposal argues that Golang developers are forced to work around language when writing hash-based data structures like Tries or concurrent hash maps. Developers who want an efficient hash-based data structure have only the builtin map to choose from. When this issue was originally created in 2017, Golang didn't have generics And then the author goes to tell us about how thi…
What makes you think they haven't tried what you think are "better ones" and moved away because they had more problems to fight the language/ecosystem about with those?
Re: Hacking Go's runtime with generics
#105Earlier quoted context omitted.
The appeal of Go: - A pretty simple, if not very expressive, language (it's anti-Perl, and seems simpler than JS); you can learn it down to a reasonably productive level in a weekend. (I did.) - A memory-safe language (like Java) with good performance (like Java) without the need to install any runtime, and the ability to ship as a single binary (unlike Java). - A reasonably good and ergonomic concurrency approach (l…
I actually find go a joy to use, I dunno. I like statically typed languages, and go makes defining and using types so simple and straightforward that it feels like you get a lot of the benefits of dynamic typing without the headaches.
What bothers me in Go is mostly the control flow around `result, err := foo(); if err != nil { return err };`, and still non-genericized standard library. But after 1.18 I started to look at Go as a potentially good language, in areas where using Rust is too cumbersome, and using Typescript or Java or Kotlin is also inappropriate.
Re: Hacking Go's runtime with generics
#106Earlier quoted context omitted.
No it's mostly just the blub paradox. You don't feel the pain because you didn't use some features/techniques of other languages that don't exist in Go. It's the same everyone. I, for example, never felt I was missing something until I learned about type providers. Now that I don't work in a language that supports them, I hate it. If I had never learned about them, I would probably never miss em.
He didn't express a lack of pain, just that he was never in a situation where he was stumped by not having them. Generics aren't exactly magic. They can improve code, but you can live without them if you really have to. Although I think you are on to something per the original question about the appeal of Go. For all its faults, Go also gets a lot of things very right that aren't obvious until you have gained the nec…
I mean, isn't that the same thing? You don't know you are "stumped" if you never experienced it. That's what I mean by "feeling the pain".
> Generics aren't exactly magic. They can improve code, but you can live without them if you really have to.
Of course - that's true for essentially any language feature. We can all use assembly if we have to, but I think that's missing the point of why OP asked.
> Although I think you are on to something per the original question about the appeal of Go. For all its faults, Go also gets a lot of things very right that aren't obvious until you have gained the necessary level of familiarity.
Sure, I mean: if you always used a language with an unergonomic and non-integreated builtsystem, you probably won't feel the pain or won't feel it as much as when coming from golang. That would be blub the other way around. Worse: the more languages (that are actually different) you have used, the more unhappy you are with every single existing language.
Re: Hacking Go's runtime with generics
#107Earlier quoted context omitted.
He didn't express a lack of pain, just that he was never in a situation where he was stumped by not having them. Generics aren't exactly magic. They can improve code, but you can live without them if you really have to. Although I think you are on to something per the original question about the appeal of Go. For all its faults, Go also gets a lot of things very right that aren't obvious until you have gained the nec…
> He didn't express a lack of pain, just that he was never in a situation where he was stumped by not having them. I mean, isn't that the same thing? You don't know you are "stumped" if you never experienced it. That's what I mean by "feeling the pain". > Generics aren't exactly magic. They can improve code, but you can live without them if you really have to. Of course - that's true for essentially any language feat…
Not at all. The claim about not being stumped was made in response to criticism that Go is unusable without generics. Said criticism was probably made up, but I guess it was still interesting enough to garner the response that ultimately brought us here.
> That would be blub the other way around.
Seems like blub the same way around. Indeed, the blub paradox itself is paradoxical.
> the more languages (that are actually different) you have used, the more unhappy you are with every single existing language.
And the more you really appreciate just what Go has done by taking an engineering approach and not an academic approach.
Re: Hacking Go's runtime with generics
#108Earlier quoted context omitted.
>just accessing dependencies in private repos requires changing global git settings, which is an abomination Just put a .netrc file in your homefolder with your username + token and use GOPRIVATE env variable. No need to change any git settings. After go modules became mainsream most go packaging issues where out of question, imo. At least for me the 'private repo packages' was the only issue. I'm pretty sure that th…
> Just put a .netrc file in your homefolder with your username + token Lol yes, let's just put sensitive information in plain text in my home folder and change the machine-wide configuration, because Go guys decided that if it worked in 1970, it is good enough for today. > the 'private repo packages' was the only issue. That's quite a big one for a language targeting companies. > I'm pretty sure that there are millio…
That't just your login and a token that gives read-only access to some repo. Hardly an issue imo. At least if this is your work PC. (also - while home folers is the default the file can be places somewhere else)
>Sure, if your gauge is the JS ecosystem...
Why not? Because some guys on HN is salty about it? JS is extremely popular and widespread. Much better gauge than something being used by a few guys.
>It does not even has basic data types such as sets (no, map keys are not a decent replacement for a set), queues or stacks.
I'd argue that channels are your queues. Maybe sets and stacks will be added now that generics are part of the language.
Re: Hacking Go's runtime with generics
#109I do not understand the appeal of go. > The proposal argues that Golang developers are forced to work around language when writing hash-based data structures like Tries or concurrent hash maps. Developers who want an efficient hash-based data structure have only the builtin map to choose from. When this issue was originally created in 2017, Golang didn't have generics And then the author goes to tell us about how thi…
The appeal of Go: - A pretty simple, if not very expressive, language (it's anti-Perl, and seems simpler than JS); you can learn it down to a reasonably productive level in a weekend. (I did.) - A memory-safe language (like Java) with good performance (like Java) without the need to install any runtime, and the ability to ship as a single binary (unlike Java). - A reasonably good and ergonomic concurrency approach (l…
Possible with GraalVM. Has been possible if you were willing to pay long before that. GraalVM produces statically linked binaries with only one external dependency — zlib, which is preinstalled pretty much everywhere. Startup time is measured in milliseconds.
I recently built a mid-size REST backend with quarkus — it ships as a single binary with size comparable to what I'd expect to see if it was written in Go, and starts in about 200 ms (from executing the command to when it's ready to serve its first request).
Having written code in both, I hope GraalVM buries Go in the long term, but in our hype-driven culture it's unlikely.
https://quarkus.io/guides/building-native-image#configuring-...
https://github.com/oracle/graal
> A reasonably good and ergonomic concurrency approach (like JS, unlike Java)
This is also very close to being solved.
Re: Hacking Go's runtime with generics
#110ELI5. How is maphash different from just using map? I am surely missing something. I thought the builtin map used hashing too?
The main difference is, it is an hardware accelerated & optimized compiler function, now exposed via the new maphash package in stdlib.
And it is fast. Faster than the former performance leader xxh3(avx2/avx512).
Try maphash yourself (example data dedupliction) https://news.ycombinator.com/item?id=34091206