Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Efficiency of 'a list
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-05-04 (06:46)
From: Mattias Waldau <mattias.waldau@a...>
Subject: [Caml-list] Two types of efficiency (Was Efficiency of 'a list)
> I've done a little timing of things, and according to my 
> results: If you care about efficiency and use OCaml, you 
> should use lists 
> fairly often, ie if you are always looping and accessing the 
> elements in order. OCaml can iterate through a list 

We are talking about two kinds of efficiency:
1. Absolute speed for mostly small benchmarks
2. Scalable programs, i.e. they work fine for input of length 100, 
   but goes on forever for input of length 1000.

Scalability is the one that I am talking about, and is the one that 
mostly gets bitten by inappropriate use of lists. For me scalability 
is the most important.

If you use Map/Hash/Set small benchmarks will be slower, however your
programs are more likely to be scalable. 

Languages like PHP have more advanced built-in datastructures with
language syntax to support them. In Ocaml, we can create the same
program, however, there is no syntax support, and we have to add
declarations like

module StringSet = Set.Make(struct 
      type t = string
      let compare = compare
    end) ;;

It would be nice if the typechecker could deduce the type of the set and
add the above declaration automatically to the program. That would make
it easier for beginners to use the advanced datastructures of Ocaml.


To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: