Page 1 of 4 123 ... LastLast
Results 1 to 10 of 31

Thread: Learning Haskell

  1. #1
    Join Date
    May 2007
    Location
    USA
    Posts
    373
    Thanks
    2
    Thanked 4 Times in 4 Posts

    Default Learning Haskell

    I'm interested in learning the programming language Haskell simply because it looks interesting.

    I have a few questions regarding it:

    1) What are good tutorials for Haskell?
    2) Or better yet, is there another functional language I should learn in favor of Haskell?
    3) Is functional programming radically different from imperative programming?
    4) What IDE should I use? An Eclipse plugin perhaps? Notepad?
    Trinithis

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    1. http://www.haskell.org/tutorial/
    2. I prefer Lisp for practical application. Haskell is a beautiful language from a computer science point of view, and it's certainly fun to work with, but I find it somewhat more difficult than necessary for a lot of tasks which, let's face it, require state to represent properly. Lisp is often described as a "semi-functional" language: it's primarily functional, and supports all the operations one expects in a functional language, but it allows other paradigms as well (it supports a very powerful class-based object orientation system, for example, superior to that of any other language of which I'm aware, as well as allowing functions to have side effects and letting the programmer specify order of execution, in the manner of an imperative language).

      I certainly don't mean to discourage you from learning Haskell, though: it is a lovely language, and definitely worth learning, especially if you're doing so for curiosity.
    3. Not necessarily, although it can be sometimes. You may not be aware, but Javascript is a fully functional functional language, and there's a library to implement some of the common extras often found in such languages in Javascript. The most obvious difference between a (purely) functional and an imperative language is that no data is stored. So, for example, in C one might write:
      Code:
      int mod_num(int n) {
        int nn = n;
        nn *= 5;
        nn += 3;
        return nn; 
      }
      However, this can be simplified:
      Code:
      int mod_num(int n) {
        return n * 5 + 3;
      }
      And in Haskell:
      Code:
      mod_num :: Int -> Int
      mod_num n = n * 5 + 3
      Lisp:
      Code:
      (defun mod-num (n)
        (+ 3 (* 5 n)))
      This is obviously a very simple example, but in the real world it gets complex (think of input and output, for example). Haskell has several clever ways around the necessity to store state, such as monads, which you'll come to in good time.

      The other defining feature of functional languages is that one can modify and pass around functions as if they were any other data type, but you're probably familiar with this from Javascript. C's function pointers are a similar concept.

      I seem to remember from somewhere that you're a mathematician. You'll have more success with Haskell thinking in terms of mathematical functions than functions in imperative programming languages.
    4. Vim works fine for me.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,926
    Thanks
    43
    Thanked 3,190 Times in 3,154 Posts
    Blog Entries
    12

    Default

    Haskell, wasn't that "The Beaver's" 'friend'?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Wikipedia says "wha'?"
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    May 2007
    Location
    USA
    Posts
    373
    Thanks
    2
    Thanked 4 Times in 4 Posts

    Default

    Thanks for your input Twey. I've always thought first-class functions were fun to use in Javascript once I learned how to use them . As for mathematician, I'm just a fledging one. I am studing it as my major, and I also want to (at the very least) minor in computer science . . . programming is addicting! And the rest is interesting.
    Last edited by Trinithis; 10-28-2007 at 09:13 PM.
    Trinithis

  6. #6
    Join Date
    May 2007
    Location
    USA
    Posts
    373
    Thanks
    2
    Thanked 4 Times in 4 Posts

    Default

    Wow, this is so cool!

    To paraphrase the tutorial:
    Code:
    add                     :: Integer -> Integer -> Integer
    add x y                 =  x + y
    
    ....
    
    map                     :: (a->b) -> [a] -> [b]
    map f  []               =  []
    map f (x:xs)            =  f x : map f xs
    
    ....
    
    map (add 1) [1,2,3] => [2,3,4]
    Can't wait to dig deeper than this . And now I want to re-read Twey's article on Javascript currying.
    Trinithis

  7. #7
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Huh, someone did read that then? I thought it was a wasted effort

    Yeah, functional programming is cool. I do recommend you learn Lisp, too, though, and see how it works in combination with other paradigms, as well as on its own as in Haskell. Python has quite a few functional influences, too.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  8. #8
    Join Date
    May 2007
    Location
    USA
    Posts
    373
    Thanks
    2
    Thanked 4 Times in 4 Posts

    Default

    I've read that Lisp is a family of languages. Which dialect should I get acquainted with first when I get the chance?
    Trinithis

  9. #9
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    It is. The only one I've learnt is Common Lisp; the other most common variant is Scheme. Some of the ideas behind Scheme seem silly to me, though, and CL has more libraries available.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  10. #10
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,926
    Thanks
    43
    Thanked 3,190 Times in 3,154 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by Twey View Post
    Wikipedia says "wha'?"
    Third result on Google:

    JuneCleaversBeaver's Profile on The Huffington Post - The ...I would NEVER knowingly serve alcohol to my boys' friends. Ward and I do suspect that Eddie Haskell may have, on one or two ocassions, poured some type of ...
    http://www.huffingtonpost.com/users/...CleaversBeaver - 49k - Cached - Similar pages
    Search terms:

    Haskell, wasn't that "The Beaver's" 'friend'?

    It's a reference to the old TV show 'Leave it to Beaver'.

    I neither know nor care much if the character from that show named Eddie Haskell had any role in the naming of the programming language under discussion. I though it might. In any case, the show was hilarious, more so now, in that it is so outdated.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •