Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Go has first-class functions, so you could write a library do the same thing with, yes, a few more declarations around it. In your example, .map { |i| i + 9 } is .map( func(i int) int { return i + 9 }), or .map(myFuncDefinedElsewhere) in most real-world scenarios.

As a commenter upthread pointed out, Go and serverside Javascript are aimed at very different use cases and audiences.



I thought this would be a fun exercise, so I implemented the Go equivalent. Can anyone get it to fewer lines? It abandoned all pretenses of readability long ago.

http://play.golang.org/p/M5VaeIgQ-q


Updated to generalise a bit more. If this ever came up in code review, I'd probably facepalm pretty hard.

http://play.golang.org/p/YUQSZgFx_b


Ha. Yeah, the map() and reject() function defs are fine but the actual usage is a little eye-bleed inducing :)


So now that we've established Ruby is better at being Ruby than Go is, I wonder if there's an actual use case for this kind of thing, so I can demonstrate the "Go way" of handling it...


Wrong and you know it. Go does not have generics so you have to use void* (interface{}) and casting. It ends up being about an order of magnitude uglier and more verbose. Which is why map, fold, etc don't exist in Go.

You go fanatics are incorrigible.


Seriously? Is this just a coincidence that another throwaway named "TakeTwo" and then "TresAmiga" are both making throw aways and dismissing all Go users? Jesus.

What he's describing is far more than possible using interfaces. I have plenty of code that does so.

How is that "wrong and he knows it". Your worse than any Go fan here. Where the hell does someone get off being vitriolic about a language or someone's preference for that language. Pathetic, at least have the balls to post under your real account.

That having been said, as an "incorrigible Go fan", I would love to see proper generics. It's something I'm enjoying in Rust. It's also something that everyone is open to adding in Go 2, so it doesn't necessarily have to be a permanent absence from Go.


There's some idiots who troll the #golang-nuts freenode channel occasionally with a bunch of spam saying 'node is way better!'.

I assume they're not gainfully employed, or else they would understand that the two languages/platforms have very different goals and principles.


`chord`? Yeah, I was in there and was one of the people feeding him/her, I'm ashamed to say. I'd had a few beers and wasn't on my best behavior.

Chord was on about "Rails" is better, couldn't fathom a web world without MVC and failed to understand that Rails was just a framework on Ruby and that one could write similar helpers in Go.

It was the perfect example of Dunning-Kruger. Painful to witness.


I think there is honestly something wrong with that guy in a mild "losethos" sort of way. He started spamming me trollish nonsense in PMs because I dared utter a single line while he was active.

Something about golang just seems to attract a certain flavor of nutters.


He stalked me too. Mocked my parents, my sexuality (lolironic), my job, etc. Classy fella.


I'm starting to feel so left out. Why do crazy Go-haters never harass me? Am I not good enough?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: