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 1AA057FF37 for ; Tue, 2 Aug 2016 18:48:53 +0200 (CEST) IronPort-PHdr: 9a23:TEB+VRTcic/SEDj6xiL5TOjK4dpsv+yvbD5Q0YIujvd0So/mwa64YBON2/xhgRfzUJnB7Loc0qyN4vimBjxLvszJmUtBWaQEbwUCh8QSkl5oK+++Imq/EsTXaTcnFt9JTl5v8iLzG0FUHMHjew+a+SXqvnYsExnyfTB4Ov7yUtaLyZ/mj6btq9aMOU1hv3mUWftKNhK4rAHc5IE9oLBJDeIP8CbPuWZCYO9MxGlldhq5lhf44dqsrtY4q3wD86Fpy8kVfqjgc+wDUbtcFDEvNWZ9sMztux7rQgaV6j4HTmISih9BBQ6D4BysDbnrtS6vn/B51S/SFsrmBeQ9QzCv6axsWDfnjS4GM3gy92SB2Z84t75SvB/0/083+IXTeozAbPc= Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=arlencox@gmail.com; spf=Pass smtp.mailfrom=arlencox@gmail.com; spf=None smtp.helo=postmaster@mail-yw0-f171.google.com Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of arlencox@gmail.com) identity=pra; client-ip=209.85.161.171; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="arlencox@gmail.com"; x-sender="arlencox@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of arlencox@gmail.com designates 209.85.161.171 as permitted sender) identity=mailfrom; client-ip=209.85.161.171; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="arlencox@gmail.com"; x-sender="arlencox@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-yw0-f171.google.com) identity=helo; client-ip=209.85.161.171; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="arlencox@gmail.com"; x-sender="postmaster@mail-yw0-f171.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0DPAADazaBXf6uhVdFdhBt8B7skIIV9AoE5BzsRAQEBAQEBAQERAQEJCwsJFzGCMhaCFwEFEhEdARQHHQEDDAYFCwMKAgImAgIhAQERAQUBHAYTCRIHh3QBAxcOowKBMj4xizuBaoJaBYZSChknDVSDQAEBAQEBAQQBAQEBARoCBhBxhSmDSoEDgkOCCYJ1gloFiCSQWzSMSgOCMo8/iCuEBYI4Eh6BDzSENiAyAYgwAQEB X-IPAS-Result: A0DPAADazaBXf6uhVdFdhBt8B7skIIV9AoE5BzsRAQEBAQEBAQERAQEJCwsJFzGCMhaCFwEFEhEdARQHHQEDDAYFCwMKAgImAgIhAQERAQUBHAYTCRIHh3QBAxcOowKBMj4xizuBaoJaBYZSChknDVSDQAEBAQEBAQQBAQEBARoCBhBxhSmDSoEDgkOCCYJ1gloFiCSQWzSMSgOCMo8/iCuEBYI4Eh6BDzSENiAyAYgwAQEB X-IronPort-AV: E=Sophos;i="5.28,461,1464645600"; d="scan'208";a="228796668" Received: from mail-yw0-f171.google.com ([209.85.161.171]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 02 Aug 2016 18:48:52 +0200 Received: by mail-yw0-f171.google.com with SMTP id r9so203529425ywg.0 for ; Tue, 02 Aug 2016 09:48:52 -0700 (PDT) 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 :cc; bh=BBSXY03Q14xXAP350y2nRBp7tX2gt4bSYJZ296Eh3lc=; b=cxaeAvdcj+a1gv6G6rCPBqlxg2U1376YATdiHqJmIN39jAfJSau5uRhnIPZPCRqksq SRuUSi7YL1G3lKHD2Qn3K12kIIZFxHJHwHIHyM7cz5Hxu7DjKgs/R4+iYYotEU1xSsHa jNt3gMgAwJTvSoxWjVXe9kSuiv2UaGG36ZbrIE7JvVXk3zql/BEShEUb6FSOvSmZirfl nxmGXisSaI678carZTBXiO1u4G2mcwOasJt8PQGu3wmxNf3cflXlCuZp59dw5/IN3MN0 IhegngcFxYbgWObw2lJapjLEO3B8UkNnwS8jZE4SYgOhzveoaI5gN1se7cpnp6wa0LCY 0adA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=BBSXY03Q14xXAP350y2nRBp7tX2gt4bSYJZ296Eh3lc=; b=E7ZGjA0KSV/CF8/3P6H4SpdKtW9wFISG8MCu6VVdZn9/Nj2VIkBMoScI31fUFTNqsS zC0/eNwDHjqTupiFONgxi6nqqr41ML5mc+cWJWbh23T3W7M+erm4A8co/yO2ZrDoQ+F2 IAotfXnM9LyOE6bNd7SYNaJAbS9OOetqokbyyz9/obqcwe9RzeoxyPEIfXWyoekiIFde nLgeVESAC+LcXDNAa8+6pEGq0/ye8bzul1ey6q9SwSgyPFkAxYd3YE2Gn6/ppKXm3YmE h9oDXsA6gc/fkeEv70h+ypxKmYnetMPpHwIvKIeeyLb1AL27Af2ocTiWLm22PROQPIML osaA== X-Gm-Message-State: AEkoouvSayaX0qWqEOgqC+NiC+K6990rNGIOWsTFsRQNT7H5zlIbZ8jVAJSxqSfvVTlCbt8gqxtCI9ngPRvAiw== X-Received: by 10.37.220.4 with SMTP id y4mr33851315ybe.150.1470156531094; Tue, 02 Aug 2016 09:48:51 -0700 (PDT) MIME-Version: 1.0 Received: by 10.129.117.136 with HTTP; Tue, 2 Aug 2016 09:48:50 -0700 (PDT) In-Reply-To: <1470155691.9343.12.camel@e130.lan.sumadev.de> References: <86a8gvjv6d.fsf@gmail.com> <1470155691.9343.12.camel@e130.lan.sumadev.de> From: Arlen Cox Date: Tue, 2 Aug 2016 12:48:50 -0400 Message-ID: To: Gerd Stolpmann Cc: caml-list@inria.fr Content-Type: text/plain; charset=UTF-8 Subject: Re: [Caml-list] Make OCaml library available to Java 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 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 wrote: >> > You could also make an executable written in Ocaml that communicates >> > over stdin/stdout. >> > >> > Arlen Cox 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 > ------------------------------------------------------------ >