Thread: ocaml and C

  1. #1
    Dump Truck Internet valis's Avatar
    Join Date
    Jul 2005
    Posts
    357

    ocaml and C

    I have read a lot of different places that ocaml is very fast, even faster than C, but it's always a stupid "yes-no I have no evidence" argument that doesn't expand anyone's knowledge. I have searched around the web and actual benchmarks I find, C always (edit: more searching = almost always actually) wins; am I looking in the wrong place or what?

    Obviously specific languages will never be better in every possible situation, can anyone show me some places where ocaml is faster (source provided please, I am ocaml literate), or give theoretical arguments about why ocaml should be faster in situation X?
    Last edited by valis; 10-04-2005 at 10:48 PM.

  2. #2
    Registered User Jaqui's Avatar
    Join Date
    Feb 2005
    Posts
    416
    To answer the real question:
    is OCAML faster than C?
    that would depend on the code itself, as well as compiler options.
    both are low level languages, with support for direct hardware control.
    so it would really depend on how the application was written as to which is faster.

    it really is a matter of how the tool was coded, rather than which will produce faster executables. unlike interpreted vs compiled, with 2 compiled languages it's all in the actual code used.
    Quote Originally Posted by Jeff Henager
    If the average user can put a CD in and boot the system and follow the prompts, he can install and use Linux. If he can't do that simple task, he doesn't need to be around technology.

  3. #3
    Dump Truck Internet valis's Avatar
    Join Date
    Jul 2005
    Posts
    357
    Sorry I wasn't more specific, assuming a single algorithm is written in C and ocaml, compiled for ia-32 and run a lot of times, which will perform better. From statistics I have seen thus far, C compilers seem to be better with the instruction set.
    For example a mul and an add will be much slower than a lea (when that's possible) and a cmovz will be faster than a jnz (to jump over a mov).

    edit: also I see ocaml brag about its recursion.

Popular pages Recent additions subscribe to a feed