Live data from Hacker News

Golang generics proposal has been accepted

github.com

151–160 of 176 posts

Re: Golang generics proposal has been accepted

#151

Nobody will have anything to complain about once go has generics, we'll never hear about Golang on Hacker News again! It'll just be the Rust people complaining. ;)

Error handling, lack of enums, modules, too big executatbles, lack of optimizing backend, middle class GC implementation.

Re: Golang generics proposal has been accepted

#152

Earlier quoted context omitted.

> C doesn't have them and is arguably the most successful language in history. I'm not sure "C didn't have it" is a good litmus test for determining the value of features... C is called a portable assembler for a reason. > Yes, they are convenient, but they also add a lot of complexity to the language and toolchain. Conversely, proponents of generics would argue that not having them creates complexity for software de…

> I'm not sure "C didn't have it" is a good litmus test for determining the value of features It can be a good test. One reason why C is so ubiquitous is the simple binary interface. This makes it easy to reuse code since the libraries can be imported by every other language out there. C code is relatively simple and the compiled objects follow simple binary interfaces. Adding features to languages almost always incr…

UNIX ABI.

Re: Golang generics proposal has been accepted

#153
post #19

I really wish they went with angle brackets like everyone else does. I get the argument about not wanting to break existing parsers but this is a significant enough language change to warrant that.

Nim, CLU, Eiffel and Scala use square brackets.

D, Modula-3 and Ada use parenthesis.

ML based languages use quoted letters.

There is no everyone else.

Re: Golang generics proposal has been accepted

#154
post #104

Earlier quoted context omitted.

> I wish that Go would adopt Sum Types And then make a Maybe sum type? But then it is too late as the std lib communicates with nils instead of Maybes > The best way to know something won't be null is to use value types where possible. Don't return nilable values unless you have a good reason. I'm not doing this, I'm using an API that does! I cannot choose what some code returns, all I can do is --sigh-- add another…

> If it is my discipline to add null guards or have runtime explosions I consider the nulls to be implicit. But they're still explicit nulls. You seem to be saying that only implicit nulls require null guards, but that's just not what that means (as far as I have learned). You seem to hate nullability as a concept, which is fine, but that's different from hating implicit nullability. > That you find as much runtime p…

Explicit to me is when I can see from the return type it is or isnt nullable AND that i have to deal with the null case explicitly (so nullableUser.lastName() errors out as I cannot call lastName() on null).

But I might well be mistaken.

Re: Golang generics proposal has been accepted

#156

IMO the biggest factors for the success of Go are 1) super-fast compile times, 2) easy to interpret compiler errors, and 3) dead simple shipment of high performance, native static binaries. I think Go has succeeded, despite, not because of the language itself. One very big limitation being the lack of generics or any sort of ability to leverage higher-order types. Sometimes making a small modification to a large code…

> That being said, I really hope that Go's core team understands the drivers of its popularity and doesn't compromise the operational side for the sake of language improvements. Although higher-typed languages have no trouble achieving good runtime performance, it seems like there's a fundamental tradeoff at compile time.

Indeed, this is part of the reason the generics have been so long in coming to Go; you can find discussions about how to implement them as far back as 2009. One of the reasons they aren't using `` to indicate them is specifically because it drastically changes the speed of parsing (since you would need to figure out whether that `I can't find the reference right now, but there was a quote in one of the early discussions that was something like:

The Generic Paradox is this: You can have slow programmers (no generics; programmers have to do their own code duplication), slow executables (where you do loads of unboxing), or slow compile times.

EDIT: Found the reference; the exact quote is: "The generic dilemma is this: do you want slow programmers, slow compilers and bloated binaries, or slow execution times?" [1]

The Golang generics proposal was specifically designed to try to reduce the "slow programmers" effect while avoiding either of the other two effects as much as possible.

[1] https://research.swtch.com/generic

Re: Golang generics proposal has been accepted

#157

IMO the biggest factors for the success of Go are 1) super-fast compile times, 2) easy to interpret compiler errors, and 3) dead simple shipment of high performance, native static binaries. I think Go has succeeded, despite, not because of the language itself. One very big limitation being the lack of generics or any sort of ability to leverage higher-order types. Sometimes making a small modification to a large code…

> Scala, Haskell, even Typescript have painful compile times. Can’t speak to the first two, but in some places TS has pathological compile times when you’re trying to give more information to the compiler . A recent example is trying to appease type inference on a set of generics where a wrapped function couldn’t narrow types from its wrapper even though they were totally valid but mostly inferred. I wrote a type gua…

You can try ReasonML/Bucklescript/ReScript. WARNING it may spoil you, by compiling in fractions of a second and make waiting for tsc miserable. Only do it if you have a high frustration tolerance.

Re: Golang generics proposal has been accepted

#158

This will probably be downvoted, but I personally never felt a huge need for generics. C doesn't have them and is arguably the most successful language in history. Yes, they are convenient, but they also add a lot of complexity to the language and toolchain. I suspect that this proposal being accepted is largely due to the huge growth of the Go community - I bet the original team (in particular, I'm thinking of Rob P…

> C doesn't have them and is arguably the most successful language in history. And many C programs just emulate them using crazy macros, that are harder to write and are less typesafe than proper generics.

I was going to say -- the way you write a lot of "generic" code in C is with macros. Coming to Golang from C and having neither C-style macros nor proper generics was quite painful.

Re: Golang generics proposal has been accepted

#159
post #153
post #19

I really wish they went with angle brackets like everyone else does. I get the argument about not wanting to break existing parsers but this is a significant enough language change to warrant that.

Nim, CLU, Eiffel and Scala use square brackets. D, Modula-3 and Ada use parenthesis. ML based languages use quoted letters. There is no everyone else.

You've taken my comment too literally. The point I was making here wasn't "angle brackets are used without exception" (clearly that's never going to be true given the rich tapestry of programming languages out there) but instead "I don't like the aesthetic of square brackets". Really it was a statement expressing a personal opinion rather than an empirical fact. Is it a little misleading? Perhaps, but that's natural languages for you (I would have edited my own post to make my point clearer but I was outside the edit window by the time I had realised how ambiguous said point was).

I have gone into more detail about why I don't like the square brackets notation for generics to one of the other replies so I wont reiterate myself here and simply suggest you read the replies before commenting.

Re: Golang generics proposal has been accepted

#160
post #92
post #63

"We don't need generics" "We don't need exceptions" "We don't need ORMs"

2 out of 3 right ain't bad. We really don't need ORMs

Yep, I can see at work how fantastic are those hand written sql scripts wrapped in bash to run migrations, and those magnific joins and manual mapping of dates.

That's great, until you realize you have an actual product to build.

Post reply on HN