From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 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 013FBBB84 for ; Thu, 9 Oct 2008 23:48:01 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ai0DAPQY7kjAXQImiGdsb2JhbACBcpFnAQEBFSKrb4Fq X-IronPort-AV: E=Sophos;i="4.33,385,1220220000"; d="scan'208";a="17871824" Received: from discorde.inria.fr ([192.93.2.38]) by mail3-smtp-sop.national.inria.fr with ESMTP; 09 Oct 2008 23:48:01 +0200 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id m99Lm16j016319 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Thu, 9 Oct 2008 23:48:01 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsgCAMQY7khDWxLCYGdsb2JhbACBcpFdHiqre4Fq X-IronPort-AV: E=Sophos;i="4.33,385,1220220000"; d="scan'208";a="15871503" Received: from ip67-91-18-194.z18-91-67.customer.algx.net (HELO server1.bertec.net) ([67.91.18.194]) by mail2-smtp-roc.national.inria.fr with ESMTP; 09 Oct 2008 23:48:00 +0200 Received: from kuba.bertec.net (kuba.bertec.net [192.168.2.16]) by server1.bertec.net (Postfix) with ESMTP id 2B060105761 for ; Thu, 9 Oct 2008 17:48:00 -0400 (EDT) From: Kuba Ober To: caml-list@inria.fr Subject: Re: [Caml-list] - Convert Caml to C/C++, C#, PHP, etc - Date: Thu, 9 Oct 2008 17:47:58 -0400 User-Agent: KMail/1.9.10 References: <19791755.post@talk.nabble.com> <19792384.post@talk.nabble.com> <20081003153921.9bc91e12.mle+ocaml@mega-nerd.com> In-Reply-To: <20081003153921.9bc91e12.mle+ocaml@mega-nerd.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200810091747.59342.kuba@mareimbrium.org> X-Miltered: at discorde with ID 48EE7C11.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; compiler:01 ocaml:01 compiler:01 ocaml:01 bytecode:01 bytecode:01 higher-level:01 cheers:01 wrote:01 wrote:01 compilers:01 caml-list:01 caml:02 output:02 output:02 On Friday 03 October 2008, Erik de Castro Lopo wrote: > axllaruse wrote: > > I would like to convert all the MTASC open source project to > > C/C++ or PHP. > > Sorry, but you're crazy. > > MTASC is a compiler and compilers are one of the tasks that > Ocaml does better that all of the languages you mention. > > Converting the MTASC compiler to a less capable language (yes, C++ > is less capable) would be an exercise in extreme Greenspunning: Um, since Ocaml can be compiled to bytecode and said bytecode executed by an interpreter written in C, that's sorta-kinda el-cheapo conversion right there. One can work backwards. 1. Get the bytecode compiler to output C that resembles what would be called in the interpreter loop. That still uses all of the interpreter's innards, just removes the interpreter loop. 2. Tweak the bytecode compiler to output higher-level C stuff where applicable. That way you can get C that looks more like C and less like bytecode-primitives-called-in-C. (2) is probably the hard part as it involves sweeping modifications to the compiler. (1) is easy, you can do it on raw bytecode without touching the compiler, although it'd be a good exercise to get to know the compiler. Side note: is there an Ocaml bytecode-compiler written in Ocaml somewhere? It'd be easier to work on than said compiler written in C/C++. Cheers, Kuba