11 January 2009

Rewire Your Brain with Functional Thinking

Rewire Your Brain
With your rewired brain you will begin to program in ways you have scarcely imagined.

Programmers often Musicians || Multi-Talented
If you are a good programmer, it's likely that you also have seemingly contrasting skills in music, sport, linguistics, dance, or have a warped sense of humour. You can see problems from more perspectives than the average bear.

Functional Programming: A Whole New Way of Thinking
Writing
recursive functions instead of while() loops requires a different way of thinking. Writing recursive functions in C or Java is relatively isolated within the overall scheme of things. It's not the whole program. It's not every while() and for() loop
re-implemented as a recursive function. And there's a tendency to mentally translate the recursive function into a procedural loop to understand it. It's like translating (say) French into English to understand it without bothering with the deep mental transformation and brain rewiring required to actually think in French. We need to think functionally.

Full Immersion in Functional Programming: Haskell etc.
While reading and working my way through Martin Odersky:
Programming In Scala I am often enough tempted to translate functional examples into procedure code. In fact, that's a valid teaching method employed in Programming In Scala to facilitate the transition of Java programmers from purely procedural and object-oriented programming, to functional programming. I don't think I need to learn multiple functional languages in order to master Scala, but it sure would help. Very often writers who are explaining and teaching Scala have a functional background, and it's easy for them to forget some of what it was like to not know functional programming. So, for my own benefit, I am immersing myself in Haskell to help me learn Scala. I am reading Real World Haskell and working through the exercises and examples.

Haskell Goes Back a Long Way
Haskell has a long history and was designed by committee to consolidate a range of functional languages that were splitting the functional community's focus and attention. There are numerous books available on Haskell such as the recently released O'Sullivan et al. Real World Haskell, and a much older book by Davie called 
Introduction to Functional Programming Systems Using Haskell. Davie's book is deep, while O'Sullivan's book is much gentler and up-to-date with the latest ghc Haskell compiler.

There will be some code in the next post!

No comments:

Post a Comment

Followers