Version française
Home     About     Download     Resources     Contact us    
Browse thread
Wrapping var_args, or C ... in ocaml?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Richard Jones <rich@a...>
Subject: Re: [Caml-list] Wrapping var_args, or C ... in ocaml?

As an example of a Python binding of the sort we generate in
libguestfs (using OCaml code to generate it :-)

  http://www.annexia.org/tmp/guestfs-py.c.txt
  [Search for calls to PyArg_ParseTuple]

The Python binding technique is sort of interesting.  On the other
hand, Python is decoding that kind-of-C-format-string arg to
PyArg_ParseTuple entirely at runtime which makes it really slow (but
not the slowest thing in Python by any means -- that language takes
being inefficient to a new level).

Out of all the language bindings that we support, the one with the
most natural FFI to C [if you exclude C++] is C#.  In C# you can
express C structures, C calling conventions and so on directly in the
language, and it is very well documented how to do this.  This makes
C# calling C shared libraries / DLLs very natural.

  http://www.annexia.org/tmp/Libguestfs.cs.txt

The worst of all of them is Haskell.  Not because the Haskell FFI is
bad, but because it's (a) obscure and undocumented and (b) the only
one of the programming languages apart from C# where you aren't
basically writing C code.  If you don't already know Haskell, it's
very difficult to writing bindings for Haskell.

  http://www.annexia.org/tmp/Guestfs.hs.txt

Rich.

-- 
Richard Jones
Red Hat