From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 7206EBBAF for ; Mon, 15 Feb 2010 00:31:43 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEAI0WeEtQRFuw/2dsb2JhbACbG3S6MIRbBA X-IronPort-AV: E=Sophos;i="4.49,473,1262559600"; d="scan'208";a="44640468" Received: from furbychan.cocan.org ([80.68.91.176]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES256-SHA; 15 Feb 2010 00:31:43 +0100 Received: from rich by furbychan.cocan.org with local (Exim 4.63) (envelope-from ) id 1NgnwE-00006q-Ls; Sun, 14 Feb 2010 23:31:42 +0000 Date: Sun, 14 Feb 2010 23:31:42 +0000 To: Guillaume Yziquel Cc: OCaml List Subject: Re: [Caml-list] Wrapping var_args, or C ... in ocaml? Message-ID: <20100214233142.GE24949@annexia.org> References: <4B781ACC.4040603@citycable.ch> <20100214180650.GA22433@annexia.org> <4B787D32.10505@citycable.ch> <20100214225931.GC24949@annexia.org> <4B78838D.1040208@citycable.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4B78838D.1040208@citycable.ch> User-Agent: Mutt/1.5.13 (2006-08-11) From: Richard Jones X-Spam: no; 0.00; ocaml:01 ocaml:01 decoding:01 runtime:01 bindings:01 ffi:01 haskell:01 haskell:01 ffi:01 bindings:01 caml-list:01 dlls:01 conventions:02 inefficient:02 structures:02 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