From: Arlen Cox <arlencox@gmail.com>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Make OCaml library available to Java
Date: Tue, 2 Aug 2016 07:51:11 -0400 [thread overview]
Message-ID: <CAHEcMuHcjpa0YkfvGRB2WQTJZgSC4qTwobSAzp90=uyXPrmmzQ@mail.gmail.com> (raw)
In-Reply-To: <86a8gvjv6d.fsf@gmail.com>
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?
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
next prev parent reply other threads:[~2016-08-02 11:51 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 [this message]
2016-08-02 16:34 ` Gerd Stolpmann
2016-08-02 16:48 ` Arlen Cox
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='CAHEcMuHcjpa0YkfvGRB2WQTJZgSC4qTwobSAzp90=uyXPrmmzQ@mail.gmail.com' \
--to=arlencox@gmail.com \
--cc=caml-list@inria.fr \
/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