3 ms·
All of this is specifically about the "Go's Apparent Philosophy" paragraph. Instead of pulling the same quote from Rob Pike over and over and over again, peopl
by Zababa 2y ago
All of this is specifically about the "Go's Apparent Philosophy" paragraph.
Instead of pulling the same quote from Rob Pike over and over and over again, people should watch/read is recent talk about Go titled "What We Got Right, What We Got Wrong": https://commandcenter.blogspot.com/2024/01/what-we-got-right-what-we-got-wrong.html https://commandcenter.blogspot.com/2024/01/what-we-got-right.... A few excerpts:
> Given the title of this talk, many people might expect I'm going to be analyzing good and bad things in the language. Of course I'll do some of that, but much more besides, for several reasons.
> But the real reason I'm going to talk about more than the language is that that's not what the whole project was about. Our original goal was not to create a new programming language, it was to create a better way to write software. We had issues with the languages we were using—everyone does, whatever the language—but the fundamental problems we had were not central to the features of those languages, but rather to the process that had been created for using them to build software at Google.
> The creation of a new language provided a new path to explore other ideas, but it was only an enabler, not the real point. If it didn't take 45 minutes to build the binary I was working on at the time, Go would not have happened, but those 45 minutes were not because the compiler was slow, because it wasn't, or because the language it was written in was bad, because it wasn't. The slowness arose from other factors.
> And those factors were what we wanted to address: The complexities of building modern server software: controlling dependencies, programming with large teams with changing personnel, ease of maintainability, efficient testing, effective use of multicore CPUs and networking, and so on.
> In short, Go is not just a programming language. Of course it is a programming language, that's its definition, but its purpose was to help provide a better way to develop high-quality software, at least compared to our environment 14 plus years ago.
> And that's still what it's about today. Go is a project to make building production software easier and more productive.
I will repeat it because I think it is very important:
> And that's still what it's about today. Go is a project to make building production software easier and more productive.
Another quote about Go being more than the language:
> A few weeks back, when starting to prepare this talk, I had a title but little else. To get me going, I asked people on Mastodon for input. A fair few responded, and I noticed a trend in the replies: people thought the things we got wrong were all in the language, but those we got right were in the larger story, the stuff around the language like gofmt and deployment and testing. I find that encouraging, actually. What we were trying to do seems to have had an effect.
And finally:
> Perhaps the most interesting consequence of these matters is that Go code looks and works the same regardless of who's writing it, is largely free of factions using different subsets of the language, and is guaranteed to continue to compile and run as time goes on. That may be a first for a major programming language.
> We definitely got that right.
So now that we know better what Go is about, we can try to see why the iterators are added. From https://github.com/golang/go/issues/61405#issuecomment-1638896606 https://github.com/golang/go/issues/61405#issuecomment-16388.... I'll quote some parts:
> Can you provide more motivation for range over functions?
> The most recent motivation is the addition of generics, which we expect will lead to custom containers such as ordered maps, and it would be good for those custom containers to work well with range loops.
> Another equally good motivation is to provide a better answer for the many functions in the standard library that collect a sequence of results and return the whole thing as a slice. If the results can be generated one at a time, then a representation that allows iterating over them scales better than returning an entire slice. We do not have a standard signature for functions that represent this iteration. Adding support for functions in range would both define a standard signature and provide a real benefit that would encourage its use.
> There are also functions we were reluctant to provide in slices form that probably deserve to be added in iterator form. For example, there should be a strings.Lines(text) that iterates over the lines in a text.
To me this provides enough justification for adding the iterators. But that's not the important part. The important part is listening to what people say about Go, not just "Go the language", but Go as a whole. And listening to what people said recently, not what they said a decade ago. This is how you genuinely engage with other people, I think.
- valyala 2y agoThanks for providing the brilliant citations of Rob Pike! I like the most these ones: > Go is a project to make building production software easier and more productive. > Go code looks and works the same regardless of who's writing it, is largely free of factions using different subsets of the language But I don't understand how these citations align with iterators in Go: - Iterator functions are non-trivial to write and read because they return a function, which accepts a function, which accepts iterable items. - The 'for ... range' loops with iterators are non-trivial to debug, since they __implicitly__ call iterator function and then __implicitly__ pass loop body converted to __implixit__ anonymous function, to the function returned by iterator function. - Iterators do not replace existing functions - they add __new__ functions because of backwards compatibility. This complicates writing, reading and maintaining Go code, since there are multiple ways to do the same thing. - Iterators encourage adding crappy iterator functions to the existing code, making it more complicated and harder to maintain.
- adeptima 2y agothnx for compiling quotes! useful
- Zababa 2y agoYou're welcome! I think as Go users we're very lucky to have all that information in the open, and that the people driving the language take the time to write it down, and discuss it with the community. I'll assume good intention and think it's not trivial to find, or the people writing articles/comments citing the same Rob Pike quote again and again don't know that he wrote and talked more about Go. I hope I can help elevate the debate a little by sharing these quotes.