From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id IAA15393; Fri, 9 Apr 2004 08:56:26 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id IAA15353 for ; Fri, 9 Apr 2004 08:56:25 +0200 (MET DST) Received: from kraid.nerim.net (smtp-105-friday.nerim.net [62.4.16.105]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i396uOYM019566 for ; Fri, 9 Apr 2004 08:56:24 +0200 Received: from hector.lesours (ours.starynkevitch.net [213.41.130.15]) by kraid.nerim.net (Postfix) with ESMTP id CE98A41AAF; Fri, 9 Apr 2004 08:56:23 +0200 (CEST) Received: from basile by hector.lesours with local (Exim 4.31) id 1BBpw7-0005Fq-CN; Fri, 09 Apr 2004 08:56:23 +0200 Date: Fri, 9 Apr 2004 08:56:23 +0200 To: mohammad siddiqui , caml-list@inria.fr Subject: Re: [Caml-list] help Message-ID: <20040409065623.GA19890@ours.starynkevitch.net> References: Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.5.1+cvs20040105i From: Basile STARYNKEVITCH X-Miltered: at concorde by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 basile:01 basile:01 2004:99 recursion:01 avoiding:01 faiencerie:01 92340:01 reine:01 nerim:01 tunes:01 ocaml:01 ocaml:01 mutable:01 mutable:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk X-Status: X-Keywords: X-UID: 198 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 > OCAML. 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). Regards. -- Basile STARYNKEVITCH http://starynkevitch.net/Basile/ email: basilestarynkevitchnet aliases: basiletunesorg = bstarynknerimnet 8, rue de la Faïencerie, 92340 Bourg La Reine, France ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners