Showing posts with label michel paul. Show all posts
Showing posts with label michel paul. Show all posts

Paradigm Shifts Make My Brain Hurt


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:
1
2
3
4
5
6
 def factorial(n): 
    f = 1 
    while (n > 0): 
        f = f * n 
        n = n - 1 
   return f 

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 this code in order to get it to work, we need  for loops and temporary variables, which track the machine’s behavior as it works through the process of calculating the answer. This is analogous to the way a student would calculate the answer on paper, keeping track of f and n on scrap paper as they go. In our imperative solution, each line of code is telling the machine to store answers and change values, such that the value returned is the answer we want.

In a functional language, you might right something like this:
1
2
3
4
5
def factorial(n): 
    if n == 0: 
        return 1 
    else: 
        return factorial(n-1) * n

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.
1
2
3
4
5
def gcf(a,b):
    if b==0: 
        return a
    else: 
        return gcf(b,a%b)

 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+

Computer Science in High School is Critical for the 21st Century Student

It is an amazing world isn't it? We have so much technology that exceed our science fiction fantasies. The question is, who is and will be making this stuff? Will it be your students? There has been an exponential boom in the demand for electronics, and unless we are talking about your basic appliances, those electronics require programming.

More and more, there is a need for our students to be literate in Computer Programming. Every field in science and mathematics requires an understanding of how computers work and those who speak the language of computers will be ahead of the game. My mother who has been a Nurse for over 30 years has seen the face of the medical field change dramatically in the last few years. In fact her department now has a need for a Bioinformatician, who is a person qualified in both nursing and computer science.

One of the most important articles I have ever read was published in June of 2008 entitled The End of Theory (accompanying diagram) and it described how we are collecting information about our Universe and ourselves so quickly that we do not have time or enough resources to interpret it so it can be used. This is why distributed computing platforms have been so successful, as they allow millions to share in the work of the scientists (e.g. BOINC, Fold It). Google has made billions in searching data quickly. Facebook and MySpace have likewise connected data in ways never before and in doing so connected people from around the World.

Computer science is a mystery to most. Very few K-12 schools offer it and those who do not major in STEM (science, technology, engineering, or mathematics) will not likely take it. This means that the majority of our population is and will remain completely illiterate in that which is truly our most universal language. It will be those who can program who will, according to Marc Prensky, truly have the upper hand.

Computer Science majors are on the rise so there will be someone to do the job. Will it be your students?

How does one get interested in Computer Science? For me, it started with my Dad and I sitting around and learning how to program our Apple IIc in BASIC. Then I learned C++ from my Mom's friend. I taught myself how to program the TI Graphing Calculator in High School (much to my benefit), and I was brought to love Pascal and Python from my teacher and friend, Michel Paul.  The point is that in all of this, I was encouraged to learn programming by others. Some of them knew how to program well, some of them were learning along with me, but they were all excited to teach and/or learn. Since the opportunities to learn how to program are very few (currently), we must be creative and innovative in getting this to our students.

I hope I have your attention. You have the potential to give your students one of the most valuable skills they will ever have (next to reading and writing). Yet your next thought might be one of doubt:

  • My students wouldn't be interested
  • There is no time with my already full schedule to teach this
  • I don't know how to program
For all of these doubts, I ask you to trust me. Many of your fellow educators around the world are already using programming in their math, science, and humanities (???) classroom. Those I have helped, were able to begin right away. As with anything your students will be only as motivated as you are and what their assignments are (link to relevant article). I have students who are interpreting genetic data, creating scientific video games, art, and going deeper in understanding of math and science every day and you can too.

In the next couple of posts, I will show you give you some tutorials and examples that I have used in the classroom. Once we have a few items, I will compile all of this together so it is easy to find and share. 

There are many different programming languages out there and they all have their advantages. In my classroom, and therefore my examples, we will be using Python. The reason for this is:
  • 100% free and open source
  • it is a very popular language used by Google, Blender, NASA, and many others so your students will have a directly transferable skill.
  • for its ease and succinct syntax
  • Python was designed from the ground up to be used in the classroom (link to the DARPA Proposal)
If you would like to begin looking through some great resources on learning Python before the next post here are my recommendations:

Python - I would strongly encourage you to download version 2.7 instead of 3.0 as it is more compatible.
How to Think Like a Computer Scientist with Python - How I learned Python basics, and still the best tutorial  for beginners I have found.
EDU-SIG - The mailing list for those who discuss Python and education. It can be overwhelming at times but it is always inspiring.
Mathematics for the Digital Age and Programming in Python - An excellent textbook already used by many teachers to integrate programming into their STEM Classroom.

*If you are a Humanities teacher and would like to inspire your students with programming as well, I have seen it done very well using a program called Alice. It was designed by Randy Pausch (of The Last Lecture fame) and others at Carnegie Mellon University, and has been an exciting opportunity for students at middle school and older to create stories while learning how to program. This software is also free and there are many great examples and tutorials available on the Alice website.

I look forward to bringing you into this exciting world that will help you and your students go deeper in understanding and enjoyment of science and mathematics. Stay tuned for the tutorials and examples.