Hacker News new | ask | show | jobs
by ninjaaron 2560 days ago
In a purely functional language, functions apply inputs to a single expression to produce an output (though there is usually a way to add some declarations inside the function to keep the expression from getting to hairy). Side effects are possible, but they are wrapped up as values that still have to be passed around as functions and possible errors must be handled.

"Purely functional" means that pure functions are not only possible, but that they are the only kinds of functions in the language.

While it might be theoretically possible to write purely functional code in Go, it doesn't have mechanisms for treating side effects as values, and the heavy reliance on arrays and channels and things would make it unnatural. Pure functions don't contain loops because a loop is only used to generate side effects. That would be hard in Go, but it's pleasant in languages that support pure FP.

If this explanation sounds weird, learn some Haskell to get an idea of what pure FP is like. It's fun stuff.