[Haskell-cafe] Re: Re: Haskell and scripting
Maciej Piechotka
uzytkownik2 at gmail.com
Thu May 6 13:36:26 EDT 2010
On Wed, 2010-05-05 at 17:18 -0400, Kyle Murphy wrote:
> Concerning your second point, I think just about any functional
> language isn't going to be simple or quick to learn. It's simply not a
> way of approaching problems that your average person (even your
> average programmer) is used to dealing with. Things like fold and map,
> the work horses of functional programming, are simply too foreign to
> most peoples imperative way of approaching problems.
>
> -R. Kyle Murphy
Sorry - I wanted to respond to many posts in this thread but I choose
the first post:
1. While doing fold/map may not be what is simple for average programmer
I guess pattern matching/some HL functions can be relatively simple for
others (pureness on the other hand do not). For example average person
thinks "Add 1 to each element of list".
Imperative way:
for i = 0 to l.length:
l[i] = l[i] + 1 # WTF? There is no x such that x = x + 1
Functional way:
callOnEvery _ [] = []
callOnEvery f (x:xs) = f x:xs -- Built-in function 'map'
-- Name could be 'better'
add1 x = x + 1
add1ToEachElement xs = callOnEvery add1 xs
Please note that I heard about person who wrote 'awesome game' in .exe
file (definitely _declarative_ style of programming ;) ) and expected it
to run ;) [Although fortunately it was 'hobbiest'].
2. Lisp readability depends much on formatting. While I cannot write
LISP I'm usually able to read it)
(defun hello-world ()
(format t "hello, world"))
Is a merge between:
def hello_world():
print "hello, world"
and
void hello_world() {
println("hello, world")
}
Of course you can write obfuscation competition entries in LISP.
3. For the list of universities that first teaches functional
programming - ICL begins with Haskell and from non-imperative languages
Prolog is in the first year curriculum.
Regards
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100506/f5079da3/attachment.bin
More information about the Haskell-Cafe
mailing list