caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: skaller <skaller@users.sourceforge.net>
To: Mako Tagliere <mako.tagliere@gmail.com>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Multi-Index Container
Date: Fri, 02 Dec 2005 11:19:54 +1100	[thread overview]
Message-ID: <1133482794.9266.74.camel@rosella> (raw)
In-Reply-To: <2670dfc80512011442g560dbfd0nabdef7c65d26d04c@mail.gmail.com>

On Thu, 2005-12-01 at 14:42 -0800, Mako Tagliere wrote:
> Hi,
> 
> My colleagues and I often debate the relative merits of OCaml and C++.
> After I tell them how expressive, fast, and all-around nifty OCaml is
> ("see! the debugger works backwards in time!"), they reply "yeah but
> C++ has STL and Boost library, which make C++ every bit as expressive as
> OCaml." 

Total Rubbish! Some people will never learn. C++ templates
actually provide a bit more than ML can -- there is some
real functorial polymorphism there. However it isn't
properly structured, and neither is C++ polymorphism,
relying on dependent name lookup as it does.

C++ also doesn't have really basic things like tuples, 
variants and first class functions. No, don't point
me at the crap in Boost -- a fine effort for C++
but it just doesn't compare with a real programming
language. Just try implementing a list: in Ocaml one line:

	type 'a mylist = Empty | Cons of 'a * 'a mylist

Just try doing THAT with variants and tuples from
the Boost library. :)) Hint -- type recursion
doesn't work with templates. It is possible to do it
but it is VERY hard, it has to be done with open
recursion, which is closed using a partial specialisation.

And if you actually succeed .. hehe .. show me how
to do terse pattern matching like

	match somelist with
	| Empty -> ...
	| Cons (elt, tail) -> ....

There is one, and ONLY one good way to do all this in
C++: using Felix.

>  When we repeated this debate recently, they challenged me to
> show them an implementation of Boost's multi-index container
> (http://www.boost.org/libs/multi_index/doc/index.html) in OCaml.  A
> bit of searching did not reveal an existing OCaml implementation.

Because Ocaml doesn't generally need it. Just use modules
(to enforce invariants) and multiple data structures,
Ocaml boxes (shares on the heap) the data anyhow.

Ocaml doesn't need multi-indexed containers in general,
they're trivial. It needs the opposite -- some way
of NOT sharing mutable data structures, which is the
default in C++.

-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net


  reply	other threads:[~2005-12-02  0:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-01 22:42 Mako Tagliere
2005-12-02  0:19 ` skaller [this message]
2005-12-02  0:53 ` [Caml-list] " Jon Harrop

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1133482794.9266.74.camel@rosella \
    --to=skaller@users.sourceforge.net \
    --cc=caml-list@yquem.inria.fr \
    --cc=mako.tagliere@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).