From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 93315BC88 for ; Mon, 7 Feb 2005 02:54:37 +0100 (CET) Received: from smtp1.adl2.internode.on.net (smtp1.adl2.internode.on.net [203.16.214.181]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j171sZb5031331 for ; Mon, 7 Feb 2005 02:54:36 +0100 Received: from [192.168.1.200] (ppp212-197.lns2.syd3.internode.on.net [203.122.212.197]) by smtp1.adl2.internode.on.net (8.12.9/8.12.9) with ESMTP id j171sSjv020749; Mon, 7 Feb 2005 12:24:29 +1030 (CST) Subject: Re: [Caml-list] The boon of static type checking From: skaller Reply-To: skaller@users.sourceforge.net To: Jon Cc: caml-list@yquem.inria.fr In-Reply-To: References: <891bd33905020213315a2ebb18@mail.gmail.com> <7f8e92aa0502060222383aac60@mail.gmail.com> Content-Type: text/plain Organization: Message-Id: <1107741266.6363.362.camel@pelican.wigram> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 07 Feb 2005 12:54:27 +1100 Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 4206CA5B.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 sourceforge:01 wrote:01 wrote:01 stl:01 stl:01 ocamlopt:01 imho:01 garbage:01 ocaml:01 ocaml:01 unboxing:01 compilation:01 optimising:01 closures:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: On Mon, 2005-02-07 at 04:28, Jon wrote: > On Feb 6 2005, Radu Grigore wrote: > > On Fri, 4 Feb 2005 10:26:55 +0000, Jon Harrop wrote: > > > The code to implement a simple tree is unwieldy in C++ (e.g. 1975 LOC > > > in stl_tree.h and stl_map.h vs 198 LOC in map.ml). > > > > The implementation in stl_tree is not a "simple" tree. The difference > > in size is also because the STL implementation is more efficient. > > This is a much smaller effect compared to the verbosity imposed by inherent > inefficiencies of the C++ language though. Curious what you think those are. g++ seems to generate better code than ocamlopt for similar simple problems (see Alioth for quantitative evidence given silly set of sample 'problems') IMHO the single major inefficiency in C++ is also a source of efficiency -- lack of a garbage collector. OTOH Ocaml has a massive inefficiency C++ does not, namely boxing, and ocaml tools currently do not seem to be very good at unboxing. Ocaml tools do much better with tail calls than g++, but I don't see that this is an intrinsic fault in C++: the 'callee pops arguments' gets in the way with separate compilation, but not for inline functions. Again, C++ provides inline functions which provide a way Ocaml does not have so easily for optimising. Felix is a C++ code generatore which provides many of the features of C++ which are clumbsy to encode such as sum types and closures, does tail call optimisation, and also provides a garbage collector. It currently appears to outperform the ocaml bytecode interpreter, whereas the x86 native code compiler ocamlopt generates faster code on average. It is hard to say that Felix code 'is faster than C++' given it actually generates it. So I'm quite interested in what inefficiencies C++ might have compared to ocaml -- feel free to identify not only 'intrinsic' inefficiency of the languages, but also problems in the compilation models, and difficulties in generating good code that are not necessarily intrinsic. (EG I would like to hear a comment that tail-rec optimisation whilst not 'intrinsically impossible' in C++ is hard to do, if that is your belief) One further comment: Ocaml and C++ share a serious impediement to efficiency -- eager evaluation. In fact lazy evaluation can also be inefficient. Which is why Felix is moving towards an 'unspecified evaluation' strategy. In fact the optimiser already assumes purity/termination, there's a way to enforce eagerness, but I have no way to enforce laziness at the moment :( -- John Skaller, mailto:skaller@users.sf.net voice: 061-2-9660-0850, snail: PO BOX 401 Glebe NSW 2037 Australia Checkout the Felix programming language http://felix.sf.net