Hacker News new | past | comments | ask | show | jobs | submit login

Your opinion seems a bit outdated. Go has had generics for almost 2 years now.



And enumerations from the start.


No it doesn't, it has a hack using constants and iota.


Which is what an enumeration is.

Perhaps you're thinking of sum types? They are often confused as enums.


Not at all.

Go read Algol 60, Pascal, Modula-2, C manuals to understand what enumerations are all about.

Not a comic dance between iota and manually written constants.


It's always bizarre when someone on a discussion forum defers to the writings of someone else. If that someone else wanted to have a discussion, they could do so themselves. But since I'm in a silly mood, I'll play along with your silliness:

From the GNU C manual: "An enumeration type represents a limited set of integer values, each with a name."

Which is exactly what Go provides. Which isn't surprising as it is identical to C in that regard.


No my dear,

this hack

    type Operation int

    const (
    Escalated Operation = iota
           Archived
    Deleted
    Completed
    )
has nothing to do with

   typedef enum {Escalated, Archived, Deleted,  Completed} Operation;
Only someone that can't get type systems would ever assert they are the same.

Literally "Go enums suck", https://news.ycombinator.com/item?id=39564737


> "Go enums suck"

Enums suck, period. That's why many modern languages don't offer enums at all, providing sum types instead, which more accurately model what most people are trying to use enumerations for. It is an antiquated pattern that may have served a useful purpose in the early days of computing, but we've learned a thing or two about programming since then.

Well, at least you've come around to recognizing that Go does have enums, even if you needed someone else's words to say it. After all, Go enums can't suck if it doesn't have them. But, of course, Go purposefully tries to be antiquated. That's kind of its whole deal. Naturally it is going to have enums to really drive home the antiquatedness.


It only took 13 years to get there.


If Go had added generics from the start, it's very unlikely that the implementation would be as solid as the current one. I think their conservative approach paid off in this case.


Did it? It still has several warts, and now gccgo is kind of abandoned, left to stagnate in Go 1.18.

Unfortunely Rust wasn't mature enough in 2013, otherwise the main programing language of most CNCF projects would not have been Go.


I think you're making my case for me here :) Yes, Go reached maturity faster than Rust (despite its first release occurring later – one of the many benefits of simplicity), and the lack of generics doesn't seem to have hurt its adoption. Another victory for Worse is Better.


> Go reached maturity faster than Rust (despite its first release occurring later – one of the many benefits of simplicity)

Rust started as a research language by a PL guy working on his free time, he wasn't even suspecting his work would end up becoming mainstream. Rust only became somewhat serious several years after Go was released and used in production at Google. If you count Graydon's first Rust publication, you may as well count all of plan9 as part of Go's history! (Or how about using Go's repository first commit[0] if we're being facetious)

Also, implementing proper generics should have been straightforward from the start for Go, given that it was already mainstream in multiple programming languages back then (including the super mainstream Java and C#, with different approach). But Go was made by people who believe syntax highlighting is useless, of course they decided against generics…

[0] https://github.com/golang/go/commit/7d7c6a97f815e9279d08cfae...


It would have been straightforward to copy an existing approach to generics (though I suspect that this is a usage of the word ‘straightforward’ that has currency only among people who’ve never written a compiler), but I’m glad they waited and did something better that had a proper theoretical foundation. If they’d naively added generic types to Go from the beginning, you can bet there would have been all kinds of interesting unintended consequences, as there were in the case of Java.


"They are likely the two most difficult parts of any design for parametric polymorphism. In retrospect, we were biased too much by experience with C++ without concepts and Java generics. We would have been well-served to spend more time with CLU and C++ concepts earlier.

-- https://go.googlesource.com/proposal/+/master/design/go2draf...

CLU was invented in 1976, C++ concepts were proposed in 2005!


If you take a step back here, the Go team acknowledged their biases and lack of in-depth knowledge in the domain, consulted with domain experts, and eventually settled on exactly the kind of generics system that you apparently approve of.

Could they have done this earlier, in principle? Sure. But at what cost? What other balls would have been dropped? I think they were absolutely right to focus on aspects of the language design and tooling that they were confident about. Go is all the better for it. It's the polar opposite of a language designed to appeal to programming language enthusiasts; and well, that shows in the reactions.

By all means use Rust. I use Rust sometimes too, and it has its advantages over Go. Personally, I find generics in Go an occasional convenience and missed them only a little before 1.18.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: