News for hackers. Stuff that matters.
Re:Even pure functions have side-effects by lallysingh on Tuesday September 06, 2011 @05:45PM (#2967411)
TL:DR; Pure functions still use memory and CPU.

Very insightful. I forgot code ran.

Re:Even pure functions have side-effects by jerf on Tuesday September 06, 2011 @08:38PM (#2967858)
Mock him if you like, but he puts his finger on a real problem. When I encounter a library or language that makes a big deal about being "declarative", I now consider that a black mark against it, not a feature, because what that translates to is usually "You still have to tell it how to get the thing you want, but since we thought we could abstract away all such performance issues, we've made it impossible to introspect or fix any performance issues you may encounter, and the language will require bizarre contortions to get acceptable performance."

Example the first and one of the biggest: SQL. Sure, it's a declarative language... after you learn how databases work, after you learn how indexes work, after you profile your biggest hitting queries and work out how to rewrite them into semantically equivalent queries that perform orders of magnitude faster, after you learn how to deal with sharding, after you learn when to denormalize and when not to, after you learn the necessary performance hacks that trick the indexer into doing what you need instead of what it thinks is correct, and after a few more things I could go on about, it's a declarative language where you don't have to worry about performance any more. Yup, totally declarative.

I like Haskell, but only because I can mostly (although not entirely) see through it.

"The major difference between a thing that might go wrong and a thing that cannot possibly go wrong is that when a thing that cannot possibly go wrong goes wrong, it usually turns out to be impossible to get at and repair." - Douglas Adams

Anything that claims to be declarative is lying. All declarations in some given environment entail some process that will be used to obtain your results, you will not be able to get good performance if you don't know that process, and actively obscuring those processes only makes it harder.

You can't afford to ignore the side effects of "pure" functions.

Re:Even pure functions have side-effects by polymatter on Wednesday September 07, 2011 @12:54AM (#2968414)
In the same vane, is the classic article [Evolution of a Haskell programmer](http://www.willamette.edu/~fruehr/haskell/evolution.html). Its just the factorial function written in different styles in Haskell, each with very different performance implications.
Re:Even pure functions have side-effects by rufibarbatus on Tuesday September 06, 2011 @07:38PM (#2967720)
And indeed, FP hackers do mind their pure functions' performance:

- http://haskell.org/haskellwiki/The_Fibonacci_sequence

- http://vimeo.com/20655874 ("Faster persistent data structures through hashing")