Understanding Recursion18 Apr 2010
As Every college in India did, our college taught us a bunch of programming languages namely c, assembly language, c++, java, C#. I never written much code other than lab excercise in any language except java. I choose java because, i really got interested in programming in the third year and that was the time, they taught java. So i used to write all my crap in java. As i got more and more interested in programming, i started to read many blogs and i finally decided to learn a new language. I spent some time evaluating the new language like Ruby, Python, etc and finally decided to go with Scala.
I decided to learn Scala because it looks similliar to java and it is concise. It went well for a few days. Then i had a feeling that i was missing something very important. So i asked some people and then found that i need to learn the basic functional programming concepts like lambda, recursion, immutability, no side effects, higher order function etc. Scala is a Hybrid language(functional and imperative).I was familiar with OOPS(imperative), but never heard of functional programming.
I read the The Little Schemer book. This Book was different from all the books out there ( at least from the books i have read so far). It looked like a list of exercise program. It was a small book and i was able to finish it in a couple of weeks.
To understand Recursion, you first need to understand Recursion
Before reading this book, i was not very clear about the recursion. Although i used recursion, i found it a bit difficult to grok. After reading, my understanding about the recursion improved a lot. (Finally i am getting recursion :)).
In Functional Language, functions are first class citizens. We can
pass them to other functions. My first reaction was, “
oh my god, It
understood the real power of it until i read the book. In fact i was
amazed when i found that a function can return another
Instead of teaching the semantics of a language it teaches how to solve a problem using programmatically. It uses Lisp to explain the concepts. It won’t teach you scheme language, but it will teach to how to think recursively.
We can’t read this book as reading a novel. We have to sit and solve all the problems by ourselves to understand the concept. I highly suggest you to read the The Little Schemer, if you are new to functional programming. I may read the seasoned schemer in the future.