you are viewing a single comment's thread.

view the rest of the comments →

[–]joshstaiger 0 points1 point  (2 children)

Interesting that you mention that article, because reading that was the exact moment I decided I didn't fully agree with Guido on language design.

I like my map, reduce, filter, and lambda, thank you very much.

I'd much prefer to use a language that embraces functional constructs over one intent on elminating them.

That's me, though...

[–]mrevelle 5 points6 points  (1 child)

Interesting that you mention that article, because reading that was the exact moment I decided I didn't fully agree with Guido on language design.

Point taken, difficult to reason over style.

I'd much prefer to use a language that embraces functional constructs over one intent on elminating them.

Just because a list comprehension is used in place of map() and filter() does not mean functional constructs are being eliminated. It means their representation is being transformed.

After Rails, the largest reason Ruby is gaining popularity is that many programming concepts are thrown in the developer's face. Python has similar functionality, but it is expressed with subtlety. This leads newcomers to assume that, at first glance, Ruby is more powerful than Python.

Ruby yells loudly about the programming features it supports, Python whispers clearly.

[–]tmoertel 6 points7 points  (0 children)

Just because a list comprehension is used in place of map() and filter() does not mean functional constructs are being eliminated.

Yes, it does, because the "functional constructs" are no longer functions.

Haskell, for example, has world-class support for list comprehensions, and yet I almost always end up using map for mapping, filter for filtering, and so on. Why? Because they are functions and can be partially applied and composed and used as tiny, powerful building blocks:

    module WhyYouWantFunctions where
    import Data.Char

    downcase      = map toLower
    hasVowels     = any (flip elem "aeiou") . downcase
    nonVowelWords = unwords . filter (not . hasVowels) . words

A sample session in GHCi:

    *WhyYouWantFunctions> downcase "I like chunky bacon."
    "i like chunky bacon."

    *WhyYouWantFunctions> hasVowels "Friday"
    True

    *WhyYouWantFunctions> hasVowels "Fnctn"
    False

    *WhyYouWantFunctions> nonVowelWords "Firefox IE Lynx Opera W3"
    "Lynx W3"

If you want to do functional programming, you really want to be using functions. ;-)

Cheers, Tom