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
speed versus C
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 1999-10-06 (14:22)
From: Jens Olsson <jenso@c...>
Subject: Reply to: speed versus C

On Sun, 3 October 1999 Jan Brosius ( wrote:
>Hi, is there anything known about the efficiency of compiled Ocaml code
>compared with C/C++

I'm very interested in this as well. I've made a small program to test
this, namely a ray tracer. Ray tracing as a problem is quite suitable
for functional programming languages and as I have written one in C
too; I wanted to compare. I've now written yet another one in
Ocaml. I'm not entirely finished but my preliminary testing shows
that the tracer written in ML can be not more than 30%-50% slower than
the C version. The C version used to compare with is quite optimized
using various compiler flags and other tricks but they are quite
similar in an algorithmic point of view.

My Ml tracer is written in a quite naive manner (with more concern on
abstractions than speed) so it may/should be possible to speed it up
more. My intention is to 'release' it in order to encourage people to
come with suggestions on how to make it faster and better.

Ok, enough about that. As an answer to your question; Ocaml is *fast*
and by selecting problems suitable for functional languages and by
taking advantage of the features given by them one can get equally
fast or even faster programs than corresponding C programs. I'd love
to have a working example to show any person in doubt and it is my
intention to make one.


Jens Olsson

--[ Jens Olsson ]-----------------------------------------------------
  [Address]            [Phone]                 [WWW]
  Djäknegatan 13, 1tr  Home: 018 -  24 88 77     
  754 23 Uppsala       Work: 018 - 471 76 85
  SWEDEN               Cell: CEASED!!!         ICQ UID 8955231
---------------------------------[ CS student @ Uppsala University ]--