←back to thread

131 points apta | 1 comments | | HN request time: 0.288s | source
Show context
barsonme ◴[] No.9266431[source]
His Go is a little disingenuous. This (https://gist.github.com/EricLagerg/105431503d32f18d239b) is almost as short as his D code, and functions the same.
replies(3): >>9266456 #>>9266519 #>>9267772 #
jff ◴[] No.9266456[source]
It's almost as if, like most people who write articles complaining about Go's lack of "expressiveness" and generics, he took a cursory look at the language, wrote some naive examples that supported his point, and squeezed out a blog post.
replies(2): >>9267073 #>>9275089 #
waps ◴[] No.9267073[source]
If the code was equivalent you might have a point. Unfortunately it is not (tokenizing/line scanning vs. copying). One has a shortcut in Go, the other does not.

Would you say that Go is not excessively verbose in non-trivial use cases ? I recently had to sort a struct list in a program. Added lines of code for sorting a single list once : 30. What the ...

replies(3): >>9267253 #>>9267258 #>>9267303 #
okbake ◴[] No.9267253[source]
I'm curious about the specifics of your problem. I couldn't imagine sorting a list of structs (by one of the fields I presume) would be too terribly different in Go than in other langauges. Heres an example of insertion sort on a basic type: https://play.golang.org/p/SPoiNRVl2B

You can use the standard library sort methods by making your type implement the sort interface. Heres an example taken from the example in the sort docs: https://play.golang.org/p/oeRIhHi1Ei

replies(2): >>9267583 #>>9273646 #
1. waps ◴[] No.9267583[source]
This post contains a comparison : https://news.ycombinator.com/item?id=9267578