[Haskell-cafe] I read somewhere that for 90% of a wide class of
computing problems, you only need 10% of the source code in Haskell,
that you would in an imperative language.
Alberto G. Corona
agocorona at gmail.com
Thu Oct 1 08:45:49 EDT 2009
2009/10/1 Curt Sampson <cjs at starling-software.com>
> On 2009-10-01 08:53 +0100 (Thu), Andrew Coppin wrote:
>
> > Sure. But what is a computer program? It's a *list of instructions* that
> > tells a computer *how to do something*.
>
> Some are. Some aren't, as proven by the Haskell definition of sum, which
> is certainly a "program."
>
> I like to think of a program as a specification. A list of instructions
> can certainly qualify, but so can other things, depending on what's
> interpreting and executing that specification.
>
>
Lets say that how to do a sum is pure abstract knowledge, and this
translates nicely to a declarative haskell sentence.
But to perform a sum of two concrete numbers is procedural, because either
the program or the compiler or yourself have to extract from the available
knowledge a sequence of steps in order to obtain a new knowledge, that is ,
the result.
In imperative languages the sequentiation is more explicit. in functional
languages this is more implicit, because the compiler+ runtime do the
sequentiation.
In fact, a C compiler also perform an automatic sequentiation for this
simple operation and generates a sequence of assembler code for either a sum
or any mathematical expression, but the haskell compiler is way more
powerful for extracting sequences of steps from declarative statements.
moreover, haskell promote a declarative style because laziness avoid to
express abstract knowledge as sequences. Referential transparency avoid also
dependencies of expressions from other expressions, and thus avoids
artificial sequencing.
however every time the program has to interact with the external world, even
for printing the result,, sequencing is necessary. That´s why the compilers
and interpreters exist!!!.
If the program has to interact many times with the external world in a given
sequence, the compiler can not guess such sequence if you don't write it
explicitly.
The perfect declarative haskell program has no main, no IO monad and no
executable.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091001/1fca004f/attachment.html
More information about the Haskell-Cafe
mailing list