How to use interfaces in Go (2012)
jordanorelli.com
How to use interfaces in Go (2012)
1–10 of 30 posts
Re: How to use interfaces in Go (2012)
#2> animals := []Animal{Dog{}, Cat{}, Llama{}, JavaProgrammer{}}
> for _, animal := range animals {
> fmt.Println(animal.Speak())
> }
> }
This makes my eyes hurt. In this modern age we still haven't learned to create easy to read languages?
Re: How to use interfaces in Go (2012)
#3> func main() { > animals := []Animal{Dog{}, Cat{}, Llama{}, JavaProgrammer{}} > for _, animal := range animals { > fmt.Println(animal.Speak()) > } > } This makes my eyes hurt. In this modern age we still haven't learned to create easy to read languages?
There's a lot going on in about 3 lines.
Re: How to use interfaces in Go (2012)
#4https://news.ycombinator.com/item?id=9320235
The blog post is from 2012.
Re: How to use interfaces in Go (2012)
#5Re: How to use interfaces in Go (2012)
#6Re: How to use interfaces in Go (2012)
#7Re: How to use interfaces in Go (2012)
#8> func main() { > animals := []Animal{Dog{}, Cat{}, Llama{}, JavaProgrammer{}} > for _, animal := range animals { > fmt.Println(animal.Speak()) > } > } This makes my eyes hurt. In this modern age we still haven't learned to create easy to read languages?
Re: How to use interfaces in Go (2012)
#9> func main() { > animals := []Animal{Dog{}, Cat{}, Llama{}, JavaProgrammer{}} > for _, animal := range animals { > fmt.Println(animal.Speak()) > } > } This makes my eyes hurt. In this modern age we still haven't learned to create easy to read languages?
I think the syntax is terse mostly for the sake of example. There's a lot going on in about 3 lines.
n = sum(x for x in my_sequence if x % 2 == 0)
But the Go code listed above is not just plagued with a lot going on in "3 lines". I think there's something to be said about gratuitous operators, and a sort of beauty to letting the parser do more work than the programmer themselves. I don't use Go at all, but from the example above I can tell it is a horribly grotesque language considering when it was created. Sure, even C or C++ have curly braces and array specifiers for types; however, at least these have the excuse of age and compatibility to work with. Go is relatively new, and I think that welder was getting at is that syntax shouldn't be some overly complex thing in this day and age. Nim and Elixir come to mind as two (newer) languages that avoid many syntax warts without making significant trade-offs because of it.Re: How to use interfaces in Go (2012)
#10> func (j JavaProgrammer) Speak() string { > return "Design patterns!" > }
shrug At least our language designers trusted our intelligence enough to implement generics.