News for hackers. Stuff that matters.
Re:Show HN: FunctionKit – Approachable functional concepts b... by wereHamster on Sunday April 22, 2018 @08:54AM (#16895956)
> In practice, it's very difficult (in most languages) to determine whether this optimisation is correct. > > [...] the optimisation happens to be correct because both mapping functions are pure. If they had side effects, [...]

TLDR: make all your functions pure. It'll make it so much simpler for you, your coworkers, but also the compiler(!) to reason about your code.

About half of the bugs and issues I come across in my $DAYJOB are because code that I use (through a third-party library) is not pure. If I had a penny every time I fixed a bug caused by impure code, I'd be rich.

Re:Show HN: FunctionKit – Approachable functional concepts b... by jsjohnst on Sunday April 22, 2018 @09:39AM (#16896116)
> If I had a penny every time I fixed a bug caused by impure code, I'd be rich.

Ok, let’s be extremely optimistic and say you fix 25 functional purity bugs a day and you’ve been fixing impure code for twenty years.

$0.01/bug * 25 bugs/day * 250 working days/year * 20 years = $1,250.

I guess that $1,250 could be rich to some, but I do think making a quarter per full day of fixing bugs doesn’t seem like a great way to get there.