caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* C++ STL bindings
@ 2010-05-10 14:00 Jianzhou Zhao
  2010-05-10 14:32 ` [Caml-list] " Basile Starynkevitch
  0 siblings, 1 reply; 2+ messages in thread
From: Jianzhou Zhao @ 2010-05-10 14:00 UTC (permalink / raw)
  To: caml-list

Hi,

Does anyone know if there is an OCaml binding to C++ STL libraries, or
any other functional language with a foreign binding to such C++
standard libraries (STL, boost)?

Thanks
-- 
Jianzhou


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] C++ STL bindings
  2010-05-10 14:00 C++ STL bindings Jianzhou Zhao
@ 2010-05-10 14:32 ` Basile Starynkevitch
  0 siblings, 0 replies; 2+ messages in thread
From: Basile Starynkevitch @ 2010-05-10 14:32 UTC (permalink / raw)
  To: Jianzhou Zhao; +Cc: caml-list

On Mon, May 10, 2010 at 10:00:32AM -0400, Jianzhou Zhao wrote:


> Does anyone know if there is an OCaml binding to C++ STL libraries, or
> any other functional language with a foreign binding to such C++
> standard libraries (STL, boost)?

I believe such a beast cannot reliably exist.

The STL C++ library (and probably the Boost one also) provides a bunch
of data structure implementations in C++. All these implementation are
built on the (sad) fact that C++ manage memory (& resources)
explicitly. In other words, any data in the C++ heap was probably
allocated thru new and should probably be *explicitly* freed thru
delete.

Also the STL C++ library is heavily template based. This means some
kind of systematic code generation.

In contrast, Ocaml provide very useful generic abstract data types in
its standard library (and other common libraries...) using functors
(see the List, Array, Hashtbl, Map, Set, ... modules).

Ocaml has also a powerful garbage collector, and most functors from
its standard library take advantage of it (in a few words, in Ocaml,
allocating memory is conceptually quite cheap & efficient, and you
don't need to free it explicitly; in contrast, allocating memory
inside C++ heap is usually much slower that equivalent allocation in
Ocaml; of course the C++ memory manager has features not provided by
Ocaml's GC -real multithreading, ...-).


So the short answer to your quest is: stick to Ocaml functors (and
avoid using C++ STL in Ocaml programs).


Cheers.

-- 
Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mines, sont seulement les miennes} ***


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-05-10 14:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-10 14:00 C++ STL bindings Jianzhou Zhao
2010-05-10 14:32 ` [Caml-list] " Basile Starynkevitch

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).