4 ms·
Can anyone point me to some good introductions on programming in a functional style for people who can already program in OO and imperative languages? My day j
by st0p 16y ago
Can anyone point me to some good introductions on programming in a functional style for people who can already program in OO and imperative languages?
My day job is Java mainly with some javascript mixed in, did a lot of PHP too. I used to hate JS, untill I learned about closures (and libraries like mootools and jquery). Having functions as first class citizens is truly nice!
I can see that the concept of immutability has a lot of value in a world where multicore reigns. And seeing code as data sounds like an awesome feature. But for me the question remains, how do I use it in practical everyday use? I mean, after 7 years of developing OO has ingrained to my mind. How do I transform that OO mindset into a functional one?
Yeah, perhaps I've become lazy, but most tutorials I've found don't tell me anything usefull. They show me how to print fibonaci numbers. Great, but how many times have you needed to generate fibonaci numbers? I need to know how to sort a list, find your next connecting flight or make a transaction to deposit 100 USD on a bank account.
I've build and helped design a couple of systems I'm proud of, even though I can see big flaws in all of them looking back. I've been most productive in garbage collected OO languages. I'm not willing to throw all that experience away but I am willing to accept that there are better ways to solve problems in code.
I see great potential emerging from both JVM / Closure and .Net / F#. If anyone can give me pointers to resources which learn me how not to reinvent the functional wheel, but how to be more productive in my day-to-day job, I'd be deeply gratefull.
- steveklabnik 16y agoI hate to be one of _those people_, but maybe you should check out Real World Haskell and Learn You A Haskell for Great Good: http://book.realworldhaskell.org/ http://book.realworldhaskell.org/ http://learnyouahaskell.com/ http://learnyouahaskell.com/ If you want to learn functional programming, I'm of the opinion that Haskell is a great language to learn it. Then again, learning by immersion works for me, and may not for you. In any case, Real World Haskell does a good job of explaining, well, real world examples. And "Learn You" is a nice intro to the language itself.
- masterj 16y agoI'd played around a bit with Clojure, but in the end it kinda left me scratching my head, unsure of how to go about doing anything useful in it. Not to mention that it's a pain to get it installed and set up properly. I've been reading learnyou over the past few days, and I can definitely feel the wheels starting to turn. I'm really looking forward to finishing it and diving into Real World Haskell. Though I'll definitely give Clojure another try once I have a better grasp on the mindset with which to approach it.
- Scriptor 16y agoA good trick with lyah is to try to write the code for a function before you see the actual example code. It'll get you in the functional mindset much faster.
- reader5000 16y agoRosetta code is a pretty useful site for this: http://rosettacode.org/wiki/Category:Clojure http://rosettacode.org/wiki/Category:Clojure