Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion Why use a functional language?
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
STARYNKEVITCH Basile  
View profile  
 More options Feb 17 2000, 3:00 am
Newsgroups: comp.lang.functional
From: STARYNKEVITCH Basile <Basile.Starynkevi...@cea.fr>
Date: 2000/02/17
Subject: Re: Why use a functional language?

>>>>> "Kevin" == Kevin Hostelley <hostell...@firstenergycorp.com> writes:

    Kevin> When I was doing procedural programming, and OOP was coming
    Kevin> into vogue, I heard all sorts of reasons why you should
    Kevin> switch (code reusability, easier to maintain, etc.).  Are
    Kevin> there similar or additional benefits to functional
    Kevin> programming?  

I have some significant experience (and expertise) with Ocaml, but I
am still coding in C++ (this is going to change) because I am required
to do so. I did look into Haskell but didn't code in it.

First, as an important remark, object-oriented programming (be it C++,
Java, or Self or CLOS) is well suited for simulation of real objects
(e.g. in a MonteCarlo-like trafic jam simulation, it is natural to
code with car objects representing physical automobile cars). But not
all programming is isomorphic to simulating a world with objects
having each a mutable state (and in some domains OO style is the wrong
answer)

Functional programming (at least in Ocaml or SML, ie. staticly typed
eager functional langages) gives some benefit because:

0. An efficient garbage collector is very useful (and GC is not equal
   to Java, many Java implementations have poor GCs, because of Java
   languages pecularities (finalizers, etc)). Current GC technlogy is
   quite mature.

1. coding in Ocaml is much more dense that the same code in C or Java,
   because you combine a lot many small functions and types. I think
   that a problem coded in Ocaml has at least 2 times less source code
   lines than the same problem coded in C+. Of course, the programmer
   has to master the language (Ocaml vs C++), the programming style
   (functional+object oriented vs imperative+OO), and the library.

2. Current functional language compilers are quite good (performance
   is at worse 2 or 3 times slower than C, and sometimes a bit faster
   than C). I believe that new hardware archtecture will benefit even
   more from functional style (and new chips are less and less suited
   to C) but I am definitely not a hardware expert.a

3. Type inference is very powerful. The compiler -in practice- find a
   lot of tiny stupid bugs that a C++ compiler can't find. And its
   avoid being verbous. You don't have to tell things twice (eg
   declare a variable with its type and initialize it [the
   initialisation is enough for the compiler to infer the type]) or
   declare a class interface and then implement it (although you do
   give in Ocaml modules interfaces and implementations)

4. Ocaml and other functional languages have useful features (pattern
   matching, anonymous functions) that are of great benifit to the
   coder. In particular, extending a union (or sum or variant) type is
   much more easy in Ocaml than in C.

5. Ocaml modules and functions are much more powerful than C++
   templates, and are easily compiled.

6. When (and only when) inheritance, the Ocaml class system is
   available and useful.

7. Compiler technlogy for functional language is a hot subject.

The current weaknesses of Ocaml and other functional languages are:

* lack of several competing implementations

* some (very often overestimated) inefficiency. It is still true that
  some numerical loops are faster in C than in Ocaml. But the converse
  may also be true (some programs run faster in Ocaml than in C). But
  shorter time to market and smaller programmer costs should dwarf the
  small performance loss.

* lack of libraries and 3rd parties tools.

* lack of well known software methodologies (although UML is very
  oversold)

There may be some projects that are going into the wall because of
languages issues. Sometimes, choosing C++ or Java is the wrong way. I
assume of course availability of competent programmers (but learning
Ocaml when starting from C is a lot easier than learning C++ from C).

See also the Ocaml web pages (and mailing list archive)
"http://caml.inria.fr/ocaml/"

N.B. Any opinions expressed here are only mine, and not of my organization.
N.B. Les opinions exprimees ici me sont personnelles et n engagent pas le CEA.

---------------------------------------------------------------------
Basile STARYNKEVITCH   ----  Commissariat à l Energie Atomique
DTA/LETI/DEIN/SLA * CEA/Saclay b.528 (p111f) * 91191 GIF/YVETTE CEDEX * France
phone: 1,69.08.60.55; fax: 1.69.08.83.95 home: 1,46.65.45.53
email: Basile point Starynkevitch at cea point fr


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google