Live data from Hacker News

First chapter of Kernighan and Donovan's new Go book [pdf]

gopl.io

61–70 of 233 posts

Re: First chapter of Kernighan and Donovan's new Go book [pdf]

#61
post #45

From the book: "But it has comparatively few features and is unlikely to add more. For instance, it has no implicit numeric conversions, no constructors or destructors, no operator overloading, no default parameter values, no inheritance, no generics, no exceptions, no macros, no function annotations, and no thread-local storage."

Are they actually proud of having no generics? :o

No, the authors specifically said that they would like to have generic features but couldn't figure out a way to implement it without unacceptable performance problems.

I'm pretty sure the feature will show up in the next few minor version increments.

Re: First chapter of Kernighan and Donovan's new Go book [pdf]

#62
post #44

Earlier quoted context omitted.

Yeah, I know 100x is a huge multiplier, but I've actually tracked myself to the extent possible, and that really is the right order of magnitude for me. There are a number of reasons. I find refactoring is way, way simpler. Refactoring in Python feels painful enough that I always put it off until it gets absolutely necessary. With Go, I find it takes way less time, and also less mental energy. The static typing and s…

The static typing and strict compiler (enforcement of imports and lvalues, etc.) works well for my writing style. It seems you more enjoy just "Not Python" than Go itself. Go is still pretty awful and designed without really consulting what would help users. It's just designed for what the creators want, but now millions of people are trying to use it—not just 8 people inside the Nation of Google. It's getting worse…

> It seems you more enjoy just "Not Python" than Go itself.

No, I have experience with lots of languages. I'm comparing to Python here because that's what OP asked for.

I don't think Go is "just designed for what the creators want", but even if it were, I don't care, because that's what I want as well.

I'm talking about my personal experience of Go based on my own experience writing Go full-time for over three years, which is as long as the language has had a stable release. With all due respect, it's highly unlikely that a review from someone using it for four days is somehow going to change how productive I've already found the language makes me.

Re: First chapter of Kernighan and Donovan's new Go book [pdf]

#63

To those in the Go community: - What is Go well suited for other than network programming? - Why might one decide to write the backend API of their web app in Go, compared to say Grails, Python etc.

I wrote some scientific code in it (some parsing, some processing). It was much easier to ensure that the code was secure (important when you parse possibly evil files), compared to C++, and it was much faster than Python and pretty easy to maintain.

Re: First chapter of Kernighan and Donovan's new Go book [pdf]

#64

From the book: "But it has comparatively few features and is unlikely to add more. For instance, it has no implicit numeric conversions, no constructors or destructors, no operator overloading, no default parameter values, no inheritance, no generics, no exceptions, no macros, no function annotations, and no thread-local storage."

> no default parameter values

Hearing this leaves a bad taste in my mouth, because one of the (mis)features I've found in Go is its implicit default value in struct initialization. In Go, you don't get a compile error when you miss some fields while initializing a struct. e.g.

  type T struct {
    a int
    b string
    c float64
  }
  
  t := T{c: 1.5}
will happily set `t.a` to 0 and `t.b` to an empty string. While this is useful for maintaining backward compatibility (adding more fields to a struct doesn't break upstream code), it also hinders discovering genuine mistakes at compile time. So typical Go programs end up using 0 or an empty string as a sentinel value. This is probably what made me feel Go's dynamic nature the most. It really is pretty close to a dynamic language.

Re: First chapter of Kernighan and Donovan's new Go book [pdf]

#65
post #60

To those in the Go community: - What is Go well suited for other than network programming? - Why might one decide to write the backend API of their web app in Go, compared to say Grails, Python etc.

Brad Fitzpatrick, a prominent Go developer and Google engineer actually gave a talk covering some of this at GoCon Tokyo last year: http://talks.golang.org/2014/gocon-tokyo.slide Skip to slide 32 for examples of different tasks for which Go is proving to be efficient.

[deleted]

Re: First chapter of Kernighan and Donovan's new Go book [pdf]

#66

To those in the Go community: - What is Go well suited for other than network programming? - Why might one decide to write the backend API of their web app in Go, compared to say Grails, Python etc.

Apart from the already mentioned reasons, another one would be maintainability.

Go was designed with this in mind and some of its shortcomings come from this approach. It is a relatively small language, with one way of doing a certain thing and a mandate of using standard libraries and strict code formatting.

It sounds limiting but it is productive and makes every Go developer write in the same style.

So whether it is you that you return to your project after a few months or a new developer, you will be able to (re)engage with the code quickly.

Re: First chapter of Kernighan and Donovan's new Go book [pdf]

#67
post #59

I still prefer forced data abstraction, i.e. classes as a core construct. GO does not force that. Data abstraction, when properly done maps the code more closely into the problem domain to be solved. In the long run that makes the code more maintainable and extensible.

I am really not sure this is true. In my opinion classes force an premature taxonomy almost all the time. I like that you can simply attach methods to structs when you decide you want object like behavior.

I understand both points of view but lean strongly toward why-el's. If there's one thing Java has taught us it's that "premature taxonomy" (love that term) can be a huge unnecessary tax on small to medium sized projects.

Re: First chapter of Kernighan and Donovan's new Go book [pdf]

#68

From the book: "But it has comparatively few features and is unlikely to add more. For instance, it has no implicit numeric conversions, no constructors or destructors, no operator overloading, no default parameter values, no inheritance, no generics, no exceptions, no macros, no function annotations, and no thread-local storage."

> no default parameter values Hearing this leaves a bad taste in my mouth, because one of the (mis)features I've found in Go is its implicit default value in struct initialization. In Go, you don't get a compile error when you miss some fields while initializing a struct. e.g. type T struct { a int b string c float64 } t := T{c: 1.5} will happily set `t.a` to 0 and `t.b` to an empty string. While this is useful for m…

[deleted]

Re: First chapter of Kernighan and Donovan's new Go book [pdf]

#69
is there a way to `go get gopl.io` all the source code at once? currently, you have to do (and know the chapter names) like this `go get gopl.io/ch1/hello-world` (or something like that - I don't remember exact url), but, as mentioned, it only works if you know chapter names. Better if you could just get whole bundle

Re: First chapter of Kernighan and Donovan's new Go book [pdf]

#70
post #41

Earlier quoted context omitted.

Most talented people can write 200 "productive" lines of code per day (not copy/paste java boilerplate). So, 100x would mean you are now writing 20,000 lines of code per day.

"One of my most productive days was throwing away 1000 lines of code." — Ken Thompson, Go designer

heh, and Go is great when you want to write throwaway code. Mission Accomplished.
Post reply on HN