English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] ocaml complexity
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-06-06 (19:32)
From: William Chesters <williamc@p...>
Subject: [Caml-list] ocaml complexity
Miles Egan writes:
 > Of all the functional languages, Ocaml seems to me the most pragmatic and most
 > useful for everyday programming, but I wonder if it's within the grasp of the
 > everyday user.  I know a lot of fairly amateur C++ programmers who get by with a
 > small subset of the language, but it seems more difficult to limit oneself to a
 > small subset of Ocaml.

 > Have others had similar experiences?  I suspect most of the readers of this list
 > are better-than-average programmers.  How difficult have you found it to be to
 > teach Ocaml to your colleagues?  Any suggestions on a simple pedagogy for
 > bringing more junior people abreast of subjects as esoteric as polymorphic
 > recursive types?

Objectively, C++ is much harder to learn than ocaml and you have to be
_brilliant_ to make the most of it without getting into trouble.  The
point surely is that people are more familiar, or at least feel
embarrassed about being unfamiliar, with the _jargon_ of C++ as
against that of ocaml.

Try this table:

ocaml closures \approx anonymous classes with one "virtual operator ()" method

ocaml sum types \approx C union with attached variant code

ocaml polymorphic types \approx generic types via templates

   -- but no worries about template instantiation, or bloat, or
      having to learn about the STL!

                     or \approx void * pointers in C
   -- but with typechecking of course

ocaml recursive types = C++ recursive types
   -- but less confusing---try explaining to a junior programmer
      what does and does not provoke "incomplete type not allowed"
      in templatey C++ code

ocaml functors, or paramaterised modules, \approx C++ templates
   -- but in ocaml you get to give signatures, hooray (typename anyone???)

ocaml classes \approx C++ classes in which all methods are virtual

The really big cultural shift is to think in recursive not iterative
terms.  I really don't know how to teach that or even explain why it's
sometimes a nice way to look at things.  But of course in a
multiparadigm language (like ocaml or, well, C++) that's more a matter
what you do with the language rather than the language per se.

Another thing that throws people, strangely, is the sheer
conciseness of functional languages---even ocaml (let alone Clean).

Finally I think there is a hard core of people who cannot understand a
language until they know how it is implemented.  In fact ocaml is
implemented in a very machine-friendly way (which is why it's so fast
and practical).  Maybe it's a useful exercise to write out equivalent
C---just as it's a great way of explaining C++ to people.
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr