Hacker News new | ask | show | jobs
by ilimilku 2617 days ago
This rather scattered and jargon-laden article seems to be pointing out the differences between the lambda calculus (stateless) and the Turing machine (stateful), which, while computationally equivalent, are not formally equivalent (pardon me if I get the verbiage wrong as I am not a mathematician). While the hardware architecture is essentially a Turing machine and thus stateful, the lambda calculus cannot be mapped onto it without somehow extracting state. In my (rather simple) mind, this shouldn't be a problem if functional programs are not used to do things that they were never intended to do in the first place. If you are trying to use Haskell to do stateful jobs like UI or DB management, you are probably using the wrong tool. Use Java or some other OOP language. Use your FP languages for middleware services that take an input and give an output that can be consumed by whatever is consuming the service. And guess what, the enterprise is already build that way.
2 comments

It's more complicated than "FP or not". Languages like Haskell isolate state and IO. But the mechanisms are there, and Haskell was intended to do it; it's just formalized and very strict. There are FP languages that don't have this pure separation (I believe OCaml and Scala mix IO freely), and that's more at the core of where the friction might be of interacting with a database rather than FP itself. I would often not use Haskell for database-related stuff, I agree, but it's more because I often do no require the level of strictness that the type system enforces in all my database interactions such that it would be worth the investment. But if you're doing mission-critical stuff, it may be worth getting the safety guarantees.
The other thing this article seems to miss is the level of abstraction at which FP applications need to live. At the OS level, where state is being managed, using FP would be insane. I don't think anyone really would want to do that. The UNIX philosophy of piping along a stream, while it may have something in common with FP, it still exists at a higher level of abstraction than the kernel, which is still a giant, complex Turing machine.
The top-level FP CLI is unsafe for exactly that reason http://okmij.org/ftp/Computation/monadic-shell.html