- I like
gofmt
. - Having used Java for so long, I got tripped up by the passing by value of structs and had to change the parameters to pointers.
- I also got tripped by the
:=
declaration shadowing variables:
func pop(n int, list []int) ([]int, error) {
if n > len(list) {
return list, errors.New("error")
}
return list[n:], nil
}
func multipop(counts []int, list []int) ([]int, error) {
for _, n := range counts {
list, err := pop(n, list) // Oops, a new variable named list
if err != nil {
return list, err
}
}
return list, nil
} - I like goroutines + a channel better than
java.util.Iterator
and Python gemerators, but not as much as lazy lists in Haskell for producer/consumer code. containers/list
looks very awkward compared tojava.util.List
, especially with Java generics. Generics are almost essential for useful containers, so Go inelegantly has the built-in functionappend
and the built-inmap
data structure.
Monday, March 19, 2012
Some thoughts after using Go for a couple of days:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment