Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: [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: -- (:)
From: Eray Ozkural <erayo@c...>
Subject: Re: [Caml-list] productivity improvement
On Friday 19 July 2002 14:10, Xavier Leroy wrote:
> > Determine Dr. Leroy's involvement in JFK assassination 180
>
> Should take less time than this, given that I wasn't born at that time :-)
>
> As everyone else, I'll point out that your code can be shortened and
> made more readable by judicious use of printf and regexps (see below).
> But really, if this is the kind of programs you're interested in
> (text-based I/O with no data structures), forget about C++ and Caml,
> and use Perl.
>

Definitely so.

Also "portage" from C/C++ cannot automatically result in a productivity 
enhancement for obvious reasons. A straightforward port will preserve
the painstaking style of those languages.

For truly enhancing the quality of code the first step I take is to design
the program to benefit from the higher level of abstraction and modularity
modern functional languages provide for.

Especially using generic data types work very well. In ocaml you can really 
write algorithms that work on generic structures, which is good for cutting 
down code size and getting to the point. Using the module system, one can 
clearly decompose the code into interfaces and implementations...

For instance in a stock market prediction code I have been working on, it took 
no more than a couple of days to rewrite a large portion of the code in 
Haskell that was previously written in C. The resulting code was 
significantly shorter and more modular; allowing me to play with new 
algorithms / metrics easily. The same would not be the case with C++. (The 
code isn't too Haskell specific and could be done as well in ocaml)

That code I think went down from about 2500 lines to 500 lines which isn't 
bad. To attain that kind of improvement, you need a change in style. The C 
program apparently used lots of text I/O to transfer and store data between
modules. The Haskell program didn't have to.

It is also true that it is not correct to expect such improvements in code 
that is too simple. If all you want to do is to sum over an array of 
integers, you can do it in C easily.

-- 
Eray Ozkural <erayo@cs.bilkent.edu.tr>
Comp. Sci. Dept., Bilkent University, Ankara
www: http://www.cs.bilkent.edu.tr/~erayo
GPG public key fingerprint: 360C 852F 88B0 A745 F31B  EA0F 7C07 AE16 874D 539C
-------------------
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