Even though I have bashed Go's lack of generics throughout its existence, this point no longer applies,<p><pre><code> package main
import (
"fmt"
)
func Id[T any] (a T) T{
return a
}
type Stack[T any] struct {
items []T
}
type Num interface {
type int, int16, int32
}
func add3[T Num](a T, b T, c T) T {
return a + b + c
}
type LinkedList[T any] struct {
value T
next *LinkedList[T]
}
func (oldNode *LinkedList[T]) prepend(value T) *LinkedList[T] {
return &LinkedList[T]{value, oldNode}
}
func tail[T any] (value T) *LinkedList[T] {
return &LinkedList[T]{value, nil}
}
func traverse[T any](ll *LinkedList[T]) {
if ll == nil {
return
}
fmt.Println(ll.value)
traverse(ll.next)
}
func main() {
node := tail(5).prepend(6).prepend(7)
traverse(node)
}
</code></pre>
<a href="https://go2goplay.golang.org/p/9cpHFGwuZmA" rel="nofollow">https://go2goplay.golang.org/p/9cpHFGwuZmA</a>
Well, it must be good at _something_, or it wouldn't be as popular as it is. Perhaps it's not a perfect language and perhaps that is not important at all. I use Go on a daily basis and even after doing that for years am still very happy with it.<p>I read lists like these, try to understand what the complaint is and then... I realize that I just don't care. There have been two or three occasions in my career that I thought "Man, it would be nice if I could use some generics now", but other than that: I don't give a fuck.<p>Go is simple enough that I can do whatever I want with it, without holding me back. It is simple enough that I can understand what my colleagues try to do without much effort. It may miss some convenient short cuts, but it is trivial to implement them yourself on the spot.<p>If it feels therapeutic to write down you annoyances, by all means go ahead. Let it out and get some peace of mind. Other than that: stop whining and just go build something useful with whatever language you prefer.
Well, if you prefer Rust, Haskell or C++ then why don't you just use Rust, Haskell or C++? Languages like Go or Oberon are intentionally as simple as possible, which is their core benefit, not their weakness. That is precisely the advantage of the diversity of languages: you can choose the one that suits you best.
Go seems to be a favorite language to hate, and yet, there's a lot of awesome software in the world because of it. It's simply and lack of features was intentional; not a design flaw. It was built by some of the premier computer scientists of our age not for lacking of knowledge of modern language features but intentionally avoiding complexity.<p>Choose Rust and C++ for building your next OS, but Go is great when I need to build a web service that's fast enough and hire a team that may not know the language walking in the door but can be productive quickly.
User defined operators frequently lead to programs that are difficult to understand, e.g. what is this '+'. When reading you will probably at first assume that it is adding two numbers, but then you also have to consider all other versions of this operator function. A function call with a good descriptive name is much clearer.
I get what you are saying, and that's why I am personally sticking with C++, and in the future Rust, but I can understand why many like the comfort of a simple language like Go. It has attracted many C developers who don't like the heavy abstractions that C++ and Rust offers.
> Generic Programming<p>The author does not seem to be aware that generics are coming in Go 1.18.<p>> Language Extensibility<p>Go was carefully designed to disallow this kind of extensibility. The point is that operators and other language constructs like `for ... range` always can be trusted and have a known cost. The author basically lists a pro as a con.
Ugh, this again. I can already predict the responses:<p>Person A: “go lacks feature X!”<p>Person B: “that’s what makes it so simple!”<p>And round and round it goes...
Second time a new account posts this 2014 article in 2 weeks.<p>Flagged, here's some previous discussion: <a href="https://news.ycombinator.com/from?site=yager.io" rel="nofollow">https://news.ycombinator.com/from?site=yager.io</a>