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=AWL autolearn=disabled version=3.1.3 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 C9562BC6B for ; Tue, 9 Oct 2007 16:05:35 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ao8CAC4nC0fUnw7Vlmdsb2JhbACCN4wRAgEBBwQGEREH X-IronPort-AV: E=Sophos;i="4.21,249,1188770400"; d="scan'208";a="4264383" Received: from ptb-relay02.plus.net ([212.159.14.213]) by mail3-smtp-sop.national.inria.fr with ESMTP; 09 Oct 2007 16:05:35 +0200 Received: from [80.229.56.224] (helo=beast.local) by ptb-relay02.plus.net with esmtp (Exim) id 1IfFiI-0003vT-Ka for caml-list@yquem.inria.fr; Tue, 09 Oct 2007 15:05:34 +0100 From: Jon Harrop Organization: Flying Frog Consultancy Ltd. To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Correct way of programming a CGI script Date: Tue, 9 Oct 2007 14:56:37 +0100 User-Agent: KMail/1.9.7 References: <1191859489.10162.16.camel@localhost.localdomain> In-Reply-To: <1191859489.10162.16.camel@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200710091456.37798.jon@ffconsultancy.com> X-Spam: no; 0.00; gerd:01 stolpmann:01 ocaml:01 byte:01 ocaml:01 byte:01 arrays:01 solver:01 frog:98 wrote:01 caml-list:01 arithmetic:01 arithmetic:01 short:01 int:01 On Monday 08 October 2007 17:04:49 Gerd Stolpmann wrote: > > I heard that OCaml is particularly slow (and probably > > memory-inefficient) when it comes to string manipulation. What is the > > preferred way in handling strings (building long strings from short > > parts - something StringBuilder would be used in Java)? Does anybody > > have any experience concerning this kind of applications? > > No, this is nonsense... In this context, yes. In general, strings are not as efficient as the equivalent concrete data structure in C. Specifically, using strings as a byte array and applying arithmetic operations to the elements is significantly slower in OCaml than C. The only option you have in OCaml is to blow your memory wad and use an int array, which is fast but wastes enormous amounts of space and still has different modulo-arithmetic properties (you might want 8-bit for some apps). Consequently, OCaml is not very good for arithmetic operations over byte arrays. I discovered this on my Sudoku solver and revisited it with the Brainf*ck interpreter. This has never bitten me in practice though. Perhaps this is an issue for bioinformaticians or some image processing applications? -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/products/?e