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

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Basile STARYNKEVITCH <basile@s...>
Subject: Re: [Caml-list] help
On Thu, Apr 08, 2004 at 10:57:26PM +0000, mohammad siddiqui wrote:

> I am new to OCAML. I Just started learning. I need to convert the
> source code of an application which runs in 4000 lines from C to

You didn't tell use what kind of application is it... 

> Can anyone help me how to get started?

I tend to believe that such a conversion is primarily a waste of
time.... And more importantly, if you convert blindly, you will get
ugly (and hardly maintainable) Ocaml code. You'll probably get an
Ocaml program as big as the original C source.

A more practical alternative might be to consider your lower C
routines as building blocks, ie to interface each of your (few) lower
C routines to Ocaml, and to recode the higher part of the application
in Ocaml.

You could also try to implement the same algorithms in Ocaml.

For completeness, you could translate your C code into an ugly,
unmaintainable Ocaml mess using references for C variables and mutable
fields all over the place. But the code will be shameful and you won't
learn anything doing it.

I strongly suggest - if you want to learn Ocaml :

  first, to learn to code thru some basic (100 lines) programs -
  learning how to use tail recursion and avoiding mutable data (and more
  generally limiting side effects).

  then, reimplement your 4000 C line program, starting from a
  highlevel abstract view of the algorithm (not from the C source);
  I'll bet you should get an Ocaml program smaller than 2000 lines.

  There are many interesting books & online resources to learn Ocaml.

Starting by translating a C program into any better language is a bad way
to learn this better language (whatever the better language is).


email: basile<at>starynkevitch<dot>net 
aliases: basile<at>tunes<dot>org = bstarynk<at>nerim<dot>net
8, rue de la Faïencerie, 92340 Bourg La Reine, France

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