A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.
I have spent a few days trying to understand why it would be beneficial to write a common web application - say a web forum - in a functional style. I don't get it.
While I was working on the read aspects of the architecture, functional programming seemed to make sense, but I encountered a big problem: database updates!
I don't understand how database updates will fit into the functional paradigm. If I have to break the paradigm to implement updates, then why bother with functional programming?
I'd like someone with functional programming experience to demonstrate to me how the functional programming paradigm can help the developer a web forum application. Thanks.
Could it be that the true benefit of functional programming is not about avoiding side-effects but mostly about exploiting continuations to write code faster?
Tuesday, June 05, 2007
A ha! Your Functional Programming has encountered its mortal foe: Real-Life Environment! Showdown!
Seriously, though, this is what happens when you try to stay within one, strictly one, approach - which is not exactly based on the fundamentals of the platform it runs on. Neat mathematics, elegant solutions for certain mathematical problems - usually a horrid mess once you try to apply it in practice, especially when you need to interface it with incompatible "math".
Maybe you could find a method to represent database transactions in a functional way. E.g. pretend a transaction is a function which converts a query into a data set? Or a generator which yields elements of that set, if your language supports generators?
Tuesday, June 05, 2007
I've just "landed" into the Functional Programming word, mostly to fill what I believe is a big hole in my computer science education :-D
My understanding is that FP is actually used in REAL WORLD scenarios with real programming languages like Erlang, Heskell, R and Ruby. For instance, take a look at this list of who uses Erlang: (http://www.erlang.org/faq/t1.html#AEN50)
Regarding the persistence problem, it has been already solved even by means of work arounds (treating input as a list of values, for instance) or extending the concepts of FP with the rather esotheric concept of Monads, which are used by Erlang and Ruby. Being honest, I'm just getting into the depthness of this concept so I can't still tell you how it work.
Just is case you haven't already visited it, the wikipedia has an interesting article about Monads and how they are used to address the IO problem:
This article also has some links to very nice and gentle introductions to the concept.
Hope this helps-
Purely functional programming languages use Monads to enable side effects.
You have to wrap up your database operations in a IO-derived monad.
But I am sure it's already implemented by someone, so you'd better search the web for an implementation.
Thursday, June 07, 2007
This topic is archived. No further replies will be accepted.Other recent topics
Powered by FogBugz