Hacker News new | past | comments | ask | show | jobs | submit login

> 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.




> 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.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: