[Haskell-cafe] Re: Why functional programming matters

Peter Hercek phercek at gmail.com
Wed Jan 23 17:16:06 EST 2008

Here are things I liked most (compared with standard imperative 
languages) when I started to learn functional programming:

* algebraic types with pattern matching work nicely as "tagged unions"; 
doing a tagged union manually in C/C++/C# is a pain (there is no 
automatic tag (provided you dismiss rtti over objects))

* lambda expressions, lexical scoping, closures; doing this in C++ is 
just incredible amount of typing; it is a bit better in C# but still not 
good enough
I happen to have nice examples of code like:
   map (\x->x*2) [1,2,3] -- but with an array
in C/C++/ML/C#. Each written as natively as possible. They are attached.

Other things did not seem that great for me from the beginning. For 
example: referential transparency - just enforces what you can take care 
not to do yourself (e.g. in C# you just cannot be sure some function is 
referentially transparent even when comment claims so - which of course 
sucks because programmers are not disciplined). Or another example: 
nontrivial higher order functions looked more damaging than helping 
because understanding usage/interactions is harder. Not mentioning 
monads (user level understanding of uniqueness typing with all the 
annotations is easier than monads).

I found ML/Clean/Haskell much more appealing than the common imperative 
languages an even Prolog (with which I could produce usably quick code 
only after actually using intimate knowledge of the inference and 
sprinkling cuts around, but that does not feel declarative to me any 
more then).

-------------- next part --------------
A non-text attachment was scrubbed...
Name: functions_as_values.tgz
Type: application/octet-stream
Size: 1432 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080123/739630da/functions_as_values.obj

More information about the Haskell-Cafe mailing list