Conceptual questions on architecture of functional programs

Silas Silva <>
Thu Nov 4 02:23:25 CET 2010

Hi all!

After asking conceptual questions about distributed NoSQL databases, it
is time for a more newbie question, about functional programming.

There is some years I do fine OO and imperative programming.  I needed
to learn some functional programming.  So I decided to start a basic
commercial application (customer, orders, etc.) in Erlang to learn
something about it.  After some time, I realized my program had the
following structure:

- model.erl -> basic functional to access Mnesia database
- layer.erl -> an abstraction layer between model and front-end.
- frontend.erl -> show a front-end for the user, for now HTTP in
  Mochiweb.  Latter, a GUI.

So, from fron-end I use layer functions, that use model functions.

So I realized I wasn't actually doing any functional programming.  This
could be an architecture of a C program using high-level code.  I did
sequential programming split in dozens of mini-functions and I believed
that this was functional programming (a C-like program with high-level

In OO, I would easily return an object from layer, call its methods to
get what I wanted and make heavy use of encapsulation in objects.  I
could also pass objects in and out.

In the program I just wrote, I pass in and out records, that are not
that different from passing C structures in and out.

So, my question is:  where is my mistake?  What about a reference (book,
tutorial whatever) about functional programming architecture for OO
programmers (or imperative programmers)?  "Programming Erlang Software
for a Concurrent World", by Joe Armstrong is great, but it is more about
the language itself than functional programming techniques.  "Practical
Common Lisp", by Peter Seibel is more worth to read.

Other references are found in

Any tips about that?


P.S: The above program don't have any concurrent code yet.  I know it is
really important for Erlang, but would it be really that necessary to
get function programming feeling?

Silas Silva

More information about the erlang-questions mailing list