Live data from Hacker News

Four days of Go

evanmiller.org

31–40 of 187 posts

Re: Four days of Go

#31

Earlier quoted context omitted.

extra long functions promotes breaking them down into smaller functions.

Of course - absolutely. No-one disputes that (seriously). The difference ends up being between a 5 line function, which does 5 simple things, and a 20 line function that does 5 simple things. In my previous example, it was 1 line which returned either the name, or 'New Name', or else 5 lines to do the same. In the end, not a big deal. A matter of taste, rather than judgement, I feel.

I suppose one could argue that it's one line actually doing 3 things... but anyway. Not a big deal, at the end of the day.

Re: Four days of Go

#32
post #3

Earlier quoted context omitted.

I enjoyed that the author readily admits to his own faults concerning Go too: In this telling, the story of Go is really a tale of revenge, not just against slow builds, but against all kinds of sloppy programming. Which in my opinion is too bad, because I myself am a sloppy programmer. This really does seem to be the approach I see with the Go digest mailing list. What I don't understand though is the ease of import…

Go is developed inside Google where all dependencies are checked into their global version control repository. There are literally no versions inside the Google codebase - everything is compiled at head. If you want to upgrade a third party library then you are expected to globally upgrade every user of it .... simply bumping the version of a widely used library can thus turn into a multi-month promotion worthy proje…

> Given this background and the Go designers focus on Google's internal needs

Does it mean the community isn't a priority? this vertical relationship between the Go team and the community could doom the language as fast as it was made popular, that's my opinion.That's a real issue.

Re: Four days of Go

#33
post #30
post #12

Earlier quoted context omitted.

Which is why Go has goto's and pointers. Got it. No, Go's adherents are just sloppy in a different way. I have many bad things to say about Haskell, but I admire Haskellers lack of sloppiness. I cannot say the same about Gophers.

Go's goto is the standard structured-programming-limited goto which is not allowed to violate blocks, which means it is not the goto that is "considered harmful". Go's "pointers" are not allowed to do pointer arithmetic, which basically means that they are references. As they are also backed by a garbage collector, this means you can't do any of the nasty C things you can do with them, not even "fail to deallocate" t…

Goto's create unreadable code and are unnecessary. They're there to encourage the writing of bad code.

You can pass a pointer over a goroutine channel. That's my main issue with them, beside the fact that we should be past this needless complication of our code. Again, they're unnecessary and encourage bad code.

Re: Four days of Go

#34
post #4
post #2

In other words, Go represents a kind of Machiavellian power play, orchestrated by slow-and-careful programmers who are tired of suffering for the sins of fast-and-loose programmers. The Go documentation refers quite often to intolerable 45-minute build times suffered by the original designers, and I can’t help but imagine them sitting around and seething about all those unused imports from those “other” programmers,…

> faith Or arrogance and incompetence. It's been said many times. Go team should spend at least one day with Gilad Bracha...

[deleted]

Re: Four days of Go

#35
post #4
post #2

In other words, Go represents a kind of Machiavellian power play, orchestrated by slow-and-careful programmers who are tired of suffering for the sins of fast-and-loose programmers. The Go documentation refers quite often to intolerable 45-minute build times suffered by the original designers, and I can’t help but imagine them sitting around and seething about all those unused imports from those “other” programmers,…

> faith Or arrogance and incompetence. It's been said many times. Go team should spend at least one day with Gilad Bracha...

I find it amusing that people would use the term "incompetence" to describe Ken Thompson and Rob Pike. These two guys have been as instrumental in shaping modern computing as Linus Torvalds, Bill Gates and Steve Jobs.

But I guess it's easy to be critical of other peoples output when you're an anonymous internet user yourself.

Re: Four days of Go

#38

Earlier quoted context omitted.

It's a balance between readability meaning 'short, and concise' and readability meaning 'very clear, even if that requires being overly verbose'. return (data.name !== '' ?: 'New Data') or Python style: return (data.name if data.name else 'New Data') vs: if (data.name != '') { return data.name } else { return 'New Data' } The former being much more concise, so that you can display (and grok, perhaps) a single functio…

> if (data.name != "") { > return data.name > } else { > return "New Data" > } Not exactly... if data.name != "" { return data.name } return "New Data" And consider the likely context... func name(ref int64) string { data, ok := get(ref) if !ok { return "No Data" } if !data.valid { return "Invalid Data" } if data.name == "" { return "New Data" } return data.name } Straightforward and unambiguous.

Doesn't compile though. You'll need lots of extra lines just to see an output, which is really much of what the posted article was talking about with its wandering-eyed gopher tale...

    package main
    import "fmt"
    func main(){
      fmt.Println(name(28))
    }
    type T struct{name string; valid bool}
    func get(ref int64) (T, bool) {
      return T{"abc", true}, false
    }
    func name(ref int64) string {
      switch data, ok := get(ref); true {
      case !ok:
        return "No Data"
      case !data.valid:
        return "Invalid Data"
      case data.name == "":
        return "New Data"
      default:
        return data.name
      }
    }

Re: Four days of Go

#39
post #5

Earlier quoted context omitted.

I think this is part of it, some of the hate comes from people that "know better" (possibly true for some, obviously the Go authors aren't omnipotent) than the Go language designers and are baffled that the language design ideas they know about aren't in the language. But I can tell you in my experience that this type of forceful "everything is a error, no warnings" and "it is done this way (formatting for instance)"…

> ...are a breath of fresh air... Agreed. Go lacks many things, but the "zen" of Go is wonderful feature most people aren't aware of, or under appreciate. I wouldn't use Go for everything, but I wouldn't dismiss it because it doesn't have a favorite language feature.

> Agreed. Go lacks many things, but the "zen" of Go is wonderful feature most people aren't aware of, or under appreciate.

It's funny that you use the word "Zen" - about two years ago, I gave a talk about Go to the New York Python Meetup about why I switched to Go[0], and the punchline was that Go fits the Zen of Python[1] better than Python does[2].

[0] Before anyone gets upset - they asked me to speak, and they were genuinely happy with the presentation. It's not like I went in there to troll with a talk on "This is why your language sucks"!

[1] https://www.python.org/dev/peps/pep-0020/

[2] If anyone's interested, these were the slides: https://s3.amazonaws.com/golangweekly/go_for_pythonistas.pdf

Re: Four days of Go

#40
post #33
post #30

Earlier quoted context omitted.

Go's goto is the standard structured-programming-limited goto which is not allowed to violate blocks, which means it is not the goto that is "considered harmful". Go's "pointers" are not allowed to do pointer arithmetic, which basically means that they are references. As they are also backed by a garbage collector, this means you can't do any of the nasty C things you can do with them, not even "fail to deallocate" t…

Goto's create unreadable code and are unnecessary. They're there to encourage the writing of bad code. You can pass a pointer over a goroutine channel. That's my main issue with them, beside the fact that we should be past this needless complication of our code. Again, they're unnecessary and encourage bad code.

In my organization Goto's have to get past code review, which is rare and when they do make sense they are probably good option. Your organization can have its own style guidelines.... Just say no gotos- done.
Post reply on HN