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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 0ED617FF37 for ; Tue, 2 Aug 2016 13:51:15 +0200 (CEST) IronPort-PHdr: 9a23:WQYqVhBLV1by6P5ba3ZSUyQJP3N1i/DPJgcQr6AfoPdwSP75ocbcNUDSrc9gkEXOFd2CrakV06yJ4+u6ASQp2tWoiDg6aptCVhsI2409vjcLJ4q7M3D9N+PgdCcgHc5PBxdP9nC/NlVJSo6lPwWB6kO74TNaIBjjLw09fr2zQd+KyZvnnLrqs7ToICxwzAKnZr1zKBjk5S7wjeIxxbVYF6Aq1xHSqWFJcekFjUlhJFaUggqurpzopM0roGxsvKcq/stEFKH7ZLgQTLpCDT1gPXpmytfssEzqVw+C4DM3VXVexhNSBwXD5xbqdpj0uyr+8OF63X/JboXNUbkoVGH6vO9QQxjyhXJfOg== Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=arlencox@gmail.com; spf=Pass smtp.mailfrom=arlencox@gmail.com; spf=None smtp.helo=postmaster@mail-yw0-f179.google.com Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of arlencox@gmail.com) identity=pra; client-ip=209.85.161.179; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="arlencox@gmail.com"; x-sender="arlencox@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of arlencox@gmail.com designates 209.85.161.179 as permitted sender) identity=mailfrom; client-ip=209.85.161.179; receiver=mail3-smtp-sop.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 (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-yw0-f179.google.com) identity=helo; client-ip=209.85.161.179; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="arlencox@gmail.com"; x-sender="postmaster@mail-yw0-f179.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0DGAAAdiKBXhrOhVdFchRcHuSKBfYYdAoEyBzoSAQEBAQEBAQERAQEBCAsLCRkvgjIWghcBBRIRHQEbHgMMBgULDQICJgICIQEBEQEFARwZGweHdAEDF6JjgTI+MYs7gWqCWgWGUAoZJw1Ug0ABCx0CBhBxhSmETYJDgkmCNYJaBZh/NIxKgjWPP4grhAWCOBIegQ8lBoJMgXMgMogXAQEB X-IPAS-Result: A0DGAAAdiKBXhrOhVdFchRcHuSKBfYYdAoEyBzoSAQEBAQEBAQERAQEBCAsLCRkvgjIWghcBBRIRHQEbHgMMBgULDQICJgICIQEBEQEFARwZGweHdAEDF6JjgTI+MYs7gWqCWgWGUAoZJw1Ug0ABCx0CBhBxhSmETYJDgkmCNYJaBZh/NIxKgjWPP4grhAWCOBIegQ8lBoJMgXMgMogXAQEB X-IronPort-AV: E=Sophos;i="5.28,460,1464645600"; d="scan'208";a="186665559" Received: from mail-yw0-f179.google.com ([209.85.161.179]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 02 Aug 2016 13:51:14 +0200 Received: by mail-yw0-f179.google.com with SMTP id r9so195936032ywg.0 for ; Tue, 02 Aug 2016 04:51:14 -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; bh=4RxSxphPOF4sWYmq7yJxxz7Dr8HtxMWsXQdcALnwQ6U=; b=Xj2rgCfjGkQftomde2m4sF1QjMMLHGKwWsxcTsrx1YErpPqGPwS0bnIItNEVPD2Ape VyRZKohc119zhLzCMhOZDj1CM2cerWKGtvI9tfzENAycBQKEN16YcVnZnk7bKnx7png5 +jp2quFgPH8kAXBFN6VRs1jyJYx0hMBj/t3eM6S4zZUcpRu39aBq2YDZZ0sHIQUT2FSE ljIgCWREnUsJfTdtZ6PiOXgThBM6dlKJR1FNo9vLCwcXMJQxcL6fOsDi0wQdFRqRVuvw IGyjsS/1CKHUiMOaEBQjC1asqMvR3HogSFKKxhmSxdstpo3XhtQiIIA60AUg5LGMTliO ulHA== 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; bh=4RxSxphPOF4sWYmq7yJxxz7Dr8HtxMWsXQdcALnwQ6U=; b=iJONXS7o8gyAeouscfIrRzY+hIZMXeF4SNtU/GClp7ZG1KldIA8xO6/b502JTmrz4F IGwkZRCMbvTk98J1Jd4YKAgFc4R0yvOYpG4ztj8Iaum6sE0f+hoof7INt4EfV0JSN9Oq CCiM2lZN8m9rDRTw/WYa1Od2fYnxyzRQeTuB0yAkNzsvWQazPT8c+A0sRb4wZo2amzHw DsBloXJzKtidAnEYafZN0VuERnifYiOL9c649jQP85+1eAlxvPjai5uz08GkG9E2AtrB IErNCdXp4jwxHzBis4hUEtXLtW1yi60oOF3+wU18bZXZvLM3hjQDbBWYd0MCAwfOeLGv n2Tg== X-Gm-Message-State: AEkooutPMtOAr08Eg4sUzdOaUfJzx57ZAX2B3senOMMHtDPFTxxtYXaa3+cXA2/b7XWDk2u/Jka/OQQftWRtFg== X-Received: by 10.129.108.203 with SMTP id h194mr53610850ywc.273.1470138672326; Tue, 02 Aug 2016 04:51:12 -0700 (PDT) MIME-Version: 1.0 Received: by 10.129.117.136 with HTTP; Tue, 2 Aug 2016 04:51:11 -0700 (PDT) In-Reply-To: <86a8gvjv6d.fsf@gmail.com> References: <86a8gvjv6d.fsf@gmail.com> From: Arlen Cox Date: Tue, 2 Aug 2016 07:51:11 -0400 Message-ID: To: caml-list@inria.fr Content-Type: text/plain; charset=UTF-8 Subject: Re: [Caml-list] Make OCaml library available to Java 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 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