Paradigm Shifts Make My Brain Hurt
But this is a good thing.
My students know that I equate math and learning in general to working out at the gym. Like lifting weights you will never get the results you want if you don’t challenge yourself and do it often. For reasons I am sure have a strong evolutionary advantage, our brains form these strong bonds to ideas family, worldview, foods you will never try even though you have no idea what they taste like, etc. Well every so often, if you are lucky, your paradigm is challenged. This serves to either strengthen it or force you into what the philosophers call a “crisis”. Either way a lot of thinking and reflection occurs. This is a story about both math and paradigms.
One day I was working at my desk when a visitor sat down next to me at the adjacent desk. As we started talking I realized that this was someone I knew from online! What a small world. It turned out to be Emmanuel from the Bootstrap project which teaches algebra and game design through programming. He was there to train engineers to become mentors of middle and high school students.
Bootstrap is unique in a couple of ways. The materials are extremely detailed completed with step by step scripts of what to say and do in the classroom. This is useful to mentors who have never taught before but I was equally surprised to see how succinctly Emmanuel was able to capture good pedagogy and convey that in short training sessions and through the materials.
The other way in which Bootstrap is unique (and why my head hurts) is its use of functional programming instead of imperative programming. You might be saying to yourself, “I thought there was only one type of programming and just different languages.” Like human languages, programming languages can be broken down into families which share certain qualities and approaches to problem solving.
Imperative languages (C, Python, Ruby, Java, etc.) allow the user to write instructions for how the computer should be manipulated. Imperative languages run by changing the state of values (saving variables, updating variables, iteration). If you have programmed it was likely in a imperative language.
Functional languages trace their roots all the way back to the Lambda Calculus, a formal system developed to explore various mathematical principles. Functional languages allow you to abstract concepts as you would in math. Some like my mentor become filled with joy when programming in a functional paradigm, I am still getting used to it but I definitely see its merits. You may find this approach freeing or frustrating, depending on your own background!
For example in an imperative style you might calculate factorial like this:
Here we’re keeping track of two values as the program runs:
- n is our counter, which starts at n and shrinks to zero
- f is our accumulator, which is multiplied by n at each trip through the loop
In a functional language, you might right something like this:
Notice that in this code one there are no temporary variables or reassignment! In this case, the code makes no reference to the machine, or how to calculate the answer. Instead, it is declaring that factorial(0)=1 and that factorial(n) is n*factorial(n-1). The premise is that you are building math out of functions instead of manipulating variables.
Another well known example is Euclid's Algorithm for the greatest common factor (GCF) of two numbers.
In my experience students often get lost in the variables and tracing out how they change. It’s too much cognitive load to ask them to keep track of (how many teachers can relate to off-by-one errors with for loops, or confusion surrounding variable scope?). But there’s something even deeper going on here, beyond “simplicity” -- suppose you wanted students to really understand factorial. As a math teacher, which approach would you choose? The list of steps and scrap paper necessary to calculate the answer, or the formula for factorial itself?
Compare the two solutions to this formula, and you’ll see that the functional approach is actually identical to the formal definition while the imperative approach has little to do with it. For students to connect the imperative solution to the math, they need to do a lot of work to see why those steps will wind up giving back the right answer. Moreover, this approach uses things like while loops and assignment, which do not even exist in algebra!
Meanwhile, the essence of factorial is declared explicitly in the functional solution (it literally reads exactly like the algebra).
This is not to say that the imperative version is incorrect. (It works just fine on my own computer here!) However, the imperative solution introduces students to assignments and while-loops: concepts that have no business in a math classroom. The imperative model for variables is completely out of place in the context of mathematics, and will only serve to make things harder for students who have to un-learn it.
As Emmanuel points out, we know that there is no such thing as the “One True Language”. Instead, you pick the language based on the job. If your job happens to be teaching math, why not use an approach that’s actually mathematical? While I am extremely new to the topic, I am working of translating my own curriculum to use the paradigm. This is not to say, one is better than the other. Each way has its strengths and weaknesses but I think I am finally ready to take up my mentor’s call to use functional programming with my students.
I would highly suggest you take a look at Bootstrap. The resources are free and as I said, extremely helpful in supporting you and the student every step of the way. This is an excellent program for students. They love creating games as they learn algebra and some best practices in programming. This in turn helps them become better at solving problems and writing code.
Connect with BrokenAirplane and stay up to date with the best resources in education.
Follow my microblogging on Google+