Replacing Clever Code with Unremarkable Code in Go
31–40 of 140 posts
Re: Replacing Clever Code with Unremarkable Code in Go
#32Earlier quoted context omitted.
Nice. I still haven't given Go much time, but I really like this form, where you can switch on multiple blocking calls. I've definitely wanted this in other languages where I'm using thread safe queues for communication, and had to do manual multiplexing into a new queue whenever I wanted to do a blocking get on multiple queues. Does anyone know of a convenient way to do this when handling multiple instances of pytho…
Looks like you can use STM in Haskell: http://stackoverflow.com/questions/5879128/a-way-to-form-a-s...
EDIT: Actually, this isn't right. The example linked does "if get from channel 1 fails, get from channel 2". I'm looking for "select" on multiple channels, where the result is based on the first channel to return.
EDIT again: Apparently I can't read, and this does achieve what I'm looking for, I just have no basic experience with STM. Awesome, will try this later!
Re: Replacing Clever Code with Unremarkable Code in Go
#33Re: Replacing Clever Code with Unremarkable Code in Go
#34I think this is one of the really great things about Go. Some detractors ask "There is so much to be gained by having generics! What would be lost if Go had generics? Nothing! Ergo, Go is wrong to not have generics". This line of argument is flawed. Go curbs the ability of people to write crazy (and ultimately mentally expensive) abstractions. The lack of generics in Go is very a good thing. Especially when it comes…
If anything, generics reduce the mental expense of reading code, because if a container has a generic value type I know that it isn't going to be doing something interesting to those values behind the scenes.
In Java, generics make your code completely unreadable, as content is buried in boilerplate. Map,ReadyState ops; for (Entry,ReadyState e: ops.entrySet()) { ...
In Go, generics would be an unqualified win for the author/reader. No one disputes that. The only dispute is over the compiler and runtime costs.
Re: Replacing Clever Code with Unremarkable Code in Go
#35I think this is one of the really great things about Go. Some detractors ask "There is so much to be gained by having generics! What would be lost if Go had generics? Nothing! Ergo, Go is wrong to not have generics". This line of argument is flawed. Go curbs the ability of people to write crazy (and ultimately mentally expensive) abstractions. The lack of generics in Go is very a good thing. Especially when it comes…
I don't think you intended that as a preface to your flawed argument, but it worked out well. No, the lack of parametric polymorphism is not a good thing. You are losing simplicity, not gaining it.
Re: Replacing Clever Code with Unremarkable Code in Go
#36I think this is one of the really great things about Go. Some detractors ask "There is so much to be gained by having generics! What would be lost if Go had generics? Nothing! Ergo, Go is wrong to not have generics". This line of argument is flawed. Go curbs the ability of people to write crazy (and ultimately mentally expensive) abstractions. The lack of generics in Go is very a good thing. Especially when it comes…
If anything, generics reduce the mental expense of reading code, because if a container has a generic value type I know that it isn't going to be doing something interesting to those values behind the scenes.
Re: Replacing Clever Code with Unremarkable Code in Go
#37http://www.paulgraham.com/avg.html Programmers get very attached to their favorite languages, and I don't want to hurt anyone's feelings, so to explain this point I'm going to use a hypothetical language called Blub. Blub falls right in the middle of the abstractness continuum. It is not the most powerful language, but it is more powerful than Cobol or machine language. And in fact, our hypothetical Blub programmer w…
I'm not sure what your point is, whether you think go is simple and powerful like lisp, or the new java, but simply quoting "The Blub Paradox" makes you sound pretentious (on a site where the largest percentage of readers are probably already familiar with said essay nonetheless). I don't think this is really applicable to the article anyway, since it's an article commenting on two very different languages and progra…
Really? I find it hard to believe you can't tell what is intended. It certainly is applicable to the article, as the article can be summarized as "I've moved up a language on the blub line, and now my old perfect language is clearly inferior, but my new blub is perfection incarnate".
Re: Replacing Clever Code with Unremarkable Code in Go
#38Earlier quoted context omitted.
If anything, generics reduce the mental expense of reading code, because if a container has a generic value type I know that it isn't going to be doing something interesting to those values behind the scenes.
That's only true in a language with type inference and type aliases. In Java, generics make your code completely unreadable, as content is buried in boilerplate. Map ,ReadyState ops; for (Entry ,ReadyState e: ops.entrySet()) { ... In Go, generics would be an unqualified win for the author/reader. No one disputes that. The only dispute is over the compiler and runtime costs.
[1] and their cost is seriously compounded by the rest of C++, D has C++-style generics with a far lower compilation cost
Re: Replacing Clever Code with Unremarkable Code in Go
#39Earlier quoted context omitted.
Really? I thought the reason Go didn't have generics is because they couldn't decide on an implementation that met their goals? That is, was quick and didn't emit a ton of code.
I don't claim that was their goal. I think it's just a nice side-effect.
He expanded on this dilemma with examples from major languages: http://research.swtch.com/generic
Re: Replacing Clever Code with Unremarkable Code in Go
#40Earlier quoted context omitted.
If anything, generics reduce the mental expense of reading code, because if a container has a generic value type I know that it isn't going to be doing something interesting to those values behind the scenes.
That is not true in C++. std::vector is not really what you would have expected.