It's Friday gents! No excuse to set aside Saturday and Sunday, you can easily go through these examples in two days and grok it. Go is that _slim_, and that's good! Guaranteed you'll find use for Go in one system or the other when you want easy deployment, fast development time and extreme speeds. :) (Disclaimer: I love Go and I hope it goes mainstream in a big way in 5 years)
One nice thing these examples also do is make it really simple for detractors to point out what they don't like about it. My #1 gripe about go, for example, is this: https://gobyexample.com/sorting-by-functions In a few other languages: // C++ sort(vs.begin(), vs.end(), [](const string& l, const string& r) -> bool { return l.size() When they fix this, Go might be the perfect language for me. Until then, I'm not touch…
Go by Example
51–60 of 130 posts
Re: Go by Example
#52Earlier quoted context omitted.
Never underestimate the power of nitpicking in an HN thread.
It is amusing that you consider either generics or durability to be "nitpicks." One is a feature that is present in almost every static language of at least the last two decades, and another is a fundamental need of most database users, relational or not. Unless by nitpick you mean, "something I personally don't care about," I think your nitpick-classifier is a bit busted.
Bringing that into a thread regarding a very cool set of examples regarding the core features of the language, isn't very constructive (at least IMO).
Re: Go by Example
#53Earlier quoted context omitted.
What are the C++14 parts here? I haven't been paying much attention to the C++14 standards shaking out. dfrey already asked about why begin/end are functions now. I see auto being used inside the lambda. Was that not allowed in C++11? I got sucked into the "use auto everywhere" mantra, so I just imagined it was possible, but could easily see if it were not. That is probably the biggest decrease in size to the origina…
> I see auto being used inside the lambda. Was that not allowed in C++11? It wasn't: http://stackoverflow.com/a/7709970/39622
Re: Go by Example
#54Earlier quoted context omitted.
I would surely never take these complaints to a go-specific discussion board. That would be disruptive and rude. But this site is not that. I will react to stories on here as pleases me, and it pleases me to constructively criticize certain go design choices sometimes when the subject comes up.
You don't fool anybody, the subject didn't come up untill you brought it. The thread is about a site that shows examples of Go code and explains them, there's no discussion about the advantages or disadvantages of their design decisions, just matter of fact statements. Of course, you can do whatever you want, but that doesn't mean that the rest of us won't probably look at your comments thinking "Here come the generi…
But seriously, they may not implement generics out of spite or just to troll generics zealots.
Edit: remove ambiguity
Re: Go by Example
#55Earlier quoted context omitted.
What does yet another gripe about generics in Go have to do with a tutorial written by an independent party, one that is about features in the language today ?
It was in response mainly to: > Go is that _slim_, and that's good! Guaranteed you'll find use for Go in one system or the other... I'm all for learning new programming languages, but if you're going to learn a new programming language, why not use one that has new ideas?
Go hits some sweet spot, apparently, since some people are happier using it than anything else they had tried. If no "new ideas" are going to help them, why should they chose more "innovative" languages instead of Go?
Re: Go by Example
#56Earlier quoted context omitted.
It is amusing that you consider either generics or durability to be "nitpicks." One is a feature that is present in almost every static language of at least the last two decades, and another is a fundamental need of most database users, relational or not. Unless by nitpick you mean, "something I personally don't care about," I think your nitpick-classifier is a bit busted.
I don't consider the features (or lack thereof) to be nitpicks. They are valid criticisms, but they have had their own very extensive discussions, and we are all very aware of them. Bringing that into a thread regarding a very cool set of examples regarding the core features of the language, isn't very constructive (at least IMO).
Re: Go by Example
#57Earlier quoted context omitted.
Why are "begin" and "end" functions now instead of methods on the iterator? Do they consider it better because now you can pass around functions, but not methods?
Because it works with arrays.
Re: Go by Example
#58Earlier quoted context omitted.
With C++14 this becomes sort(begin(vs), end(vs), [](auto const& l, auto const& r) { return l.size() Even simpler.
What are the C++14 parts here? I haven't been paying much attention to the C++14 standards shaking out. dfrey already asked about why begin/end are functions now. I see auto being used inside the lambda. Was that not allowed in C++11? I got sucked into the "use auto everywhere" mantra, so I just imagined it was possible, but could easily see if it were not. That is probably the biggest decrease in size to the origina…
Re: Go by Example
#59Earlier quoted context omitted.
That's something for the Go creators to decide, but personally I enjoy the feeling of safety that comes with lack of generics. I have very few Go bugs at runtime and I think that explicitness plays a huge part in it.
Not having generics reduces explicitness (because you don't specify the types of your containers) and reduces safety (because of all the casts and manual implementations of things like swap functions).
There are too many indirections to follow manually. All I know is that the compiler will select some function that has conforming types. The compiler is very very smart. It knows all the incredibly complicated name resolution rules and it will use each one of them.
Unfortuntately I'm not as smart. Even after more than 20 years of using C++ I sometimes fail to anticipate which function the compiler decides to use. And that is not safe.
In fact it is less safe than casting interface{}, because that will at least fail fast at runtime instead of silently doing something unexpected.
Re: Go by Example
#60This documentation is great, but one thing I tend to miss with examples like these is how to structure a project, deal with packages, etc.
Since your folder structure is also your package structure, with rmux[1] I tried to separate the project into dependencies, and use a package for each one. I like to also limit files to one class--but if you read through the default package files, the creators seems to go both ways.
One interesting thing that isn't mentioned often is how to handle the equivalent of #ifdef, through +build flags. This isn't the best solution, since all functions and their arguments are evaluated (even empty functions), but it does allow for the use of constants to wrap around cpu-wasteful debug-only areas/