English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Correct way of programming a CGI script
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-10-09 (14:05)
From: Jon Harrop <jon@f...>
Subject: Re: [Caml-list] Correct way of programming a CGI script
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 

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 

Dr Jon D Harrop, Flying Frog Consultancy Ltd.