caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Richard Jones <rich@annexia.org>
To: Guillaume Yziquel <guillaume.yziquel@citycable.ch>
Cc: OCaml List <caml-list@inria.fr>
Subject: Re: [Caml-list] Wrapping var_args, or C ... in ocaml?
Date: Sun, 14 Feb 2010 23:31:42 +0000	[thread overview]
Message-ID: <20100214233142.GE24949@annexia.org> (raw)
In-Reply-To: <4B78838D.1040208@citycable.ch>


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


  parent reply	other threads:[~2010-02-14 23:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-14 15:46 Guillaume Yziquel
2010-02-14 18:06 ` [Caml-list] " Richard Jones
2010-02-14 20:26   ` Richard Jones
2010-02-14 22:46   ` Guillaume Yziquel
2010-02-14 22:59     ` Richard Jones
2010-02-14 23:13       ` Guillaume Yziquel
2010-02-14 23:19         ` Richard Jones
2010-02-15  1:34           ` Guillaume Yziquel
2010-02-15  2:37             ` Thomas Fischbacher
2010-02-14 23:31         ` Richard Jones [this message]
2010-02-15 10:16     ` Florent Monnier
     [not found]     ` <201002151106.23642.fmonnier@linux-nantes.fr.eu.org>
     [not found]       ` <4B7F3FED.4010100@citycable.ch>
2010-02-20  2:41         ` Guillaume Yziquel

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=20100214233142.GE24949@annexia.org \
    --to=rich@annexia.org \
    --cc=caml-list@inria.fr \
    --cc=guillaume.yziquel@citycable.ch \
    /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).