5 ms·
Have ever tried programming in Go? Edit: Functional Programming in Go 1. http://stackoverflow.com/questions/4358031/functional-programming-in-go http://stackov
by realrocker 13y ago
Have ever tried programming in Go?
Edit: Functional Programming in Go
1. http://stackoverflow.com/questions/4358031/functional-programming-in-go http://stackoverflow.com/questions/4358031/functional-progra...
2. http://golang.org/doc/codewalk/functions/ http://golang.org/doc/codewalk/functions/
- rybosome 13y agoI'm currently in a study group at work for Go, and I'm writing a few one-off personal tools with it. This is hardly serious experience, but it's enough to get a flavor for the language. As the other answer to your question states, adopting a functional style in Go is technically possible, but practically it is so inconvenient as to be unusable. EDIT: Take a look at this article, which explores developing a library that adds runtime-checked type parametric functions. http://blog.burntsushi.net/type-parametric-functions-golang http://blog.burntsushi.net/type-parametric-functions-golang Choice quote: "There’s no such thing as a free lunch. The price one must pay to write type parametric functions in Go is rather large: Type parametric functions are SLOW. Absolutely zero compile time type safety. Writing type parametric functions is annoying. Unidiomatic Go."
- gnuvince 13y agoGo doesn't lend itself to functional programming, in part because of its lack of type parametrization. In a language like Scala or Haskell, using functions like map, fold, and filter is clean an idiomatic. In Go, it is so ugly and convoluted that you immediately reject this approach and use for loops instead.
- mseepgood 13y agoStanding firmly in one paradigm is a good thing for a language IMHO. I've worked in multi-paradigm languages and they suffer from the fact that their communities can't find a common style. "Should I use a fold or a loop or a tail recursion?", or some library designers want to be as typeful as possible, others don't, etc.
- eru 13y ago> "Should I use a fold or a loop or a tail recursion?" Neither, use a combinator, like map or traverse. (And that applies to all languages that support this style.)