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).

Peter.

Attachment: functions_as_values.tgz
Description: Binary data

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to