From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 240A5BC57 for ; Mon, 13 Dec 2010 14:07:33 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AnYBALupBU2GnQCBkWdsb2JhbACjfxUBAQEBCQsKBxEDJsFfhUoEhR6KdQ X-IronPort-AV: E=Sophos;i="4.59,335,1288566000"; d="scan'208";a="70396221" Received: from shiva.jussieu.fr ([134.157.0.129]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 13 Dec 2010 14:06:54 +0100 Received: from hydrogene.pps.jussieu.fr (hydrogene.pps.jussieu.fr [134.157.168.1]) by shiva.jussieu.fr (8.14.4/jtpda-5.4) with ESMTP id oBDD6skX054838 for ; Mon, 13 Dec 2010 14:06:54 +0100 (CET) X-Ids:164 Received: from strontium.pps.jussieu.fr (Debian-exim@strontium.pps.jussieu.fr [134.157.168.38]) by hydrogene.pps.jussieu.fr (8.13.4/jtpda-5.4) with ESMTP id oBDD6jN0031143 ; Mon, 13 Dec 2010 14:06:45 +0100 Received: from vouillon by strontium.pps.jussieu.fr with local (Exim 4.72) (envelope-from ) id 1PS873-0007D3-Hs; Mon, 13 Dec 2010 14:06:45 +0100 Date: Mon, 13 Dec 2010 14:06:45 +0100 From: Jerome Vouillon To: caml-list@yquem.inria.fr Subject: [ANN] Js_of_ocaml version 1.0 Message-ID: <20101213130645.GA27585@pps.jussieu.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-Miltered: at jchkmail.jussieu.fr with ID 4D061A6E.003 by Joe's j-chkmail (http : // j-chkmail dot ensmp dot fr)! X-j-chkmail-Enveloppe: 4D061A6E.003/134.157.168.1/hydrogene.pps.jussieu.fr/hydrogene.pps.jussieu.fr/ X-Spam: no; 0.00; vouillon:01 vouillon:01 ocaml:01 ocaml:01 compiler:01 bytecode:01 recompile:01 bindings:01 compiler:01 bytecode:01 ocaml-:01 lib:01 modular:01 integers:01 expansive:01 Hi, I'm happy to announce the first official release of Js_of_ocaml, a compiler from OCaml bytecode to Javascript. This tool let you write OCaml programs that run on Web browsers. Js_of_ocaml is easy to install, and use thereafter, as it works with an existing installation of OCaml, with no need to recompile any library. It comes with bindings for a large part of the browser APIs. The project page is: http://ocsigen.org/js_of_ocaml/ EXAMPLES The compiler has been used to implement some noteworthy examples, such as: - an interactive 3D view of the Earth http://ocsigen.org/js_of_ocaml/planet - a graph viewer http://ocsigen.org/js_of_ocaml/graph PERFORMANCES According to our benchmarks, with state of the art Javascript engines, the generated programs runs typically faster than with the OCaml bytecode interpreter ( http://ocsigen.org/js_of_ocaml/performances ). Js_of_ocaml performs dead code elimination in order to generate compact code: the Javascript file produced is usually smaller than the input bytecode file, and often much smaller. LINKS Project home page http://ocsigen.org/js_of_ocaml/ Download http://ocsigen.org/download/js_of_ocaml-1.0.tar.gz Get source code darcs get http://ocsigen.org/darcs/js_of_ocaml/ Documentation https://ocsigen.org/js_of_ocaml/lib/overview FURTHER TECHNICAL DETAILS Js_of_ocaml performs a fairly faithful translation. The order of evaluation is preserved. Modular arithmetic is used for integers (but with 32 bit integer). It does not support tail calls (function calls in tail position), as this would be too expansive. However tail recursion (self call in tail position) is properly optimized. Explicit coercion functions can be used to convert Ocaml values to Javascript values, and conversely (for instance, to map OCaml mutable strings to Javascript immutable UTF-16 strings, or to map OCaml booleans to Javascript booleans). A Camlp4 syntax extension makes it possible to invoke Javascript methods in a type safe way. COMPARISON TO OCAMLJS Ocamljs is a compiler from OCaml source code to Javascript. Jake Donham has written a fair comparison of the two tools: http://ambassadortothecomputers.blogspot.com/2010/08/ocamljs-03.html Ocamljs is a back-end to the existing OCaml compiler. Thus, contrary to Js_of_ocaml, you need to perform a distinct installation of OCaml to use Ocamljs, and you have to recompile all the libraries you may need. Ocamljs follows a different philosophy: it attempts to merge OCaml datatypes with the corresponding Javascript datatypes. For instance, OCaml objects are implemented as Javascript objects. Conversely, Javascript objects are given an OCaml object type. A mixed representation of strings is used: mutable OCaml-style strings and immutable Javascript strings both have the same type. All this is good for interoperability, but can be a source of incompatibilities and can result in runtime errors not caught by the type checker. Ocamljs optimizes tail recursion, but this comes at a large performance cost. -- Jerome Vouillon