caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: Dave Berry <dave@kal.com>
Cc: caml-list@inria.fr
Subject: [Caml-list] Re: OCaml on CLR/JVM?
Date: Wed, 14 Feb 2001 20:30:51 +0100	[thread overview]
Message-ID: <20010214203051.A28371@pauillac.inria.fr> (raw)
In-Reply-To: <3145774E67D8D111BE6E00C0DF418B663ED7AF@nt.kal.com>; from dave@kal.com on Fri, Feb 09, 2001 at 03:49:16PM -0000

> To look at it another way, OCaml already shares a platform with C
> (at least with the native-code compiler), so all the C libraries are
> already available.  Yet it can still be a lot of effort to link with
> a C library.  Why should Java and .NET be any easier?

In short, because it is possible to automate fully the generation of
stub code for interfacing with Java or .NET, while this is not
possible in C.  To generate stub code, you need to know quite a lot
about the library you're interfacing with: 
- types of function arguments and results, and of data structure members;
- memory protocol (who frees dynamically-allocated memory and when?)
- error reporting protocol (e.g. return "impossible" results, or
    longjmp() somewhere, or call a user-provided error callback, or ...)

For C, most of this information is implicit or written down in English
only.  E.g. the function prototypes you find in .h files are wholly
inadequate to generate stub code because the C types are not
informative enough: is "char **" an array of strings or a string
result passed as an "out" parameter?  what about macros (they are in
effect untyped)?  As for memory management and error reporting, the .h
file doesn't say anything at all.  

So, interfacing with a C library requires quite a lot of manual
intervention to supply the missing info.  This can take the form of
writing the stubs entirely by hand, or writing a higher-level
description of the library interface in an IDL-like interface from
which the stubs can be generated automatically.  The latter means less
typing, but is not actually significantly easier: the programmer still
has to get the intended behavior from the English documentation, and
then shape it into an IDL file that the stub generator will
understand.

Interfacing with Java or .NET is a completely different story:
- Libraries always come with detailed type annotations (descriptors
  in Java .class files; metadata in .NET) that are high-level enough
  to support the automatic generation of stub code.
- These systems are garbage-collected, so there is no concern about
  manual deallocation.
- These systems have built-in exceptions, which most libraries use
  consistently to report errors.

So, the goal of generating stub code entirely automatically can be
achieved with Java or .NET, but not with C.  (Or so I hope; we'll see
how it goes.)

- Xavier Leroy
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


  parent reply	other threads:[~2001-02-14 19:30 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-02-09 15:49 Dave Berry
2001-02-10  1:04 ` Toby Watson
2001-02-14 19:30 ` Xavier Leroy [this message]
2001-02-15 12:12   ` [Caml-list] " Sven LUTHER
  -- strict thread matches above, loose matches on Subject: below --
2001-03-05  6:00 [Caml-list] " Arturo Borquez
2001-02-23 16:33 Chris Tilt
2001-02-24 12:02 ` John Max Skaller
2001-02-16 19:06 Dave Berry
2001-02-16 21:16 ` Marcin 'Qrczak' Kowalczyk
2001-02-16 18:38 [Caml-list] " Dave Berry
2001-02-15  9:33 [Caml-list] " Fabrice Le Fessant
2001-02-15 10:19 ` Fabrice Le Fessant
2001-02-16 16:54 ` John Max Skaller
2001-02-14  7:31 Don Syme
2001-02-14 19:44 ` Xavier Leroy
2001-02-09 22:05 Don Syme
2001-02-14 17:24 ` [Caml-list] " Anton Moscal
2001-02-16 15:45   ` John Max Skaller
2001-02-06  0:03 OCaml on CLR/JVM? (RE: OCaml <--> ODBC/SQL Server) Don Syme
2001-02-08 19:03 ` OCaml on CLR/JVM? Xavier Leroy
2001-02-09  9:06   ` David Mentre
2001-02-14 19:32     ` [Caml-list] " Xavier Leroy

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=20010214203051.A28371@pauillac.inria.fr \
    --to=xavier.leroy@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=dave@kal.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).