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 mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 0144EBBAF for ; Wed, 24 Nov 2010 10:05:00 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AiYDAEdk7EyGnQCBcmdsb2JhbACidRYMCAsJEQMfvHKFTAQ X-IronPort-AV: E=Sophos;i="4.59,247,1288566000"; d="scan'208";a="89235885" Received: from shiva.jussieu.fr ([134.157.0.129]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 24 Nov 2010 10:05:00 +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 oAO94s54013357 ; Wed, 24 Nov 2010 10:04:55 +0100 (CET) X-Ids:165 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 oAO94kGF019699 ; Wed, 24 Nov 2010 10:04:46 +0100 Received: from vouillon by strontium.pps.jussieu.fr with local (Exim 4.72) (envelope-from ) id 1PLBHS-00043W-Do; Wed, 24 Nov 2010 10:04:46 +0100 Date: Wed, 24 Nov 2010 10:04:46 +0100 From: Jerome Vouillon To: Alain Frisch Cc: caml-list@yquem.inria.fr Subject: Compiling to Javascript Message-ID: <20101124090446.GA15560@pps.jussieu.fr> References: <980786.74593.qm@web111507.mail.gq1.yahoo.com> <4CECBCCD.4000609@frisch.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4CECBCCD.4000609@frisch.fr> User-Agent: Mutt/1.5.20 (2009-06-14) X-Miltered: at jchkmail.jussieu.fr with ID 4CECD536.00F by Joe's j-chkmail (http : // j-chkmail dot ensmp dot fr)! X-j-chkmail-Enveloppe: 4CECD536.00F/134.157.168.1/hydrogene.pps.jussieu.fr/hydrogene.pps.jussieu.fr/ X-Spam: no; 0.00; vouillon:01 vouillon:01 0100,:01 frisch:01 compiler:01 ocaml:01 bytecode:01 ocaml:01 compiler:01 javascript:98 javascript:98 wrote:01 wrote:01 jerome:01 jerome:01 On Wed, Nov 24, 2010 at 08:20:45AM +0100, Alain Frisch wrote: > On 11/19/2010 8:46 PM, Dario Teixeira wrote: > >Actually, Facebook has a compiler that transforms PHP source code into C++ [1], > >and they claim a 50% reduction in CPU usage. > > I haven't looked into this project, but I've a hard time believing > this is a better approach than compiling PHP to Javascript. The > translation would probably produce quite idiomatic Javascript code > on which modern > interpreters do an amazing job (and they keep improving). I'm not so sure about that. For instance, PHP has complex implicit conversion rules which are not the same as Javascript rules. These would have to be made explicit, at a high cost. The calling convention is likely to be different too. On the other hand, OCaml compiles well to Javascript. We experience performances comparable to those of the bytecode interpreter with Js_of_ocaml, our compiler ( http://ocsigen.org/js_of_ocaml/ ). (I should really make an official release soon...) -- Jerome