[erlang-questions] Design methodology going from Object oriented to functional programming?

Francis Norton francis.norton@REDACTED
Tue Oct 23 14:01:09 CEST 2007


I'm just an Erlang learner, but one thing that led me to Erlang is my
ancient and well thumbed copy of Shlaer and Mellor's "Object lifecycles:
Modeling the world in states" (
http://www.amazon.com/Object-Life-Cycles-Modeling-Computing/dp/0136299407)
which, for such a short book, made a great deal of sense to me and very much
changed the way I saw program design.

It might be relevant to you because it is aimed at developing real-time
systems where each "object" is implemented as a state-machine driven
process, and the messages each process accepts are its "methods".

Francis.

On 10/22/07, Alexander Lamb < alexander.lamb@REDACTED > wrote:
>
> Hello list,
> I am trying to understand what is the design process (intellectual, that
> is) when building a program in Erlang.
>
> Indeed, in the object oriented world, I would start by finding what my
> classes might be and the relationship between them. Gradually I would add
> functions (class or instance methods) to the classes in order to provide
> solid foundations on top of which I can write an application.
>

On 10/23/07, erlang-questions-request@REDACTED <
erlang-questions-request@REDACTED> wrote:
>
> Send erlang-questions mailing list submissions to
>         erlang-questions@REDACTED
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         http://www.erlang.org/mailman/listinfo/erlang-questions
> or, via email, send a message with subject or body 'help' to
>         erlang-questions-request@REDACTED
>
> You can reach the person managing the list at
>         erlang-questions-owner@REDACTED
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of erlang-questions digest..."
>
>
> Today's Topics:
>
>    1. HiPE compilation option (Serge Aleynikov)
>    2. Re: Fwd: Why single-assignment with non-shared    state?
>       (Richard A. O'Keefe)
>    3. Re: Design methodology going from Object  oriented to
>       functional programming? (Aaron Feng)
>    4. Re: Design methodology going from Object  oriented to
>       functional programming? (YC)
>    5. Re: Design methodology going from Object  oriented to
>       functional programming? (Jay Nelson)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Mon, 22 Oct 2007 20:39:24 -0500
> From: Serge Aleynikov <saleyn@REDACTED>
> Subject: [erlang-questions] HiPE compilation option
> To: "Erlang Users' List" <erlang-questions@REDACTED>
> Message-ID: <471D50CC.1030601@REDACTED>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> One of my colleagues asked me how to enable HiPE compilation.  After
> explaining the +native command-line flag I went back to documentation
> and haven't found any reference to it in erlc, c, compile.  I think it
> must be an oversight as HiPE is an important feature that deserves to be
> documented.
>
> Serge
>
>
> ------------------------------
>
> Message: 2
> Date: Tue, 23 Oct 2007 15:08:07 +1300
> From: "Richard A. O'Keefe" <ok@REDACTED>
> Subject: Re: [erlang-questions] Fwd: Why single-assignment with
>         non-shared      state?
> To: Erlang Questions <erlang-questions@REDACTED>
> Message-ID: <E787BEFE-6AB4-4727-9ADC-AB3A014C057E@REDACTED>
> Content-Type: text/plain; charset=US-ASCII; format=flowed
>
> On 22 Oct 2007, at 2:05 am, Tobias Gerdin wrote:
>
> > Well as long as the expressions you match on doesn't change during
> > matching I do not see the problem. There are several prominent
> > languages such as the ML-family, Scala, or even Lisps which feature
> > both pattern matching and assignment.
>
> I know nothing about Scala.
>
> However, I keep both SML and Mlton on my machines (hmm, I think I may
> have MoscowML somewhere as well).  SML DOES NOT ALLOW PATTERN MATCHING
> ON MUTABLE DATA.  SML's mutable data are "references" (boxes holding a
> single variable) and "arrays".  You cannot look inside either of these
> using pattern matching.
>
> The only "pattern matching" feature standardly available in Lisp is
> destructuring-bind (and its close relatives).  It matches mutable
> cons cells because Lisp doesn't have any other kind.  Reading any
> Scheme or Lisp tutorial, with its dire warnings against changing
> lists that happened to appear as literal data, may provide some idea
> of the trouble mutable data can get you into.
>
>
>
> ------------------------------
>
> Message: 3
> Date: Mon, 22 Oct 2007 22:29:51 -0400
> From: "Aaron Feng" <aaron.feng@REDACTED>
> Subject: Re: [erlang-questions] Design methodology going from Object
>         oriented to functional programming?
> To: "Jay Nelson" <jay@REDACTED>
> Cc: erlang-questions@REDACTED
> Message-ID:
>         <4e3934860710221929y5b0a775bm10a7df93f206003b@REDACTED>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hi Jay,
>
> I found the paper very insightful.  I understand the space constraint that
> some of the code sample has to be removed.  Is the complete code sample
> available for download?
>
> Aaron
>
> On 10/22/07, Jay Nelson <jay@REDACTED> wrote:
> >
> > I wrote a paper for the 2004 ICFP on designing structured systems
> > using processes.  You can find it on my website at http://
> > www.duomark.com/erlang/index.html
> >
> > jay
> >
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://www.erlang.org/mailman/listinfo/erlang-questions
> >
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> http://www.erlang.org/pipermail/erlang-questions/attachments/20071022/7b3bfb0a/attachment-0001.html
>
> ------------------------------
>
> Message: 4
> Date: Mon, 22 Oct 2007 19:41:26 -0700
> From: YC <yinso.chen@REDACTED>
> Subject: Re: [erlang-questions] Design methodology going from Object
>         oriented to functional programming?
> To: "Alexander Lamb" <alexander.lamb@REDACTED>
> Cc: erlang-questions@REDACTED
> Message-ID:
>         <779bf2730710221941y4865b02bo5c842e94ced49c96@REDACTED>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Actually, at the level you are describing, there should be no difference
> between FP and OOP.
>
> While OOP definitely emphasize data and relations, it is not the only
> paradigm that does so - and given your background you should be
> experienced
> with the relational paradigm, which has even heavier emphasis on data and
> relations, but is not OOP.
>
> To leverage your knowledge on relations - you can pretend sql queries are
> functions, i.e. select is a function, update is a function, and insert is
> a
> function.  Then instead of writing
>
> object.insert()
>
> you write
>
> insert (object) - which looks a lot like the sql query insert into table
> ...
>
>
> That's it.  In the Java style OOP the head of the statement is an object,
> and in FP the head of the statement is a function name.  But in either
> case
> you need to model the same world.
>
> An extremely crude way of thinking about FP is that it decouples the data
> from the function (or vice versa, that OOP couples functions and data).
> That means some facilities that you've taken for granted in OOP, such as
> inheritance, polymorphism, etc., will no longer be available.  But FP have
> a
> different approaches to address these problems, and that's where the
> rubber
> meet the road.
>
> Erlang's process model is basically the Actor model - the idea of
> everything
> is an actor feels similar to everything is an object in OOP.  So as others
> have alluded to instead of thinking in objects you can think in processes.
> But Actor model is independent of FP or OOP, so you would still have to
> get
> used to the FP part in Erlang.
>
> You might want to check out
> http://www.math.chalmers.se/~rjmh/Papers/whyfp.html
> <http://www.math.chalmers.se/%7Erjmh/Papers/whyfp.html>.  A higher level
> introduction is http://www.defmacro.org/ramblings/fp.html.
>
> Cheers,
> yc
>
> On 10/22/07, Alexander Lamb < alexander.lamb@REDACTED > wrote:
> >
> > Hello list,
> > I am trying to understand what is the design process (intellectual, that
> > is) when building a program in Erlang.
> >
> > Indeed, in the object oriented world, I would start by finding what my
> > classes might be and the relationship between them. Gradually I would
> add
> > functions (class or instance methods) to the classes in order to provide
> > solid foundations on top of which I can write an application.
> >
> > For example, I could have PERSON, PROFILE, ROLE, FEATURE, etc... and
> > decide a PROFILE is a collection of FEATURES. A PERSON can have 0 or
> many
> > ROLES. A ROLE is a PROFILE on a given area (a department for example)
> for a
> > given time. I would then add functions such as "give all the active
> roles
> > for the user" or "what features give that profile" or "does the user
> have a
> > given feature for that department".
> > I admit it is more complexe than that, but you get the idea.
> >
> > Obviously, this doesn't seem to be the way to go with Erlang.
> Intuitively,
> > I would start making a list of all the functions which will allow me to
> > interract with my application. In that case I could have "give me all
> users
> > with an active role on that department", etc... Then by implementing
> those
> > high level functions I would split them into pieces by calling smaller
> > simpler functions. The underlying data structure will "just follow" or
> > "appear" naturally.
> >
> > Hence: object oriented design is "data structure and relationships
> first,
> > functions second" and functional design is "functions first, data
> structure
> > second".
> >
> > Am I being over simplistic here. Are there some guidelines as to how one
> > can approach a problem when creating a new program? Especially programs
> > which deal with persistent data, not protocole analysers or socket
> servers!
> >
> > Thanks,
> >
> > Alex
> >   --
> > Alexander Lamb
> > Founding Associate
> > RODANOTECH S?rl
> >
> > 4 ch. de la Tour de Champel
> > 1206 Geneva
> > Switzerland
> >
> > Tel:  022 347 77 37
> > Fax: 022 347 77 38
> >
> > http://www.rodanotech.ch
> >
> >
> >
> >
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://www.erlang.org/mailman/listinfo/erlang-questions
> >
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> http://www.erlang.org/pipermail/erlang-questions/attachments/20071022/0fc13763/attachment-0001.html
>
> ------------------------------
>
> Message: 5
> Date: Mon, 22 Oct 2007 21:51:44 -0700
> From: Jay Nelson <jay@REDACTED>
> Subject: Re: [erlang-questions] Design methodology going from Object
>         oriented to functional programming?
> To: "Aaron Feng" <aaron.feng@REDACTED>
> Cc: erlang-questions@REDACTED
> Message-ID: <FC68D843-F1BE-4859-AE50-E966D81B4F82@REDACTED>
> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
>
> I haven't looked at for a couple years.  I don't have the code on the
> web.  I will have to look around and see if I can find it on another
> computer.
>
> jay
>
> On Oct 22, 2007, at 7:29 PM, Aaron Feng wrote:
>
> > Hi Jay,
> >
> > I found the paper very insightful.  I understand the space
> > constraint that some of the code sample has to be removed.  Is the
> > complete code sample available for download?
> >
> > Aaron
> >
>
>
>
> ------------------------------
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
> End of erlang-questions Digest, Vol 5, Issue 69
> ***********************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20071023/5a800e80/attachment.htm>


More information about the erlang-questions mailing list