caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Seungcheol Jung <scjung.hyu@gmail.com>
To: OCaml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] Invoking Java programs from an OCaml program
Date: Fri, 18 Dec 2015 19:25:07 +0900	[thread overview]
Message-ID: <CAARf2izyr6+6Zhto9bsnMz0W-fe1EHcU7mgEzLEOz8gTZoETug@mail.gmail.com> (raw)
In-Reply-To: <4D6A138A-AA9F-4DFB-85E8-38B44983EC11@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2845 bytes --]

Hi, list.

I am also looking for a way to use Java library in OCaml application. My
OCaml
application is performance-critical static source code analyzer. I found two
options: X. Clerc's OCaml-Java and X. Leroy's camljava. Which one is more
suitable?

1. OCaml-Java
From my understanding, OCaml-Java[1] compiles OCaml code into byte code and
packs the byte code, interpreter, and Java code into one Java application.
It
looks more like embedding OCaml code in Java, not getting some help from
Java. So it does not satisfy my pro-OCaml taste. I am also concerned about
slowdowns due to byte code and interpreter.

2. camljava
I think camljava[2] is more suitable for my purpose. Using camljava, I can
launch JVM and call Java methods via JNI from native OCaml applications.
However, it is a very low-level interface so that I need to implement many
boilerplates by hand (O'Jacaré[3] might reduce some burden?) and beware of
type-safety. Also, it is not maintained for a long time (the latest
version came out before ten years ago).

Do you have any suggestions? Moreover, could anyone share some real-world
stories about OCaml-Java binding?


Regards,
Seungcheol Jung

[1] http://www.ocamljava.org/
[2] https://forge.ocamlcore.org/projects/camljava/
[3] http://www.pps.univ-paris-diderot.fr/~henry/ojacare/index.en.html


On 16 December 2015 at 22:29, Chan Ngo <chan.ngo2203@gmail.com> wrote:

>
> On Dec 15, 2015, at 6:21 AM, Paul Pelzl <pelzlpj@gmail.com> wrote:
>
> On Mon, Dec 14, 2015 at 9:25 AM, Chan Ngo <chan.ngo2203@gmail.com> wrote:
>
>> An alternative, if you want to do as follows:
>> - Compile Java program to an executable (not jar file)
>> - Call this executable and get the return values from it
>>
>> So you can think about Unix module in OCaml, you can use the standard I/O
>> to realize a communication channel between your OCaml code and the
>> executable Java.
>> https://ocaml.github.io/ocamlunix/ocamlunix.html
>>
>>
> If the data to be exchanged is structurally complex, then this technique
> becomes difficult; a cross-platform serialization library can be very
> helpful for generating appropriate serialization code in multiple
> languages.  As one example, Cap'n Proto has bindings for both Java and
> OCaml: https://capnproto.org/otherlang.html
>
>
> Yes, I agree, in some cases, it will become difficult and we need a
> cross-platform serialization library. Your example is a good point. In
> addition, if you can control the source code of the Java side, you can
> modify the code such that it can return the result as JSON object then the
> OCaml side can get this object value to parse complex data structures.
>
> Best,
>
> ---
> Chan Ngo
> INRIA,
> (+33)02 99 84 72 84
> chan.ngo@inria.fr
> http://people.rennes.inria.fr/Chan.Ngo
>
>

[-- Attachment #2: Type: text/html, Size: 4446 bytes --]

  reply	other threads:[~2015-12-18 10:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-14 16:40 Soichi Sumi
2015-12-14 17:25 ` Chan Ngo
2015-12-15  5:21   ` Paul Pelzl
2015-12-16 13:29     ` Chan Ngo
2015-12-18 10:25       ` Seungcheol Jung [this message]
2015-12-18 22:55         ` Sebastien Ferre
2015-12-21  8:53         ` forum
2015-12-15  9:06 ` forum

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=CAARf2izyr6+6Zhto9bsnMz0W-fe1EHcU7mgEzLEOz8gTZoETug@mail.gmail.com \
    --to=scjung.hyu@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;
as well as URLs for NNTP newsgroup(s).