Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
The "Objective" part of Objective Caml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-11-08 (18:16)
From: brogoff <brogoff@s...>
Subject: Re: Ant: [Caml-list] The "Objective" part of Objective Caml
On Mon, 7 Nov 2005, Brian Hurt wrote:
> On Tue, 8 Nov 2005, skaller wrote:
> >>> The object oriented part of OCaml is roughly speaking
> >>> just as capable as that of Python, C++, Java, C# etc.
> >>
> >> Sure, I don't doubt that.
> >
> > I do. The Python system is much more 'capable' and much less 'robust'.
> > This is typical for dynamic typing vs static typing.
> I think I'm with Skaller here- Objects in Ocaml are much less powerfull
> than they are in (for example) Java or Python.

They're not "much less powerful" than they are in Java. They certainly lack
some features of the Java object system, but they posses many others. If
"powerful" means "supports multiple inheritance", Java is far less powerful.
If it means "supports" downcasting, ...

As far as static vs dynamic, dynamic type systems are inherently more
capable. There is no "slack" in a dynamically typed language. But the
possibility of a runtime exception is of course there.

>  For example, objects in
> Ocaml can not have non-virtual (non-overloadable) methods, or static
> (global) methods.  So patterns like singletons are hard to implement with
> Ocaml objects.
> But that's OK- because Ocaml provides other ways to provide those
> capabilities.  The problem I have with a lot of pure-OO languages is the
> need to make objects do everything.

The flip side of this is that OCaml is like Perl, with lots of ways to do
things, and many overlapping features. The fact that OCaml has classes and
modules is good, and that's how I think OO languages should be, but I would
expect that protection and hiding be done only by modules and not objects.

So, while I agree that a truly pure OO language is excessive, having a language
with tuples/records/variants/exceptions/... subsumed by the object system,
and a separate module system for namespace control is a reasonable approach.

> Ocaml is to use modules, not objects.  If you're not using the true power
> of objects- inheritance, virtual functions,

> and overloading-

Overloading is not an OO feature. Algol-68 and Ada 83, amongst others, had
overloading. While Java supports static overloading, languages like
CLOS and Dylan support generic functions with multiple dispatch, which
is far more powerful.

I do use classes when I want to reuse "record" field names, but that's
hardly OO. I suppose it is a kind of overloading though.

-- Brian