As I have mentioned in other blog posts, learning the programming basics on your own can be frustrating. Sometimes it feels like I'm wandering through a thick fog that I can't find my way out of. But alas, Daniel P. Friedman's The Little Schemer has given me hope.This book is all about recursion, something that I did not understand but had used on websites such as Free Code Camp and Code Academy. There were many "ah-ha!" moments for me while reading this book, but most importantly I began to understand what the hell recursion actually is. In my own words, recursion is a problem that solves itself by referring back to its beginning after modifying at least one part of the original problem. In Friedman's words, "recursion is the act of defining an object or solving a problem in terms of itself."
I first heard of this book while going through Douglas Crockford's JavaScript lectures on youtube. He mentioned that every programmer should understand what this book teaches, and when Crockford recommends such things, young programmers should listen.
The book is structured in a wonderfully refreshing way especially for someone who intends to learn on their own. The text consists of simple questions that build toward more complex realizations. Instead of giving definition terms in English, the book works the reader to a conclusion on his/her own by using the previous question and answer to help define the next.
The Little Schemer is written in the language Scheme, something I have never seen before, but I had no problem picking up the concepts of the book because the language has many similarities to JavaScript. For example, a scheme function would translate to JavaScript like this:
(define phish (lambda (a b c) (body)))
//and in JavaScripst...
function phish foo(a, b, c) {
return body;
};
As you can see the functions are pretty similar so for most of the book I just left the problems in scheme. One thing that really stuck out to me while going through this book is the functions that I have been taking for granted such as the simple .length property in JavaScript, or the very often used "rember" function found in the book. "Rember" takes two arguments, one an atom and one a list, and removes the first argument when it finds it in the list.
This book helped me understand recursion MUCH more, and is something that I will return to over the next few weeks when I feel I need a refresher.
-John