←back to thread

131 points apta | 2 comments | | HN request time: 0.393s | 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 #
NateDad ◴[] No.9267258[source]
For anything larger than a trivial program, go is no more verbose than python. For small programs, there's too much variance to really say what language is less verbose, because you can always hit cases where one language has something in the stdlib and one doesn't.

The only place go is more verbose is sorting, and lack of map, filter, and list comprehension. Most of the latter just means you need a 3 line loop where you have one line in python. But that should not be a great effect on any reasonable size program.

replies(1): >>9268232 #
1. Paddy3118 ◴[] No.9268232[source]
You can say that, but it doesn't make it so. Go here: http://rosettacode.org/wiki/Category:Go for many examples of more succinct Python with better commenting than the Go code, for example: http://rosettacode.org/wiki/Align_columns
replies(1): >>9275458 #
2. NateDad ◴[] No.9275458[source]
forgive the copy-paste response from elsewhere on thus thread.

an example from https://www.spacemonkey.com/blog/posts/go-space-monkey -

we decided to transliterate our 90k lines of Python directly to Go, line by line

The 90K number includes our tests, but without tests, the Python codebase is 36,784 lines of code. Those same lines of code became 41,717 lines of Go code. So, not that much of an increase. When you consider that's just 4,933 more lines, it's not crazy to assume most of those are closing braces.

I'd say closing braces and trivial expansions of list comprehensions into 3-5 line loops.

There's a real life example of direct transliteration, not just a rewrite. That's 13.4% more lines. I think that's pretty close.