[net.lang] Functional vs. Object-Oriented

kadie@uiucdcsb.CS.UIUC.EDU (06/28/86)

Two of the new waves in programming seem to be in total opposition.
Functional programming languages, like FP, have us program with
virtually no side-effects. Object-oriented languages like Smalltalk
have us program with only side-effects.

In the spirit of generating discussion, let me ask
what reasons we have to belief that either paradigm
is useful?

Also, since they contradict either other, they can't both
be right, right?

Carl Kadie
University of Illinois

robison@uiucdcsb.CS.UIUC.EDU (06/28/86)

The two paradigms do not necessarily contradict each other.  
There is a paper in the reference listed below that shows
how a functional language can incorporate objected-oriented
language features.  One way of looking at it is that when an
object receives a message, a new object must be generated, i.e.
call-by-value semantics are required.  By doing such, the polymorphism 
and data encapsulation of Smalltalk can be added to a functional
language.

Also, if one allows lazy evaluation in a functional language,
then infinite lists behave like message streams.  Thus the
two approaches converge in another way.

I think the two paradigms represent different frames of reference.
In the Smalltalk model, you stand on the objects and watch the
operations go past.  In FP, you stand on the functions and watch the
objects go past.  It is sort of a programming relativity.

Here's the reference.  I can't remember which paper described the
object-oriented FP, but it shouldn't be too hard to find.

Reference:

     J. Darlington, J.V. Guttag, P. Henderson, J.H. Morris, J.E.Stoy, 
     G.J. Sussman, P.C. Treleaven, D.A. Turner, J.H. Williams, D.S. Wise
     *Functional Programming and its Applications*,
     Edited by J.Darlington, P. Henerson, and D.A. Turner. 
     Cambridge University Press
     1982

Arch D. Robison
University of Illinois at Urbana-Champaign

P.S. Both paradigms also share another common property: they are both
     difficult to implement efficiently!

cjh@petsd.UUCP (Chris Henrich) (06/30/86)

[]
In article <8900035@uiucdcsb> kadie@uiucdcsb.CS.UIUC.EDU writes:
>
>Two of the new waves in programming seem to be in total opposition.
>Functional programming languages, like FP, have us program with
>virtually no side-effects. Object-oriented languages like Smalltalk
>have us program with only side-effects.
>
>In the spirit of generating discussion, let me ask
>what reasons we have to belief that either paradigm
>is useful?

Both paradigms are found, in practice, to be useful.  Try them
yourself; you will probably have a success story or two to
add.
>
>Also, since they contradict either other, they can't both
>be right, right?
>
My first thought is that I've heard other such clashes of symbols 
before.  The one that comes first to mind is the dispute between wave 
theories and corpuscular theories of light. (Any further discussion of 
this should be transferred *totally* and *immediately* to net.physics 
and possibly net.philosophy!)  

My second thought is that the contradiction is imprecise.  The
reasonable way to state one of these paradigms is "Here's a way to
make good programs:... ."  Note that I do not say it is the *only*
way.  The second paradigm comes along: "Here's another."  No
contradiction.

Regards,
Chris

--
Full-Name:  Christopher J. Henrich
UUCP:       ...!hjuxa!petsd!cjh
US Mail:    MS 313; Concurrent Computer Corporation;
            106 Apple St; Tinton Falls, NJ 07724
Phone:      (201) 758-7288
Concurrent Computer Corporation is a Perkin-Elmer company.

liberte@uiucdcsb.CS.UIUC.EDU (07/01/86)

The concept of polar relationships between opposites has always
fascinated me.  The "functional vs. object-oriented" polarity is
one of several to be found in computer science as well as
many other fields of study.

>>Also, since they contradict either other, they can't both
>>be right, right?
>>
>My first thought is that I've heard other such clashes of symbols 
>before.  The one that comes first to mind is the dispute between wave 
>theories and corpuscular theories of light. (Any further discussion of 
>...

Without delving into too much philosophy, it is educational to list
other such polarites in computer science.  Here is a sample:

viewing data as programs vs. viewing programs as data
lexical vs. dynamic scoping
top-down vs. bottom-up design
top-down vs. bottom-up taxonomy of sorting algorithms
symbolic vs. numeric computation
counting vs. estimating
menu vs. command interfaces

to touch on a few diverse areas.  I will gladly collect any others
people wish to mail me and post a summary.  There must be hundreds
within computer science alone.


Daniel LaLiberte   217-333-8740
University of Illinois, Urbana-Champaign
Department of Computer Science
1304 W Springfield
Urbana, IL  61801

liberte@b.cs.uiuc.edu
liberte@uiuc.csnet
ihnp4!uiucdcs!liberte

kurt@fluke.UUCP (Kurt Guntheroth) (07/03/86)

Object oriented programming and functional programming are not really
competetive points of view.  Object oriented programming is the most current
extension to the way we program now, an advancement on the same old
imperative programming style.  Of note, with object oriented languages, 
side effects are encapsulated in objects with protected scopes.  Object
oriented languages reduce the problems associated with global variables and
global scope, but are otherwise conventional.

Functional languages represent a new way of looking at problems.  Functional
languages have a much more abstract model of computation and computers.
They make you think about computation in a different way.  I cannot comment
on whether or not it is a better way...