caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Arlen Cox <arlencox@gmail.com>
To: Gerd Stolpmann <info@gerd-stolpmann.de>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Make OCaml library available to Java
Date: Tue, 2 Aug 2016 12:48:50 -0400	[thread overview]
Message-ID: <CAHEcMuGLKcTggCkRm9QfZpJko1N6-NUYuMu74Gi57+34JFGP4Q@mail.gmail.com> (raw)
In-Reply-To: <1470155691.9343.12.camel@e130.lan.sumadev.de>

Of course you're right.  Also, I think polymorphic variants would be
problemantic (and the object system...).

It just seems like there should be a genuinely good way to interact
with the JVM at a fine-grained level that doesn't involve writing a
boatload of really finicky C code to serve as an intermediary.  I
guess I sort of want a SWIG for OCaml instead of just SWIG for C/C++.

Arlen


On Tue, Aug 2, 2016 at 12:34 PM, Gerd Stolpmann <info@gerd-stolpmann.de> wrote:
> Am Dienstag, den 02.08.2016, 07:51 -0400 schrieb Arlen Cox:
>> Thank you for your answers.  I should be more clear on a couple of
>> things.  My default method of communication is to use pipes or
>> sockets.  However, my code is an abstract domain library.  The
>> interface exposes large, recursively defined variants; exposes
>> first-class modules (though not functors); and is expected to be
>> relatively high performance.
>>
>> For now I'll tinker with the js_of_ocaml option.  It might be a pain
>> to wrap it properly, but I think it should be possible to make the
>> performance acceptable by replacing a few of the hotter internal
>> components with native Java code accessed via the Javascript api.
>>
>> I am still open to other ideas, though.
>>
>> Has anyone considered writing a source-to-source translator from OCaml to Scala?
>
> Scala is fairly slow for symbolical code. Actually, I'd be more
> interested in a source-to-source translator from Scala to OCaml to get
> better speed... For a translation of OCaml to Scala you need to start
> with the typed source code (cmt files) because Scala requires way more
> typing hints than OCaml, and to get the omnipresent subtyping under
> control. Also, there is no direct counterpart of first-class modules, so
> you'd have to work around that.
>
> Gerd
>
>> Thanks,
>> Arlen
>>
>> On Tue, Aug 2, 2016 at 6:56 AM, Malcolm Matalka <mmatalka@gmail.com> wrote:
>> > You could also make an executable written in Ocaml that communicates
>> > over stdin/stdout.
>> >
>> > Arlen Cox <arlencox@gmail.com> writes:
>> >
>> >> Hi all,
>> >>
>> >> I'm trying to figure out what the best way is to make an OCaml library
>> >> available to a Java program.  I can think of several ways to do this
>> >> each with pros and cons:
>> >>
>> >> 1.  OCaml-Java:  This is the most obvious solution that translates the
>> >> OCaml code directly to Java.
>> >>   + Simple interface to OCaml code
>> >>   + Portable Java-compatible code
>> >>   + Can easily call back into Java
>> >>   - OCaml-Java is a bit buggy
>> >>   - Code runs slower
>> >>
>> >> 2.  js_of_ocaml:  Translate OCaml to JavaScript and then use the new
>> >> "fast" JavaScript engine in Java 8 to execute the JS.
>> >>   + Portable Java-compatible code
>> >>   + Can call back into Java (albeit, less easily than OCaml-Java)
>> >>   - Not type safe interface
>> >>   - Possible massive slowdowns or at least unpredictable performance
>> >>
>> >> 3.  JNI with C Library:  Wrap OCaml code in a C library and then call
>> >> into that with JNI
>> >>   + Native OCaml performance
>> >>   - Complex GC interaction
>> >>   - Not type safe
>> >>   - Not portable (need different .so for each platform)
>> >>   - No tools to help in doing this (CamlJava is both unsupported and
>> >> seemingly unidirectional)
>> >>   - No easy call back into Java
>> >>
>> >> Does anyone have any experience with doing this or have any
>> >> suggestions on what to do in this situation?
>> >>
>> >> Thanks,
>> >> Arlen
>>
>
> --
> ------------------------------------------------------------
> Gerd Stolpmann, Darmstadt, Germany    gerd@gerd-stolpmann.de
> My OCaml site:          http://www.camlcity.org
> Contact details:        http://www.camlcity.org/contact.html
> Company homepage:       http://www.gerd-stolpmann.de
> ------------------------------------------------------------
>

  reply	other threads:[~2016-08-02 16:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-02  4:02 Arlen Cox
2016-08-02 10:56 ` Malcolm Matalka
2016-08-02 11:51   ` Arlen Cox
2016-08-02 16:34     ` Gerd Stolpmann
2016-08-02 16:48       ` Arlen Cox [this message]
2016-08-02 17:21     ` Pippijn van Steenhoven
2016-08-02 17:34       ` Arlen Cox
2016-08-03 12:43       ` Hendrik Boom
2016-08-03 12:46         ` Jeremy Yallop

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=CAHEcMuGLKcTggCkRm9QfZpJko1N6-NUYuMu74Gi57+34JFGP4Q@mail.gmail.com \
    --to=arlencox@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=info@gerd-stolpmann.de \
    /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).