What language do you think is a good combination between OOP and FP 
Author Message
 What language do you think is a good combination between OOP and FP

I'm relatively new to FP and used to program in an OO-fashion.  My
personal preferred PL is Eiffel, I now try to find out where OOP and
FP good be best combined. The following candidated don't look bad:

- OCAML
- CECIL

Do you have know any other language like this?

Do you think it's a good idea to combine FP and OOP Elements in one
language?

Or do you think that a language should purely be functional and/or
oo-oriented?

Here's what I like about Eiffel (the idea of Design by Contract), so I
expect that functional elements in assertions could help a lot.

The full power of FP-language seemed to be the direct support for
abstract datatypes. So I like the way for example how Stacks are
implemented in FP-languages.

Any comments or hints ?

Best regards
Friedrich



Tue, 26 Dec 2000 03:00:00 GMT  
 What language do you think is a good combination between OOP and FP

Quote:

> I'm relatively new to FP and used to program in an OO-fashion.  My
> personal preferred PL is Eiffel, I now try to find out where OOP and
> FP good be best combined. The following candidated don't look bad:

> - OCAML
> - CECIL

> Do you have know any other language like this?

Dylan
Common Lisp

Quote:
> Or do you think that a language should purely be functional and/or
> oo-oriented?

> Here's what I like about Eiffel (the idea of Design by Contract), so I
> expect that functional elements in assertions could help a lot.

Common Lisp has a better exception system. Assertions can
easily be added via method combination.


Tue, 26 Dec 2000 03:00:00 GMT  
 What language do you think is a good combination between OOP and FP
On Fri, 10 Jul 1998 10:54:02 +0200, Friedrich Dominicus

Quote:

>Do you think it's a good idea to combine FP and OOP Elements in one
>language?

I'm an Ocaml user, and while I love the language, I don't use the
OOP features much.  It's not that I'm completely adverse: in Python,
for instance, I use OOP all the time, and I've been writing OOP-
style C++ for many years.  (But I hate it, and that's a different
story for another time.)

Quote:
>Or do you think that a language should purely be functional and/or
>oo-oriented?

I think, door # 2: OOP or functional.  With ML (or Ocaml not using
the OOP features) there is so much elegant support for programming-
in-the-large, with the extraordinary module system, functors, and
the like, that you really don't need OOP as an alternative problem-
segmentation methodology.  ADT's give you almost everything that
OOP gives you - OOP adds the ability to indirect off a reference
to any subclass of the reference's base class, and get the appropriate
function for the derived class, which you can't get with just
references to ADT's - although you can get the same effect if the
ADT instantiation is not through a reference.  And that is not
such a big deal, at least to me, in my applications (large,
commercial programs like compilers, as well as embedded systems).

It's a different way of thinking.  Python (or Modula-3, or
Eiffel, or Smalltalk, or Objective-C) has a world view that revolves
around classes and inheritance and method overrides and so forth.
It's a way of dividing up a problem to manage the complexity.
It's not terribly bad, but it sure isn't as good as its evangelists
claim.  (It IS terribly bad as implemented in C++, but there I
go again.)  At root OOP is not a different or more powerful way
of programming; you can do the same thing with function pointers
and nested structures.  It's just a way of bundling things with
some syntactic molasses that makes it a little easier, supposedly,
to reuse common parts and extend existing mechanisms.  Supposedly.

FP, on the other hand, is a different and more powerful way of
programming.  It puts the full power of functions at your disposal,
and it makes some things easy that you think would be very hard
(like returning functions from functions, and storing functions
in variables, and partially evaluating functions and then
executing them later in their original environment, and so on
and on) while making some other things hard that you think would
be easy (like assigning a value to a member of a list).  So you
are forced to think differently, with different pathways, rather
than just obliquely, as you do when learning OOP.  And with
the incredible module systems and libraries of Ocaml and SML,
you can build ADT's that are more than ADT's - that are sort
of polymorphic ADT's combined with templates.  You get reuse
and power and problem subdivision already with ML, so you
don't need OOP.  It's not that OOP is a bad thing; it's that
you don't seem to need it in ML, because ML's existing
problem-subdivision mechanisms are more than up to the task.

I've been following the CAML list regarding OOP, and as far
as I can tell, most of the people who are making heavy use
of Ocaml's OOP features are those who are coming to Ocaml
with a heavy predisposition toward the OOP style of programming.
OOP provides something familiar to them, something they can
feel comfortable with.  This is a good thing ... it took me
many months to learn the language because there was so little
in it that was familiar to me.

A well-written ML/Ocaml program is a thing of beauty.  FP
lets you write poetry rather than prose.  In my humble
opinion, OOP doesn't help FP, it clutters it.  Ocaml is
nice because you are free to use the OOP features or not
as you choose.  But if I were designing a new FP language,
I would skip the OOP features and concentrate on making
the FP core fast and clean and portable and elegant.

It's not that easy to design an FP language these days.
Scheme and ML are rather elegant and well-thought-out,
and you'd have to do a whole lot better than them to
gain any audience.  Haskell was designed explicitly to
unite the wandering nomadic tribes of the lazy-evaluation
steppes.  Ocaml is very successful because it has one of
the finest implementations of any programming languages,
ever.  I suppose you could do a stunningly fast Haskell
... There does seem to be room for improving the usual
imperative languages by adding FP features, though.

The difficulty and the wonder of FP both spring from the
same source, I think.  Scheme, ML, Ocaml and Haskell are the
products of some of the best thinkers in the field.
They are our top-drawer talents, our blue-chippers.
Elegance and clarity and beauty and power really matter
to these guys, and they are open to peer review and
external criticism.  They publish their specs as well
as their implementations freely.  So it's no surprise
that Milner got the award for ML, or that Scheme has
taken over much of the academic community, or that
these languages are rigorously defined and meticulously
implemented.

But ... then again, it's no surprise that these languages
are hard to learn, either.  Instead of sitting down and
learning to print "hello, world" on the display, you are
handed a treatise on the lambda calculus and are expected
to understand combinators in a few hours.  Instead of
filling out a dialog box (as in Visual Basic) that specifies
the colors and fonts of your application's main window,
you are introduced to currying and first-order functions
and tail recursion elimination.  Jeez, where did all the
audience go?  Out the exits, that's where, out to something
familiar and understandable without a math degree.

You want to help the FP community?  Build us a language
that we can teach to the Visual Basic crowd.  Build us
a language like Pizza, the Java veneer with the essential
FP features, but fast and usable.  Find a way for us to
take these amazingly beautiful concepts that Milner, Steele,
et al, have brought down from the gods to us, and distribute
them to the masses.

No, with apologies to Xavier Leroy, for whom I have the
highest respect -- we don't really need OOP features in FP.

What we need is a way to give to the rest of the world what
we have already found for ourselves.  FP, not OOP, is the
real revolution, the real break-through, the real hope for
the programmers of the next generation.

Dwight "ML until I die" VandenBerghe



Tue, 26 Dec 2000 03:00:00 GMT  
 What language do you think is a good combination between OOP and FP
: Pure OOP gives you Smalltalk (among others), which is a very nice
: language.  Pure FP gives you Haskell, which is also very nice.  The
: problem with Haskell is that it's difficult to do simple imperative
: things, like printing out the value of a variable at the beginning of a
: function (without using monads, which I still don't understand too
: well).  Although impure, a small amount of imperative-ness is handy.  

I think a distinction needs to be made here. If you are just printing
out the value of a variable for debugging purposes then that should be
easy and should not involve monads (cf: 'trace' in Gofer). Often such
debug printing is not easy but that's the fault of the implementation
(more money needs to be directed to programming environments -- I know
researchers don't get funded for that ...). If you are printing out
the value of a variable for purposes other than debugging then that
should involve monads or uniqueness types or whatever the I/O mechanism
is.

graham
--

        He'll be riding that fast train to Memphis
                    On that sweet R & B
            Till the green grass way down home
                     Grows up over me



Tue, 26 Dec 2000 03:00:00 GMT  
 What language do you think is a good combination between OOP and FP
I've read a number of the responses to this, and found them all interesting
and some eloquent, as well.  I'm a newcommer to FP, and, as it happens,
I spent a while today trying to download "fp+oop=Haskell" by Emery Berger.
Without success.  

Is the Emery Berger article completely off base, or ...?

If anyone can point me to a place I can download the Berger article, I'd
appreciate it.  I tried Emery's site, and the link to the ..ps.gz version
seemed to go nowhere.  I found an HTML version somewhere, but I'd really
like something I can put on old fashioned paper.  I tried the
.dvi.Z, ..ps.Z at haskell.org/papers.  The files downloaded, but
my gunzip says they are corrupted (yes, I retried the download).  Other sites
I found had apparently broken links to the paper.

Best regards,
--
   John Velman



Tue, 26 Dec 2000 03:00:00 GMT  
 What language do you think is a good combination between OOP and FP
: I've read a number of the responses to this, and found them all
: interesting and some eloquent, as well.  I'm a newcommer to FP, and,
: as it happens, I spent a while today trying to download
: "fp+oop=Haskell" by Emery Berger.  Without success.

: Is the Emery Berger article completely off base, or ...?

I have not read it. However, Simon Peyton-Jones has some information
on his "work in progress" pages about existential types that are going
to be in GHC (and Haskell 2, eventually, I guess).

Existential types enable the kind of polymorphism usually associated
with the phrase "object-oriented programming". For example a list can
contain all kinds of objects as long as they have some set of
functions defined (i.e. the "methods" of the objects).

This is useful for implementing things like graphics editors where a
"canvas" has all kinds of various objects in its list of shapes. The
shapes can be any kind of type as longs as they support some set of
"methods" like "draw" (for display on the canvas) or "drop" (for
drag-and-drop user interfaces).

--


                 http://www.gemstone.com



Tue, 26 Dec 2000 03:00:00 GMT  
 What language do you think is a good combination between OOP and FP

Quote:

> I have not read it. However, Simon Peyton-Jones has some information
> on his "work in progress" pages about existential types that are going
> to be in GHC (and Haskell 2, eventually, I guess).

If you want to try existential right now you can use HBC.
They have been in HBC for about four years now.  There are universal
types too, but you have express them differently than the current GHC
syntax.

--

        -- Lennart Augustsson
[This non-signature is unintentionally not left unblank.]



Tue, 26 Dec 2000 03:00:00 GMT  
 What language do you think is a good combination between OOP and FP

Quote:

>    Re: What language do you think is a good combination between OOP and FP
>   References:



>> I'm relatively new to FP and used to program in an OO-fashion.  My
>> personal preferred PL is Eiffel, I now try to find out where OOP and
>> FP good be best combined. The following candidated don't look bad:

>> - OCAML
>> - CECIL

>> Do you have know any other language like this?

>Dylan
>Common Lisp

How does Scheme with TinyClos, STklos, BOS or Yasos compare, FP-OOP-compromise
-wise?

     Klaus Schilling    



Tue, 26 Dec 2000 03:00:00 GMT  
 What language do you think is a good combination between OOP and FP

Quote:

> It's a different way of thinking.  Python (or Modula-3, or
> Eiffel, or SmallTalk, or Objective-C) has a world view that revolves
> around classes and inheritance and method overrides and so forth.
> It's a way of dividing up a problem to manage the complexity.
> It's not terribly bad, but it sure isn't as good as its evangelists
> claim.  (It IS terribly bad as implemented in C++, but there I
> go again.)  At root OOP is not a different or more powerful way
> of programming;

I don't agree. OOP (in its many incarnations with different
views on the topic) is an important paradigm.

Quote:
> FP, on the other hand, is a different and more powerful way of
> programming.

"more powerful"? For what?

Quote:
> opinion, OOP doesn't help FP, it clutters it.

There are a lot of different ideas/dimensions what "object-oriented" is
about.

Prototype-oriented view: Objects can delegate.
Logics: Use logic to describe the relations, concepts and individuals.
Message Passing: Communicating objects.
Generic Functions: Choose implementation based on argument classes.
...

Quote:
> It's not that easy to design an FP language these days.
> Scheme and ML are rather elegant and well-thought-out,

Common Lisp is another language with a very clean idea
about OOP. Classes with multiple inheritance
will give you the data structures. Generic Functions
capture the functionality. A machinery with
very dynamic features (method combination) determines
the runtime behaviour. The language is extensible
in terms of itself, so that you have an object-oriented
reflective language that has an Meta Object Protocol.
So Common Lisp combines OOP-features (Classes, Inheritance, ...)
with FP (Generic Functions). Lisp programmers have
been long using object-oriented ways of thinking
in their software. Actually the operating system
of the Lisp machines is implemented using the techniques.

Dylan is an attempt to simplify these ideas, add things
like type inference and sell it to the average programmer.
Harlequin has recently released a free version for Windows.
See at http://www.harlequin.com/ .



Wed, 27 Dec 2000 03:00:00 GMT  
 What language do you think is a good combination between OOP and FP

Quote:

> >    Re: What language do you think is a good combination between OOP and FP
> >   References:



> >> I'm relatively new to FP and used to program in an OO-fashion.  My
> >> personal preferred PL is Eiffel, I now try to find out where OOP and
> >> FP good be best combined. The following candidated don't look bad:

> >> - OCAML
> >> - CECIL

> >> Do you have know any other language like this?

> >Dylan
> >Common Lisp

> How does Scheme with TinyClos, STklos, BOS or Yasos compare, FP-OOP-compromise
> -wise?

They all try to bring various ideas of Common Lisp (CLOS) into
Scheme.

Dylan also is like a Scheme with CLOS (minus Meta Object Protocol,
minus method combinations, minus ...).



Wed, 27 Dec 2000 03:00:00 GMT  
 What language do you think is a good combination between OOP and FP
Forgive the newbie question, but...

What are GHC and HBC, and where might I find more information on them?

Thanks,
Bob Manjoney
McHugh Software International

Quote:


>> I have not read it. However, Simon Peyton-Jones has some information
>> on his "work in progress" pages about existential types that are going
>> to be in GHC (and Haskell 2, eventually, I guess).
>If you want to try existential right now you can use HBC.
>They have been in HBC for about four years now.  There are universal
>types too, but you have express them differently than the current GHC
>syntax.

>--

> -- Lennart Augustsson
>[This non-signature is unintentionally not left unblank.]



Wed, 27 Dec 2000 03:00:00 GMT  
 What language do you think is a good combination between OOP and FP

: What are GHC and HBC, and where might I find more information on them?

They're Haskell compilers, http://www.haskell.org

--


                 http://www.gemstone.com



Wed, 27 Dec 2000 03:00:00 GMT  
 What language do you think is a good combination between OOP and FP

Quote:

>Existential types enable the kind of polymorphism usually associated
>with the phrase "object-oriented programming". For example a list can
>contain all kinds of objects as long as they have some set of
>functions defined (i.e. the "methods" of the objects).

Yep.  Existential types are The Way To Go [TM].

But in OOP, objects generally have three important properties:

        identity
        state (normally mutable)
        methods

Existential types help with the methods, but they don't help
with object identity or mutable state.

Now there's ways to handle those in Haskell too, but I suspect that if
you're really doing lots of object oriented programming then a language
with more direct support for OOP may be more elegant.

--

WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"



Wed, 27 Dec 2000 03:00:00 GMT  
 What language do you think is a good combination between OOP and FP

Quote:

> I'm an Ocaml user, and while I love the language, I don't use the
> OOP features much.  It's not that I'm completely adverse: in Python,
> for instance, I use OOP all the time, and I've been writing OOP-
> style C++ for many years.  (But I hate it, and that's a different
> story for another time.)

[...cut a lot of interesting remarks...]

Quote:
> No, with apologies to Xavier Leroy, for whom I have the
> highest respect -- we don't really need OOP features in FP.

As another Ocaml user, I must say that I mostly agree with you:
in most cases, FP is more than enough to solve the problem, and there
is no real need for OOP. Unneeded use of OOP may clutter your program.

I believe OOP is an interesting paradigm, but when it comes to make
concise and error-free programs, and even efficient ones, FP is a
better choice.

Still, I wouldn't say as you that we don't need OOP features in FP. I
happen to be using them quite often. Strangely, not for what OOP
supporters would sell them: it is too difficult to make a really safe
library using OOP. While a functional library can be almost completely
characterized by its interface, with OOP protocols need to be
explained informally. I believe there is work in the OOP community to
formalize that, but for now FP wins. The reusability claims of OOP
come very short when you compare them with the FP possibility of
reusing any bit of code.

However, I see at least two reasons to use OOP in a functional context:

* Objects are a useful concept, particularly for prototyping. They may
  help you structure your program. While I would not use them in
  libraries (or only in very restricted cases), I see no problem in
  using them at the user level, when code reuse is not so much a
  problem. Consider also the problems related with the use of
  references in ML. I prefer to use an object with a mutable instance
  variable, and know the scope of my variable.
  Why not use an ADT? With objects and inheritance it is easier to
  provide several variations on the same basic interface.  Once an
  ADT is closed, there is no easy way to extend it.  However if I'm
  going to turn this into a library, I might start thinking harder,
  and build an ADT covering the needed variations.

* There are cases where you need objects for typing. Parametric
  polymorphism is wonderful, but it does not cover everything.
  Heterogeneous containers are not available for instance. Object
  subtyping is a way to refine typing, and be able to express more in
  a type-safe system.

I shall add that I do not believe that OOP is the only useful
extension one may add to FP. There are many other directions to
explore.  There is of course a tradeoff between expressivity and
complexity of the language, but remember that currently the public for
FP is a knowledgeable one, and ready to learn.

Quote:
> What we need is a way to give to the rest of the world what
> we have already found for ourselves.  FP, not OOP, is the
> real revolution, the real break-through, the real hope for
> the programmers of the next generation.

The question is maybe: Are we ready?
Certainly, we have found ways to solve our problems using FP, but can
we solve all problems using FP? If this is not the case, can we provide
a unified model for integrating with systems that solve the problems
we cannot solve?

FP is a wonderful paradigm for writing compilers and theorem provers.
We have known this for long. It can also be used for many other tasks,
but there proving its superiority will not be that easy.

I read a lot about Erlang on this newsgroup.  I sincerely believe this
is a wonderful language, and a step in the good direction.  But can it
pretend to be as universal as C/C++ ?  If no, what are users expected
to do for areas not covered by the language?

I would really like to know what is the real strength of FP now, not
only in terms of what one can do with it, but also in terms of how
easily the peripheral problems, and particularly the relation with the
non-FP world can be handled, both conceptually (what is an object seen
from the FP side) and practically.

Regards,

        Jacques

---------------------------------------------------------------------------
Jacques Garrigue      Kyoto University     garrigue at kurims.kyoto-u.ac.jp
                <A HREF=http://wwwfun.kurims.kyoto-u.ac.jp/~garrigue/>JG</A>



Fri, 29 Dec 2000 03:00:00 GMT  
 
 [ 55 post ]  Go to page: [1] [2] [3] [4]

 Relevant Pages 

1. DBC in functional languages [Was: comparison OOP and FP]

2. FP Component Libraries? (FP vs OOP)

3. A good language to start fp

4. Good language with which to learn FP?

5. OOP and classes, Was: OOP & Functional Languages

6. New security exploit combination, I think

7. multi-language vs mono-language, 1/2 (was: Me and FP &c)

8. multi-language vs mono-language, 2/2 (was: Me and FP &c)

9. Speed of FP languages, prospects (was Re: Benchmarking Lazy Functional Languages)

10. comparison OOP and FP (and how to put them together) was: Re: need help with haskell

11. OOP => FP

12. "FP+OOP=Haskell"

 

 
Powered by phpBB® Forum Software