3 ms·
I like FP's other "timeless" feature, you can think of the operations without respect to time, there isn't a sequence of operations, it's just a relation betwee
by karmakaze 6y ago
I like FP's other "timeless" feature, you can think of the operations without respect to time, there isn't a sequence of operations, it's just a relation between the input and output. It may be described sequentially in parts but there is no mixing of output with input so can be thought of happening instantaneously.
This is also the same reason why I like SQL, it describes properties of the result set--if your thinking of it as procedural steps it's more difficult. When it comes down to performance tuning however, you do have to consider what really happens in terms of index choices, loop nesting, etc. I never got into FP problems large/complex enough to hit this point where I have to understand how FP sausages are made.
- marcosdumay 6y agoHaskell is famous for having problems with space leaks, where the runtime just refuses to evaluate your code and keeps storing more of it to run later. It's not usually a problem because people will teach you how to avoid most of it on any introductory text (usually, it's not hard), but if no care is taken, it will happen. To go into another timeless paradigm, logical programming is famous for unexpected exponential execution times. It's rare that those get past tests, but it's something that developers are constantly having to fix (this or ensuring the type system detects determinism). SQL has a much milder version or this with underspecified joins. Getting ride of time makes a lot of things easier, but is not trouble-free.
- samcal 6y agoI really like that distinction, relating imperative/FP tradeoffs to the classic space/time tradeoff. I'd also point out that betting on space getting cheaper over time seems like a better bet than betting on time getting cheaper :)
- marcosdumay 6y agoThat's not the trade-off. The trade-off is about what you have to think about when programming, and what kinds of bugs appear. Non-buggy performance follows different rules.
- UncleMeat 6y agoIs time better? My experience with Haskell went like this. 1. Interested in Haskell. Learn the language, read papers, enjoy the PL concepts and interesting academic work. 2. Does it scale? Implement small program in in C++ and Haskell. Optimize as best I can. Talk to people who work on ghc who happen to be in my lab. Further optimize. Everybody agrees, no further clear way to optimize the Haskell program. C++ implementation remains several orders of magnitude faster. If it were a time and space trade off, laziness would lead to good performance. But it doesn’t. It tends to produce stupendously bad cache behavior. Haskell is a lovely platform for understanding some recent PL theory. It is possible to write the sort of obviously correct programs that make it so desirable. It isn’t resource efficient. Worse, laziness means that performance tends to be chaotic. Small seemingly unrelated changes can change the execution order and change your profile a lot. Similar challenges exist in logical programming.
- YeGoblynQueenne 6y ago>> To go into another timeless paradigm, logical programming is famous for unexpected exponential execution times. I have never heard of those famous "unexpected exponential times" in logic (not "logical") programming. Could you please give an example of what you mean? I'm also not sure what you mean by "this or ensuring the type system detects determinism". What logic programming languages with a type system do you mean? Why would a type system be required to detect determinism?
- carapace 6y agoYou might like Prolog.
- karmakaze 6y agoI've tried Prolog. It required thinking in both the specification correctness and it's 'search/match' execution based on how it's specified (with manual path cuts inserted as needed) much more so than these FP languages. Effectively writing a procedural definition non-procedurally. SQL can be like this too but is a small space/number of cases that it's not so unexpected.
- amw-zero 6y agoThis mapping of inputs to outputs is only superficial and hides that fact that computation is inherently “sequential” as you say. That’s why the even lambda calculus requires reductions. Of course I prefer writing in a functional style, because pure functions are just simpler. But all of computation can’t be reduced to just pure functions, which is why even Haskell has to call out to its runtime eventually.
- dragonwriter 6y ago> But all of computation can’t be reduced to just pure functions, which is why even Haskell has to call out to its runtime eventually. All of computation provably can, but not everything computers do, despite the name, is computation.
- amw-zero 6y agoComputation cannot be reduced to simply functions, that’s why we need something like the lambda calculus to express computation. There are functions within the calculus, but to say that “computation is a function” is not correct.
- pcstl 6y agoActually, computation, in the classic sense used by Turing, Church, and other pioneers, refers to evaluating the value of (mathematical) functions. The word computation first appears in the earliest papers of the field which would later become computer science referring to "computable functions", which refers to functions which can be evaluated by a mechanical process. Hence saying "not everything computers do is computation".