--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
We still don't understand genrality: the current generics are unimpressive. The proposals for Go are typically "let's do something that has failed already, in hopes that trying it agin will have a different result". That, alas, is one of the definitions of insanity.Due caution is advised!
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
@Bakul - is your approach documented in Egon's collection? I think it is essentially the same as Egon's at
https://groups.google.com/d/msg/golang-nuts/JThDpFJftCY/1MqzfeBjvT4J
Perhaps your syntax is cleaner, simpler. I also like this general approach. In Egon's document, this approach has nearly no downsides.
I agree that it makes the suitable trade-offs. And Linq is doing pretty well without generics (https://github.com/ahmetb/go-linq); not familiar with Rx.When I consider the dilemma, the two things I don't want are slow programmers and slow execution, leaving "slow compilers and bloated binaries". But here is how I think about this option:- There are alternatives that only impact compiler speed if they are actually used. I think that's fair.
- There are alternatives that result in binaries hardly any larger than if you copy-pasted. Again, I think that's reasonable.
As I understand it, the package template approaches fall into this camp. So with the above restrictions, count me in favor of slow and bloated :-)
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
Something I've never seen addressed in the generics tradeoffs debate (not saying it hasn't been, but I haven't see it personally)
is that without generics, you're forced to use interface{}
which just boxes the values anyway. So you're already paying a performance cost for type-agnostic code without generics. And if you copy/paste code instead of boxing, you're just bloating the size of the binary like generic templates would. It seems to me if boxing generics was added, there wouldn't be a downside:
if you didn't want to pay the performance cost of boxing generics, then don't use generics; if you can pay the cost, then use them, and it won't perform any worse than it would now with interface{}, and perhaps could perform even better, depending on the semantics and implementation. You could have the same opt-in performance tax in the form of bloated binaries/slow builds as well,
--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/VbWfF865C3s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts+unsubscribe@googlegroups.com.
Egon:>See https://docs.google.com/document/d/1vrAy9gMpMoS3uaVphB32uVXX4pi-HnNjkMEgyAHX4N4/edit#heading=h.j8r1gvdb6qg9I don't see the Implicit Boxing section point out that this is what happens now when you shoehorn everything into interface{}.
In this sense, I don't see a performance downside for boxing generics compared to the current state of things.
>You can also use copy-paste, code-generation.I was referring to the downsides of copy/paste here: "You could have the same opt-in performance tax in the form of bloated binaries/slow builds as well, but lack of an official debugger right now is predicated on builds being fast, so that seems like a no-go."
>It would be slower than copy-paste and generated approaches.It wouldn't be slower than interface{}, right?
>When generics are added, then they will be (almost) impossible to avoid. So the opt-in "slow builds" isn't really opt-in unless you really try...By opt-in, I meant the code we write ourselves. In shared code, it would be no more impossible to avoid generics than interface{} is now, which doesn't seem to have been a problem. If there's a case where the performance is too slow, one could always copy/paste the code and remove the generics from it.
On Tue, Mar 28, 2017 at 12:28 AM, Egon <egon...@gmail.com> wrote:
On Tuesday, 28 March 2017 07:56:57 UTC+3, Will Faught wrote:Something I've never seen addressed in the generics tradeoffs debate (not saying it hasn't been, but I haven't see it personally)is that without generics, you're forced to use interface{}You can also use copy-paste, code-generation.which just boxes the values anyway. So you're already paying a performance cost for type-agnostic code without generics. And if you copy/paste code instead of boxing, you're just bloating the size of the binary like generic templates would. It seems to me if boxing generics was added, there wouldn't be a downside:It would be slower than copy-paste and generated approaches.if you didn't want to pay the performance cost of boxing generics, then don't use generics; if you can pay the cost, then use them, and it won't perform any worse than it would now with interface{}, and perhaps could perform even better, depending on the semantics and implementation. You could have the same opt-in performance tax in the form of bloated binaries/slow builds as well,When generics are added, then they will be (almost) impossible to avoid. So the opt-in "slow builds" isn't really opt-in unless you really try...but lack of an official debugger right now is predicated on builds being fast, so that seems like a no-go.
On Friday, March 24, 2017 at 12:10:08 PM UTC-7, Mandolyte wrote:The recent survey reveled that generics was thing that would improve Go the most. But at 16%, the responses were rather spread out and only 1/3 seemed to think that Go needed any improvement at all - see link #1. I think most will concede that generics would help development of algorithms, libraries, and frameworks. So in the spirit of friendly rivalry, here is a list of algorithms developed for Swift:As you might guess, it is chock-full of generics. Yeah, I'm a little envious. :-) enjoy...
--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/VbWfF865C3s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
>Because it can also be implemented in other ways.Do you mean interface{} can be implemented in other ways? I couldn't make out your meaning.
>As said... there is a performance upside for some other approaches.The other approaches have downsides, or at least generation does. Compared to using interface{} as is done now, boxing generics improves type safety and expressiveness and has no performance regression. That's a clear net win.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
There is part of the topic that has always been slightly beyond my grasp. (Maybe I do understand...but just lack absolute certainty.) Maybe others know the answer...In a template system (which is what I prefer but that's not the point of this email) we have the notion of the TYPE(s) being a formal argument. We presume that the code will compile or fail based on the suitability of the instantiated type. That is, a templated Min would fail on the comparison "<" if the TYPE was "Map[something]something." Call that a lexical fail.My question is, what about a semantic fail. Say, "<" for floating point. In the sort package the Less function does !Less(a,b)&&!Less(b,a) to figure out Equal(a,b). That works for ints and strings, but when I templated sort I found that it failed in tests with float32 and float64 because of NaN values, which are !Less(a,b)&&!Less(b,a) yet !Equal(a,b). I had to make two templates, one for floating point values and one for integral/string values.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
-j
There is part of the topic that has always been slightly beyond my grasp. (Maybe I do understand...but just lack absolute certainty.) Maybe others know the answer...In a template system (which is what I prefer but that's not the point of this email) we have the notion of the TYPE(s) being a formal argument. We presume that the code will compile or fail based on the suitability of the instantiated type. That is, a templated Min would fail on the comparison "<" if the TYPE was "Map[something]something." Call that a lexical fail.My question is, what about a semantic fail. Say, "<" for floating point. In the sort package the Less function does !Less(a,b)&&!Less(b,a) to figure out Equal(a,b). That works for ints and strings, but when I templated sort I found that it failed in tests with float32 and float64 because of NaN values, which are !Less(a,b)&&!Less(b,a) yet !Equal(a,b). I had to make two templates, one for floating point values and one for integral/string values.My uncertainty is in the fact that I only discovered the problem through testing--i had failed to anticipate it. It was easy to fix, but only after the fact. That makes me wonder about the truly perfect generality of templated reusable software, which would be most perfect if it failed to compile rather than fail in some rare edge condition under use or testing.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
yes
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
On Sat, Apr 1, 2017 at 1:42 AM, Will Faught <will....@gmail.com> wrote:For example []GenericElement could be boxed as:struct{ itab ptr; ... data []struct{elem ptr} }or[]struct{itab, elem ptr}Can you explain in more detail what's going on there? What's itab? You seem to have pointers represents the slice elements, and that's what I meant by allocating on the heap and passing pointers around. Boxing is just moving values from the stack to the heap, or starting a value in the heap rather than the stack, right?When you have a slice you could specify the interface table pointer once or for each element. One could prevents significant amount of memory at the cost of making internals more complicated.Boxing also involves adding additional type information to distinguish between different types of pointers.
Which part of that are you referring to?The 10x performance difference in dictionary implementation between C# and Java.
My original point was the relative upsides and downsides of boxing generics relative to what Go is now, not boxing generics versus other kinds of generics in an abstract sense. Constraints have already been made on these tradeoffs, for instance fast builds. You seem to be talking about general pros and cons for generics approaches and implementations. It'd be great to start from scratch and ponder all these ideas, but I'm talking about building on what we already have.Yes.I think the reason boxing hasn't been implemented is because it doesn't improve the current Go language enough. You can already use interfaces as such boxes and implement small wrapper around them to make it type-safe...
Is something missing here?Accidentally sent the email too early :DThe reason Go doesn't have generics is because the designers of the language try to avoid all the problems listed, at least to some degree.Sure, you can disagree with this philosophy, which is fine, I completely understand. But, that is the route Go Team has chosen. The only way forward is to find newer more interesting trade-offs and implementations.
There is part of the topic that has always been slightly beyond my grasp. (Maybe I do understand...but just lack absolute certainty.) Maybe others know the answer...In a template system (which is what I prefer but that's not the point of this email) we have the notion of the TYPE(s) being a formal argument. We presume that the code will compile or fail based on the suitability of the instantiated type. That is, a templated Min would fail on the comparison "<" if the TYPE was "Map[something]something." Call that a lexical fail.