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] productivity improvement
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-07-09 (18:20)
From: Shannon --jj Behrens <jjinux@y...>
Subject: Re: [Caml-list] productivity improvement
>     Oleg> What are the _simplest_ examples that
> demonstrate
>     Oleg> considerable (> 2:1) O'Caml vs C++
> productivity improvement
>     Oleg> (in terms of program size) and where can I
> find them?

I wrote a bunch of programs comparing several
languages using two different algorithms ("Simple" and
"Modcount") for finding primes.  Eventually, I hope to
throw these up on a Web page, but here is a summary of
the results:

    Source: 76 lines
    Binary: 5833 bytes
    Sample Run: 1.56 seconds
    Source: 63 lines
    Binary: 127264 bytes
    Sample Run: 1.63 seconds
    Source: 35 lines
    Binary: 138726 bytes
    Sample Run: 3.57 seconds
    Source: 28 lines
    Binary: 1629 bytes
    Sample Run: 13.6 seconds

    Source: 95 lines
    Binary: 6020 bytes
    Sample Run: 1.08 seconds
    Source: 83 lines
    Binary: 127391 bytes
    Sample Run: 1.35 seconds
    Source: 54 lines
    Binary: 139091 bytes
    Sample Run: 3.66 seconds
    Source: 44 lines
    Binary: 4054 bytes
    Sample Run: 91.8 seconds

Line counts do not include blank lines or comments.
Sample runs were calculated using "time ./executable
5000".  Ocaml programs where compiled using the native
compiler.  Python binary sizes were taken from .pyo's
which still require the Python interpretter.  My
friend did a Java version.  It required more lines of
code that OCAML, and was slightly slower.  I don't
have the exact numbers, so I haven't written them
here. :(

Here are some of the things that I learned:

1) C is the fastest (of course).
2) Python requires the fewest lines of code.
3) Ocaml provides (in my mind) the best ratio of
execution speed per lines of code.
4) I don't agree that having a higher level language
will often result in using better algorithms, which
compensate for the language overhead.

I have the code of the programs, if you wish.

Best Regards,

Do You Yahoo!?
Sign up for SBC Yahoo! Dial - First Month Free
To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: