From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 79C4C7EF29 for ; Fri, 18 Dec 2015 11:25:29 +0100 (CET) IronPort-PHdr: 9a23:sCS/wRYKMiCj9e61xaifC7P/LSx+4OfEezUN459isYplN5qZpcu9bnLW6fgltlLVR4KTs6sC0LqI9fi4EUU7or+/81k6OKRWUBEEjchE1ycBO+WiTXPBEfjxciYhF95DXlI2t1uyMExSBdqsLwaK+i760zceF13FOBZvIaytQ8iJ35rxj7j60qaQSjsLrQL1Wal1IhSyoFeZnegtqqwmFJwMzADUqGBDYeVcyDAgD1uSmxHh+pX4p8Y7oGx48sgs/M9YUKj8Y79wDfkBVGxnYCgJ45jMnhDGSUOq73oYU2MZ2j5JGBSNuBrzW5O0tirhqsJ83jObNIv4V+Zndy6l6vJQRQLuhywHOjk9uEPKjMM42LlQog+nqFp/0pP8b4ScNf44daTYK4BJDVFdV9pcAnQSSri3aJECWq9YZb5V Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=scjung.hyu@gmail.com; spf=Pass smtp.mailfrom=scjung.hyu@gmail.com; spf=None smtp.helo=postmaster@mail-qg0-f54.google.com Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of scjung.hyu@gmail.com) identity=pra; client-ip=209.85.192.54; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="scjung.hyu@gmail.com"; x-sender="scjung.hyu@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of scjung.hyu@gmail.com designates 209.85.192.54 as permitted sender) identity=mailfrom; client-ip=209.85.192.54; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="scjung.hyu@gmail.com"; x-sender="scjung.hyu@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-qg0-f54.google.com) identity=helo; client-ip=209.85.192.54; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="scjung.hyu@gmail.com"; x-sender="postmaster@mail-qg0-f54.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0B7AACl3XNWlDbAVdFdFoN2bQaENLgxgQSBYiGFbAKBMgc6EgEBAQEBAQEBEAEBAQEHCwsJHzCCLYIHAQEBAwESER0BGx4DDAYFCw0qAgIhAQERAQUBHAYTCRmHdwEDCggOnVOBMT4xi0iBaoJ5iBYKGScNVoNTAQEBBwEBAQEBARcBBQ6LRoJTgjWCb4FJBY4tiFKFPIYXgXiBXEmTI4NngicSJIEXERgLgjQjgWwvNAEBAYUOAQEB X-IPAS-Result: A0B7AACl3XNWlDbAVdFdFoN2bQaENLgxgQSBYiGFbAKBMgc6EgEBAQEBAQEBEAEBAQEHCwsJHzCCLYIHAQEBAwESER0BGx4DDAYFCw0qAgIhAQERAQUBHAYTCRmHdwEDCggOnVOBMT4xi0iBaoJ5iBYKGScNVoNTAQEBBwEBAQEBARcBBQ6LRoJTgjWCb4FJBY4tiFKFPIYXgXiBXEmTI4NngicSJIEXERgLgjQjgWwvNAEBAYUOAQEB X-IronPort-AV: E=Sophos;i="5.20,445,1444687200"; d="scan'208";a="192905807" Received: from mail-qg0-f54.google.com ([209.85.192.54]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 18 Dec 2015 11:25:28 +0100 Received: by mail-qg0-f54.google.com with SMTP id v36so29220705qgd.2 for ; Fri, 18 Dec 2015 02:25:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=/v69+JOW7wDz0HDqzIE18XcX508Fc41PQ6EIw8dhR0I=; b=apwZFzPkNibEpei0KGXoA/aU68RPDvWGopnkO5ntw0GR5dKV24+0ay16r8EvpCsw2z uQTiGNDwF4Rgt/7VTBfQRe0iH0cwu4mNrpfRJsHjfwRjzHjIOr54H0wnQZOvbslk6LHF xyQjiiba0D3mLfavmg2DRZon2pNoUuZBneMG7HuqSgoL3QVlqqnLCLUKkoOFBst/T8yQ z66/b63VgJGXxXo5IXcESIgFuksP+1QDg2j/xvTCsBdejuTmDLkWVGQy8pAQqNzXEJ0j j8Q3ler6Z95egbdywagb388FQZXyHj9CRNeKrD9UbedAs5JeZNpuFDiGSweG79D11QhC ztyA== X-Received: by 10.140.109.136 with SMTP id l8mr3814841qgf.26.1450434327229; Fri, 18 Dec 2015 02:25:27 -0800 (PST) MIME-Version: 1.0 Received: by 10.55.96.135 with HTTP; Fri, 18 Dec 2015 02:25:07 -0800 (PST) In-Reply-To: <4D6A138A-AA9F-4DFB-85E8-38B44983EC11@gmail.com> References: <8D722630-1CB1-413B-9F90-1F975FA5B64B@gmail.com> <4D6A138A-AA9F-4DFB-85E8-38B44983EC11@gmail.com> From: Seungcheol Jung Date: Fri, 18 Dec 2015 19:25:07 +0900 Message-ID: To: OCaml Mailing List Content-Type: multipart/alternative; boundary=001a113a44f8d83b600527298ee7 Subject: Re: [Caml-list] Invoking Java programs from an OCaml program --001a113a44f8d83b600527298ee7 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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=C3=A9[3] might reduce some burden?) and bewar= e 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 wrote: > > On Dec 15, 2015, at 6:21 AM, Paul Pelzl wrote: > > On Mon, Dec 14, 2015 at 9:25 AM, Chan Ngo 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 > > --001a113a44f8d83b600527298ee7 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi, list.

I am also looking for a way to use Java l= ibrary in OCaml application. My OCaml
application is performance-critica= l 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 int= o 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. Us= ing 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=C3=A9[3] might= reduce some burden?) and beware of
type-safety. Also, it is not maintai= ned for a long time (the latest
version came out before ten years ago).<= br>
Do you have any suggestions? Moreover, could anyone share some real-= world
stories about OCaml-Java binding?


Regards,
Seungcheo= l Jung

[1] http://www.ocamljav= a.org/
[2] https://forge.ocamlcore.org/projects/camljava/
[3] http://www.p= ps.univ-paris-diderot.fr/~henry/ojacare/index.en.html


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

<= span class=3D"">
On Dec 15, 2015, at 6:21 AM,= Paul Pelzl <pelz= lpj@gmail.com> wrote:

On Mon, Dec 14,= 2015 at 9:25 AM, Chan Ngo <chan.ngo2203@gmail.com> wro= te:
An = alternative, if you want to do as follows:
- Compile Java program to an= executable (not jar file)
- Call this executable and get the ret= urn values from it

So you can think about Unix mod= ule in OCaml, you can use the standard I/O to realize a communication chann= el between your OCaml code and the executable Java.


If the data to be exchanged is structurally com= plex, then this technique becomes difficult; a cross-platform serialization= library can be very helpful for generating appropriate serialization code = in multiple languages.=C2=A0 As one example, Cap'n Proto has bindings f= or both Java and OCaml: https://capnproto.org/otherlang.html

Yes, I agree, in some cas= es, it will become difficult and we need a cross-platform serialization lib= rary. Your example is a good point. In addition, if you can control the sou= rce 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.

Be= st,


--001a113a44f8d83b600527298ee7--