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 DC8F07EFCD for ; Sat, 18 Oct 2014 11:09:39 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of forum@x9c.fr) identity=pra; client-ip=188.165.33.202; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="forum@x9c.fr"; x-sender="forum@x9c.fr"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of forum@x9c.fr designates 188.165.33.202 as permitted sender) identity=mailfrom; client-ip=188.165.33.202; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="forum@x9c.fr"; x-sender="forum@x9c.fr"; 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@mo3.mail-out.ovh.net) identity=helo; client-ip=188.165.33.202; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="forum@x9c.fr"; x-sender="postmaster@mo3.mail-out.ovh.net"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkIBAL0tQlS8pSHKnGdsb2JhbABbg2FYzAqHTgKBJwERAQEBAQEICwkJFC6EAgEBAQMBeQULCxgcEiE2BhOIKwMJDAEIxkINhjEBAQEBAQEEAQEBAQEBGASOGYFcVAQHgy2BHgWSAIRGhQKRWYpTaoEGgUUBAQE X-IPAS-Result: AkIBAL0tQlS8pSHKnGdsb2JhbABbg2FYzAqHTgKBJwERAQEBAQEICwkJFC6EAgEBAQMBeQULCxgcEiE2BhOIKwMJDAEIxkINhjEBAQEBAQEEAQEBAQEBGASOGYFcVAQHgy2BHgWSAIRGhQKRWYpTaoEGgUUBAQE X-IronPort-AV: E=Sophos;i="5.04,745,1406584800"; d="scan'208,217";a="101783570" Received: from 13.mo3.mail-out.ovh.net (HELO mo3.mail-out.ovh.net) ([188.165.33.202]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/ADH-AES256-SHA; 18 Oct 2014 11:09:39 +0200 Received: from mail614.ha.ovh.net (gw6.ovh.net [213.251.189.206]) by mo3.mail-out.ovh.net (Postfix) with SMTP id 94D1FFFAC34 for ; Sat, 18 Oct 2014 11:09:37 +0200 (CEST) Received: from b0.ovh.net (HELO queueout) (213.186.33.50) by b0.ovh.net with SMTP; 18 Oct 2014 11:09:37 +0200 Received: from amontsouris-554-1-96-254.w86-212.abo.wanadoo.fr (HELO pc2.home) (forum%x9c.fr@86.212.71.254) by ns0.ovh.net with SMTP; 18 Oct 2014 11:09:35 +0200 Content-Type: multipart/alternative; boundary="Apple-Mail=_CA8736FB-75FD-4FF8-9D7F-137671299CA6" Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) From: "forum@x9c.fr" In-Reply-To: Date: Sat, 18 Oct 2014 11:09:34 +0200 Cc: Xavier Clerc , caml-list@inria.fr Message-Id: References: To: Kenneth Adam Miller X-Mailer: Apple Mail (2.1878.6) X-Ovh-Tracer-Id: 3336885850973209534 X-Ovh-Remote: 86.212.71.254 (amontsouris-554-1-96-254.w86-212.abo.wanadoo.fr) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-OVH-SPAMSTATE: OK X-OVH-SPAMSCORE: -100 X-OVH-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeejhedrtdduucetufdoteggodetrfcurfhrohhfihhlvgemucfqggfjnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-Spam-Check: DONE|U 0.5/N X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeejhedrtdduucetufdoteggodetrfcurfhrohhfihhlvgemucfqggfjnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd Subject: Re: [Caml-list] Library recompilation with OCamljava --Apple-Mail=_CA8736FB-75FD-4FF8-9D7F-137671299CA6 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=iso-8859-1 Hi Kenneth, Le 17 oct. 2014 =E0 23:33, Kenneth Adam Miller a =E9crit : > So, after doing some more work, I think the answer to 2) is no/no. After = looking more into piqi, I now just need to find a way to do protocol buffer= s based RPC to an ocaml service... >=20 > Anybody know how to do that? >=20 > On Thu, Oct 16, 2014 at 4:08 AM, Kenneth Adam Miller wrote: > So, I'm attempting a large library recompile with ocamljava. It's pretty = audacious, because some people in my workplace are rather unwilling to lear= n ocaml, yet a very well respected and needed library is authored in it. Ev= eryone knows java, so we hope very much to recompile the library just with = ocamljava.=20 >=20 > Two important things that make me nervous in pursuing this effort are: >=20 > 1) once fully recompiled, will the library work in java as it did with na= tive/ocaml byte code? > I've already started modifying the popular OCamlMakefile project to add a= java-byte-code target, and I've found that a threaded example is admitted = by the compiler produces an uncaught exception when run on the JVM... That = example may fall out of what the ocamljava docs has been safely implemented= under ocamljava, I'm not sure... This sounds like a bug... It would be nice to report it at https://github.= com/xclerc/ocamljava, particularly if you have a (small) reproduction case. The "thread" library = is indeed only lightly tested, mainly because the "concurrent" library (which is specific to OCaml= -Java) includes another implementation of threads, that is much closer to Java threads. > 2) I've noticed that the rather large library that I need to compile, as = my final target, and aside from the toy targets I'm testing ocamljava with,= actually consumes some other C libraries and functions in it's dependency = path... > This is difficult; the traditional OCamlMakefile builds traditional c stu= bs to .o files, correctly compiled with ocamlc. But when put on the ocamlja= va command line, but ocamljava doesn't know what to do about it. Would ther= e be any way that I can have support for this ocaml feature as well, or fac= ilitate some way to link in or enable ocaml code that calls into C being co= mpiled down to java?=20 OCaml-Java does not know how to handle C files, as additional primitives sh= ould be implemented through Java files. As a consequence, when porting a project from ocamlc/oc= amlopt to ocamljava, you have to port C files to Java files. >=20 > 3) What if the answer to 2) is no/no? > If I can't use ocamljava, which is the most desired and elegant way, allo= wing beautiful language inter-operation, how can I best facilitate calls to= the ocaml library? Is there a fast way to generate callbacks to ocaml in j= ava or any other language? It's very highly preferable not to have to deleg= ate back through the JNI due to type safety and fragility. Alternatively, I= looked at the OCaml library Restful, and wondered to myself if there could= be any kind of fast definition between ocaml types and an exchange languag= e, like json or something. Ideally, I'd like to be able to generate a url p= er function in a very very simple declarative manner, so that I can take oc= aml libraries, and make them operate as a service, where ocaml library func= tions correspond to URLs. I think a neat way to use a C library from an ocamljava-compiled program wo= uld be to have a Java "backend" for Jeremy Yallop's ctypes (https://github.com/ocamllabs/oca= ml-ctypes). I never had the time to implement that, but toyed with this idea and think = the best way to implement it would be to go through JNA (https://github.com/twall/jna) rath= er than JNI. JNA includes a "dlopen"-like mechanism, and automatically maps simple types= from Java to C. My knowledge of ctypes is quite limited, but I see no showstopper. Regards, Xavier= --Apple-Mail=_CA8736FB-75FD-4FF8-9D7F-137671299CA6 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=iso-8859-1 Hi Kenneth,


Le 17 oct. 2014 =E0 23:33, Kenneth Adam Miller <kennethadammiller@gmail.com= > a =E9crit :

So, after doing some more work, I think the a= nswer to 2) is no/no. After looking more into piqi, I now just need to find= a way to do protocol buffers based RPC to an ocaml service...

Anybody know how to do that?
<= br>
On Thu, Oct 16, 2014 at 4:08 AM, Kenneth Adam= Miller <kennethadammiller@gmail.com> wrote:
So, I'm attempting a large library recompile with ocamljava. It's pretty = audacious, because some people in my workplace are rather unwilling to lear= n ocaml, yet a very well respected and needed library is authored in it. Ev= eryone knows java, so we hope very much to recompile the library just with = ocamljava. 

Two important things that make me nervo= us in pursuing this effort are:

1) once fully reco= mpiled, will the library work in java as it did with native/ocaml byte code= ?
I've already started modifying the popular OCamlMakefile project to a= dd a java-byte-code target, and I've found that a threaded example is admit= ted by the compiler produces an uncaught exception when run on the JVM... T= hat example may fall out of what the ocamljava docs has been safely impleme= nted under ocamljava, I'm not sure...

This sounds  like a= bug... It would be nice to report it at https://github.com/xclerc/ocamljava,
parti= cularly if you have a (small) reproduction case. The "thread" library is in= deed only lightly
tested, mainly because the "concurrent" library= (which is specific to OCaml-Java) includes
another implementatio= n of threads, that is much closer to Java threads.


2) I've noticed that the rather large library that I ne= ed to compile, as my final target, and aside from the toy targets I'm testi= ng ocamljava with, actually consumes some other C libraries and functions i= n it's dependency path...
This is difficult; the tra= ditional OCamlMakefile builds traditional c stubs to .o files, correctly co= mpiled with ocamlc. But when put on the ocamljava command line, but ocamlja= va doesn't know what to do about it. Would there be any way that I can have= support for this ocaml feature as well, or facilitate some way to link in = or enable ocaml code that calls into C being compiled down to java? 
OCaml-Java does not know how to handle C files, as additional p= rimitives should be implemented
through Java files. As a conseque= nce, when porting a project from ocamlc/ocamlopt to ocamljava,
yo= u have to port C files to Java files.



<= /div>
3) What if the answer to 2) is no/no?
If I can't use ocaml= java, which is the most desired and elegant way, allowing beautiful languag= e inter-operation, how can I best facilitate calls to the ocaml libr= ary? Is there a fast way to generate callbacks to ocaml in java or any othe= r language? It's very highly preferable not to have to delegate back throug= h the JNI due to type safety and fragility. Alternatively, I looked at the = OCaml library Restful, and wondered to myself if there could be any kind of= fast definition between ocaml types and an exchange language, like json or= something. Ideally, I'd like to be able to generate a url per function in = a very very simple declarative manner, so that I can take ocaml libraries, = and make them operate as a service, where ocaml library functions correspon= d to URLs.

I think a neat way to use a C library fro= m an ocamljava-compiled program would be to have a
Java "backend"= for Jeremy Yallop's ctypes (https://github.com/ocamllabs/ocaml-ctypes).
I never h= ad the time to implement that, but toyed with this idea and think the best = way to
implement it would be to go through JNA (https://github.com/twall/jna) rather than JNI.<= /div>
JNA includes a "dlopen"-like mechanism, and automatically maps si= mple types from Java
to C. My knowledge of ctypes is quite limite= d, but I see no showstopper.


Regard= s,

Xavier
= --Apple-Mail=_CA8736FB-75FD-4FF8-9D7F-137671299CA6--