Version française
Home     About     Download     Resources     Contact us    
Browse thread
How to do this properly with OCaml?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jon Harrop <jon@f...>
Subject: Re: [Caml-list] Games
On Thursday 28 July 2005 22:32, David Thomas wrote:
> --- Jon Harrop <jon@ffconsultancy.com> wrote:
> > Many games now use quite sophisticated LOD algorithms
> > and OCaml is vastly better suited to this than C++.
>
> I'm probably missing something obvious, but... why?

Essentially, OCaml is much better suited to the manipulation of complicated 
data structures like trees and graphs than C++. In particular, it is much 
easier to write such code correctly in OCaml than in C++.

As games have evolved, their emphasis has moved from blitting to simulating 
the interactions of complicated hierarchical systems in real time. For 
example, the transition from (array-based) sprites to (tree- or graph-based) 
LOD polygonal models in the presence of collision detection.

Similarly, as scientific computing has evolved, emphasis has moved from 
vector/matrix calculations to the hierarchical simulation of physical systems 
(not in real time!). For example, use of the (tree-based) Fast Multipole 
Method (FMM) instead of (array-based) Ewald summation when computing 
long-range interactions between particles.

This is easily explained with a little computer science: We're now close 
enough to the asymptote that asymptotic algorithmic complexity has become 
more important than the constant prefactor. We know that trees, graphs and 
many other non-trivial data structures facilitate common operations (e.g. 
search, insert, replace) with considerably better asymptotic complexities 
(e.g. O(log n) instead of O(n)). So we're ditching arrays in favour of trees 
and graphs and, consequently, we should be ditching C++ in favour of OCaml.

This is exactly the topic of my book "Objective CAML for Scientists". Hence, I 
think I'm a suitable candidate for writing "Objective CAML for Games". :-)

-- 
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
Objective CAML for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists