←back to thread

Go subtleties

(harrisoncramer.me)
234 points darccio | 1 comments | | HN request time: 0.231s | source
Show context
jasonthorsness ◴[] No.45669948[source]
Great list! Reminds me to check out more of the new stuff in 1.25.

The one thing I wish Go had more than anything is read-only slices (like C#).

The one thing I wish more other languages had that Go has is structural typing (anything with Foo() method can be used as an interface { Foo() }.

replies(2): >>45670075 #>>45672522 #
gethly ◴[] No.45672522[source]
Yeah, having mutability optional would be great. It would also allow a lot of data to pass through the stack instead of heap due to pointers, which Go is riddled with for absolutely no reason(imo).

On the other hand, now that we have iterators in Go, you can create a wrapper for []byte that only allows reading, yet is iterable.

But then we're abstracting away, which is a no-go in Go and also creates problems later on when you get custom types with custom logic.

replies(1): >>45673240 #
1. eikenberry ◴[] No.45673240[source]
> Yeah, having mutability optional would be great. It would also allow a lot of data to pass through the stack instead of heap due to pointers, which Go is riddled with for absolutely no reason(imo).

My guess is that it is due to many developers bringing reference semantics with them from other languages to Go. It leads to thinking about data in terms of pointers instead of values.