Discussion

Ask HN: Should you always prefer pure functions?

In general, I prefer following functional programming principles. This leads me to default to writing pure functions and only writing impure functions when it's absolutely necessary (meaning that the program would not work unless the functions were impure).

On the other hand, I try to avoid dogma and assess situations on a case by case basis.

Are there cases when you would prefer _not_ to write pure functions even when you could, or should you always prefer pure functions? In either case, why?

5 points crcl 8 years ago 6 comments

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton