Live data from Hacker News

Replacing Clever Code with Unremarkable Code in Go

vividcortex.com

21–30 of 140 posts

Re: Replacing Clever Code with Unremarkable Code in Go

#21

http://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…

I would agree, and add that simply referencing the article, or quoting relevant portions, along with introducing some original narrative would've been much more productive (conducive to conversation).

Re: Replacing Clever Code with Unremarkable Code in Go

#22
post #18
post #2

I didn't put much code into the article, but ask me if you'd like more details on exactly what I'm talking about -- in terms of real code.

A little off-topic, but could you give some (Perl) code examples of this: > You feel initiated into an inner circle. You feel like you’ve discovered LISP in an alternate dimension (but you haven’t).

It's tough to give examples of this in Perl without a lot of narrative (and sometimes a lot of code), but the technique I'm referring to is currying: programs that write programs, via functions that write functions. This, of course, is what you do all the time in LISP. It takes half the (Higher-Order Perl) book to illustrate the technique and its power. Which is kind of the point: shouldn't it be a commonplace thing that doesn't take so much work to get around to explaining and using?

Re: Replacing Clever Code with Unremarkable Code in Go

#24
post #2

I didn't put much code into the article, but ask me if you'd like more details on exactly what I'm talking about -- in terms of real code.

Like this, I presume: go func(){ for { select { case

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 python's Queue or similar with Haskell's Chan?

Re: Replacing Clever Code with Unremarkable Code in Go

#25
post #18
post #2

I didn't put much code into the article, but ask me if you'd like more details on exactly what I'm talking about -- in terms of real code.

A little off-topic, but could you give some (Perl) code examples of this: > You feel initiated into an inner circle. You feel like you’ve discovered LISP in an alternate dimension (but you haven’t).

I'm not the author, and I don't know much Perl either, but I imagine something like this:

$_=@_%*!8%#9(

Re: Replacing Clever Code with Unremarkable Code in Go

#26
post #13

I 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…

Limiting power was the argument for making Java crippled too. On the topic of generics specifically, parametric polymorphism actually makes code simpler, see e.g. Haskell.

Whether by design or accident, Go is filling the use case of "you tried Python but performance wasn't good enough". People will bring up cases like "you can't write a generic map function, or tree data structures!", but Go isn't the language for those things. In Go, you would just use a for loop or a dictionary-based map. If your program gets to the point where that no longer cuts it, then it's time to move on to a different language.

Re: Replacing Clever Code with Unremarkable Code in Go

#27
post #13

Earlier quoted context omitted.

Limiting power was the argument for making Java crippled too. On the topic of generics specifically, parametric polymorphism actually makes code simpler, see e.g. Haskell.

Whether by design or accident, Go is filling the use case of "you tried Python but performance wasn't good enough". People will bring up cases like "you can't write a generic map function, or tree data structures!", but Go isn't the language for those things. In Go, you would just use a for loop or a dictionary-based map. If your program gets to the point where that no longer cuts it, then it's time to move on to a d…

…or a data structure that uses interface{} and you manually unpack. Or a hand specialized (rather than generic) data structure.

Bear in mind that with the new release of Go, maps are already hand specialized for primitives.

Re: Replacing Clever Code with Unremarkable Code in Go

#28

I 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

#29
post #18

Earlier quoted context omitted.

A little off-topic, but could you give some (Perl) code examples of this: > You feel initiated into an inner circle. You feel like you’ve discovered LISP in an alternate dimension (but you haven’t).

I'm not the author, and I don't know much Perl either, but I imagine something like this: $_=@_%*!8%#9(

You're awesome :-D Come work for us! https://vividcortex.com/jobs/

Re: Replacing Clever Code with Unremarkable Code in Go

#30

Earlier quoted context omitted.

Like this, I presume: go func(){ for { select { case

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...
Post reply on HN