Tell your students the math they’re learning is Hindu & Muslim technology

If a student was to ask you what was the most important piece of technology ever invented, what would you say? Hopefully you’d use it as a conversation starter, and see what they knew. Things that would likely come up would be fire, the wheel, agriculture, and plumbing. All of these could vie for the top spot. But one of the most powerful technologies ever invented isn’t even taught as a technology, or even an invention. Is it because we take it for granted, or because it’s invented by non-European cultures?

Before Europe had the numbers we have today, they had Roman numerals. The Romans were great at lots of things, but their arithmetic, bluntly, sucked. Quick, what’s XIX times LVIII? Clearly they didn’t do math using these clunky numbers; doubtless merchants had abaci that allowed faster calculations, but there was no way to record the calculations. The Greeks, so famous for their math, didn’t have a better numeral system. In any case, Greek mathematicians focused on geometric proofs, and considered arithmetic a trivial matter for members of the lowly merchant class.

At least as far back as 700 BCE Hindu mathematicians had to record what would have been stupendously large numbers for their cosmology; for example their estimate of the life of the universe is 4.3 billion years, which given what we know today is a pretty good guess. They needed a way to represent these numbers. Originally they gave different numbers names, like “veda” (4) and “tooth” (32). But they found a more efficient way using calculations on clay tablets covered with sand, where they traced different numbers and calculations. Words were dispensed with and replaced with symbols. We wouldn’t recognize the symbols now, but they were the ancestors of the numbers we use now, and they used a place value system based on powers of 10. For an empty place they used a dot. A case has been made that they copied this system from a similar system used in China in the first millenium BCE.

The Hindus certainly weren’t the only people that used a place value system. The Maya had a place value system maybe as early as the first century CE. And the Sumerian cultures had nearly every part of a place value system as far back as the second millenium BCE.

Hindu and Arabic Numbers

It’s interesting to think about why we don’t use these systems now. I am a huge fan of the Mayans and love to talk about their math. But their numeral systems had a couple of weaknesses. They used powers of 20 instead of 10, which would have made it difficult to create things like multiplication tables. Worse, instead of making their third-lowest place 400 (20×20) they made it 360 (20×18) because that was close to the length of a year and they were mostly interested in keeping track of dates. Their numeral system could easily have overcome these weaknesses but the Classic Mayan culture crashed in the late first millenium CE and descending civilizations were decimated by European invaders.

The Sumerians had a better chance to make a numeral system that lasted, but their system lacked some important parts. Unlike both the Mayans and Indians they didn’t have a symbol for an empty place, so they just left it blank. If we did things like the Sumerians then 102 would be written as “1 2”. They also didn’t have a way to mark a unit place, even though they could do fractional places. The order of magnitude had to be figured out by context. If we did things this way then “432” could mean 0.432, 43.2, or 432,000. (In fact we do this verbally today: if I say a house costs “two-fifty” you assume one thing, if I say a slice of pizza costs “two-fifty” you assume something else.) Worse, they used base 60, meaning that a multiplication table would be impossible to memorize by anyone but a genius. Still, the Sumerian base-60 place value system continues to be used today in the way we count time, angles and latitude and longitude.

Muhammad ibn Musa al-Khwarizmi
Muhammad ibn Musa al-Khwarizmi

Still, the Hindu numeral system might not be the default today if not for the Persian genius Muhammad ibn Musa al-Khwarizmi. You might have heard of him as the inventor of algebra, and that is more or less true (really he got a lot of it from the Hindus). But that completely understates his impact. After his famous book al-Kitāb al-mukhtaṣar fī ḥisāb al-jabr wal-muqābala (The Compendious Book on Calculation by Completion and Balancing from which the term “algebra” comes), he wrote a few less famous but maybe even more influential couple of volumes whose original titles are unknown but were translated as “So Said Al-Khwarizmi” and “Al Khwarizmi on the Hindu Art of Reckoning.” These translations were the Europeans’ introduction to the algorithms of arithmetic we still use derivations of today: long addition, long multiplication, long division and so on. 

So to rather than just saying al-Khwarizmi gave us algebra, it’s better to say that aK gave us nearly the entirety of what a layperson calls “math.” Is this a technology? Absolutely. There is nothing in the counting numbers that requires they be divided into powers of 10, as the Mayans and Babylonians could tell you. Arguably other place value systems might work even better: base 6 would have an easier times tables, base 12 would give us better fractional places and base 16 has the advantage of working with binary numbers central to computing.

But it’s because of this piece of technology that an average contemporary sixth grader can solve problems that would have only been accessible to the most advanced calculator in Roman times. It is because of this technology, of course, along with aK’s invention of algebra, that we have made so many other tools in math like the coordinate plane and calculus, and all of the practical inventions that have required complex calculations.

Alan Turing
Alan Turing

But the contribution doesn’t end there! In the early 20th century logician Kurt Gödel ruined the dreams of a generation of mathematicians by showing that in every logical mathematical system some true theorems couldn’t be proved. The British mathematician Alan Turing wondered if he could at least make a method to predict what those unprovable theorems could be. If this were possible perhaps we could place some logical land mine warnings around them. (Spoiler: you can’t do that either.)

This led Turing to ask what sort of things could be proven using a “mechanical process,” ie and algorithm. To think about this, he began by considering someone carrying out an algorithm in the style invented by al-Khwarizmi, like

23
x 15

He decided there was no reason this had to happen in two dimensions, so imagined instead a tape containing

23 x 15 =

from which a machine could carry out the algorithm by moving up and down the tape. This machine, known today as a “Turing machine,” is not a physical thing but rather a theoretical instrument that has the ability to calculate anything that’s capable of being computed mechanically.

“Computed mechanically” today of course means “can be done by a computer.” Turing didn’t invent the computer, rather he invented computation as we now understand it. But his method of computing began with the methods written by a Persian mathematician who’d studied the Hindus who maybe studied the Chinese.

We can’t say al-Kwarizmi invented our modern numbers and mathematical algorithms; rather he is similar to Euclid, who compiled different geometrical proofs (no doubt filling in blank spaces with his own genius) from Greek mathematicians into a compendious volume that shaped math for millennia to come. Certainly Euclid’s Elements and al-Kwarizmi’s “Compendious Book” are the most influential math textbooks of all time.

It’s surprising, if you think about it, that outside of specialized areas there is only a single numeral system that’s used in general today worldwide, regardless of culture or language spoken. Different countries might use different symbols for “2” and “4” but their calculations are all identical if you just change the symbols. This certainly suggests the power of this technology. And all of our science and invention, from molecular biology to Mars explorers, could not have been made if we couldn’t do the kind of calculations we can do.

But when students learn arithmetic, they are given this technology as if it has just been written into the universe with no invention necessary at all. I remember listening in shock when a commenter on a news channel said something like “give me an important invention that didn’t come from a European.” He’d never been taught that an invention we use today was created by Persians, Hindus and Chinese, because he’d never been taught it was an invention at all. We can do better than that.

Proposed computer programming standards

So this is my first try at creating computer programming standards. Note that these are not general “tech” standards, as tech can mean a lot of things (for example in Montessori it can have little to do with computers). Instead of talking about computers I say “computing machines” to mean any device that is controlled by a processor, which today can mean everything from your car to a fighter jet to your coffee maker. I’ve tried to minimize just learning a particular programming language, which is what most programming classes today do; mostly that is in the “Process and Application” section. I’ve created 8 categories that I think envelop the experience of working with computing machines, but I’ve probably missed something.

The categories I’ve chosen are:

  • Algorithms, meaning developing procedures to solve problems
  • Process & Application, meaning the general rules of procedural programs (loops, conditionals, etc.) and turning algorithms into actual code
  • Data & Classification, meaning the different ways that computing machines store data, such as data types (string, integer, etc.) and more complex data structures (objects) and databases
  • Logic, meaning the rules that apply to booleans and conditionals
  • Environment and Interface, meaning both the input and output devices of computing machines and also the user interfaces of software
  • Network and communication, meaning all the different ways computing machines talk to each other
  • Physical computing and sensing, meaning devices controlled by computers that do work in the world and analyze it
  • Debugging, meaning understanding the kinds of unexpected behavior we get from computing machines and how we can analyze and come up with solutions for them

There are other categories that I’ve debated including. Two specifically are: Hardware and History of Computation. The first is how computers physically work; this should be in here and the whole thing could be expanded to Computer Science standards, but I don’t know exactly what they are yet. The second is how the idea of computation has developed, going from Al-Kwarizmy developing algorithmic processes through Charles Babbage and Ada Lovelace developing the ideas behind doing it with machines, Alan Turing developing the theoretical underpinning of modern computation and John von Nuemann inventing the architecture of the computer, programmers like Margaret Hamilton writing the code for Apollo, and so on. This content is essential to include because it will engage more humanities-inclined students, but I don’t know if it belongs in standards.

The standards have levels ranking from what I might expect a young grade schooler to be able to learn up to what I think a small percentage of advanced high schoolers might potentially learn. The goal is to create an “all-some-few” approach to lesson design in which every level of learner is challenged and engaged.

Here are the complete standards:

  1. Algorithms
    1. Overview: many problems can be solved by a planned procedure of steps that can be carried out in a mechanical predictable way by a person or a machine
    2. Levels:
      1. Students can follow simple sets of instructions with only one outcome
      2. Students can distinguish between a mechanical and non-mechanical process
      3. Students can follow a set of instructions with conditional outcomes
      4. Students can describe algorithms verbally and visually
      5. Students can identify commands in a computer language that apply to steps in an algorithm
      6. Students can write a computer program implementing an existing algorithm
      7. Students can modify existing algorithms to get different results
      8. Students can make original naive algorithms to solve a problem
      9. Students can evaluate an algorithm for correctness and efficiency
        1. “Safe move”
        2. Asymptotic notation
      10. Students can understand proofs about the efficiency and accuracy of an algorithm
      11. Students can create an efficient algorithm
  2. Process & Application
    1. Overview: Machines can be programmed to execute algorithms using various coding interfaces that can be interpreted by the machine.
    2. Levels:
      1. Students can apply existing methods with or without parameters to get an output
      2. Students can match basic method keywords with desired outputs and order them in short functional segments
      3. Students can create simple conditional blocks that respond to hardcoded variable states
      4. Students can create conditional loops responding to hard-coded conditions and match them with loops in an algorithm
      5. Students can use main loops that run during the length of the program
      6. Students can create conditionals of moderate complexity that respond to data input by a user, and match them with branches on an algorithm
      7. Students can create iteration loops to move through collections of data based on loops in an algorithm
      8. Students can combine multiple conditionals and loops to create a single-function program
      9. Students can create simple functions matching a subprocess in an algorithm
      10. Students can create multi-function programs based on algorithms they have created
  3. Data & Classification
    1. Machines that do computations and apply algorithms store data of various types in different ways in order to perform operations on it.
    2. Levels:
      1. Students can identify different kinds of information, such as numbers, dates and text
      2. Students see how primitive kinds of data describe different kinds of real-world objects and situations
      3. Students understand that different kinds of operations and methods apply to different types of data
      4. Students can recognize complex data types that contain a number of primitive types and methods
      5. Students can identify how complex data types apply to real-world objects and problems
      6. Students can describe data types as superclasses and subclasses
      7. Students recognize complex data types that contain other complex types have methods or functions with different types as arguments
      8. Students can make original data classes to model real-world objects
      9. Students can identify and share data classes using a markup language such as JSON or XML
  4. Logic
    1. Computers at their core operate by evaluation of logical statements that follow certain logical rules.
      1. Students can classify statements as true and false
      2. Students can evaluate simple conditional statements based on truth or falsity and use them to make choices
        1. (“stand up if you’re wearing blue.”)
      3. Students can evaluate simple conditionals using conjunctions (AND) and disjunctions (OR)
      4. Students can evaluate multi-level conditional statements with basic operators
      5. Students can create basic conditional statements that can be used to solve real-world problems
      6. Students can apply more advanced operators such as XOR and NAND
      7. Students can apply Boolean operators to binary numbers
      8. Students can create complex Boolean operations to solve problems
  5. Environment & Interface
    1. When a human interacts with a machine there must be an interface through which the user provides data and instructions to the machine and the machine can provide information to the user
    2. Levels:
      1. Students understand the difference between input and output and can give some examples of each (not necessarily in a machine)
      2. Students can identify common input devices such as touchscreen, keyboard, mouse and camera, and can identify common output devices such as screen, speakers and printers
      3. Students can type short inputs and place things using a drag-and-drop interface with a plan for expected output
      4. Students can respond to basic computer requests for information, including username and password forms
      5. Students can interact with a computer in a text-based interface and use advanced GUIs
      6. Students can create text-based interactive environments for other users
      7. Students can used advanced GUI and text-based development environments with an expected outcome
      8. Students can create interactive environments for other users
      9. Students can understand and control how a device interacts with a computer at a machine level
  6. Networks & Communication
    1. Many machines communicate with other machines over different types of electronic connections.
    2. Levels:
      1. Students understand that devices they are using are connecting with other devices locally and over the internet
      2. Students can navigate a simple hyperlink environment
      3. Students can enter network addresses (such as URLs) with an expectation of reaching another device
      4. Students can understand and respond to events that occur through interfaces and distinguish them from events internal to the machine
      5. Students understand basic principles of how computers request, serve and interpret served data (what happens when you “go to” a Web page?)
      6. Students can create client-side interfaces that can be served over a network (such as an HTML page)
      7. Students can create interfaces that send and respond to data from the server during use (client-side programming)
      8. Students can create and interpret network requests at a text level
  7. Physical computing and sensing
    1. Processing machines can control other machines that collect information from the world perform physical work in the world according to a program.
    2. Levels:
      1. Students can identify devices that can connect to a machine and do physical work
      2. Students can identify what kind of physical work a device will be able to do
      3. Students can make a physical device do a simple motion or response, (such as spinning  a motor or turning on an LED)
      4. Students can plan simple motions for a connected physical device and explain it algorithmic fashion
      5. Students can convert an algorithm to control a machine into a simple program
      6. Students can plan a series of actions for a physical machine to solve a problem
      7. Students can plan and write a program that will make a physical machine solve a problem
      8. Students can modify physical machines to make them do different things than they were built for
      9. Students can make a physical machine to solve a problem and program it
  8. Debugging
    1. Often machines don’t do what we expected them to do or want them to do, which can result in an error message or in unexpected output. There are different types of errors that can happen in computing and many different reasons they can happen. Debugging is identifying the type and cause of an error and changing our input or the state of a program or machine so we get the output we expected.
    2. Levels:
      1. Students understand that an error message occurs because a program can’t interpret an input or because it’s in an incorrect state
      2. Students understand that an error can be understood by analyzing and changing input or the state of the computer or program
      3. Students can experiment with different types of input to analyze what is causing an error
      4. Students understand the three main kind of errors that occur when programming:
        1. Syntax or compile-time errors: the compiler won’t even try to run a command because it doesn’t understand it
        2. Runtime errors or exceptions: the compiler understands a command and attempts to run it, but the data it is using lead to an operation the computer can’t perform, causing the program to stop with an error (y=5/x, where x = 0)
        3. Unexpected output: the compiler understands a command and it runs without error, but doesn’t give you the output you were planning for
      5. Students can identify some causes of an error, such as unanticipated input, endless loops, memory overflows and incorrect data types
      6. Students can identify the type of error that’s occurring in a program and consider what kinds of actions might change the outcome
      7. Students can analyze error messages and use this information to find the location and cause of an error
      8. Students can anticipate the kinds of errors that might happen in a program and modify the program to avoid them
      9. Students can write methods that deal with exceptions in a way that records or logs useful information, allows the program to continue and gives a user-friendly output

 

Can We Escape the Forever Loop?

If you’ve used Scratch or a similar program to teach coding, it’s likely you’ve helped a student who asked why code like this isn’t working:

When green flag clicked - if(space key pressed) - Move(10)

The student is pressing the space key, but their sprite isn’t moving. They don’t understand why.

“Well,” you say, “that’s easy. What’s happening is the code’s only running once, and it happens instantaneously, so if you’re not already holding down space when the program starts, it sees that the key isn’t down, moves on, and ends the program. All you need to do is wrap it in a forev-”

And I’m going to stop you right there, before you doom the kid to a loop he probably won’t escape for years. Let’s go back in time. It’s likely you at some point learned to code using some kind of a console app, maybe Python or if you are as old as me maybe BASIC. In any case, you probably have written a HelloWorld2 program that went something like this:

name = input("Hi, what's your name?")
print("Hello " + name + "!")

Now let me ask you this. Why do you not need to do something like this?

while(name == "")
    name = input("Hi, what's your name?")
print("Hello nice to meet you " + name + "!")

In other words, how does the compiler know to just sit there and wait for you to enter your name before just moving on and running the program and printing “Hello  !”

If your answer is, “Well, that’s just how console apps work!” then I am a bit disappointed but I’ll give you another chance. Why do console apps work that way? In pretty much any console app, when you use an input command, it knows to sit there and wait until the user has entered some data ending with a linebreak (‘enter’) character.

Formally in programming this is known as an ‘event’. This is any change in state of the compiler’s environment; an event is often user input but doesn’t need to be. It can be a mouse click but it can also be the return of data from a network call or two objects colliding in a video game.

In a simple procedural program the only way to check for an event is to create an endless loop and check repeatedly 30-60 times a second. It’s not just Scratch that does it this way. Processing (and Processing JS in Khan Academy by extension) has the draw() function, which is just a forever loop. Greenfoot has the act() function, same thing. Even Arduino C is centered around the loop() function.

Except for the Arduino, all these are primarily game-creation engines. But real programmers rarely use a continuous loop like that. Most programs with user interaction are instead event-based. This means you create a handler that responds to an event like a mouse-click or key press. In JavaScript, for example, it’s something like this:

document.getElementById("myBtn").addEventListener("click", displayDate);

But that’s advanced programming! You can’t expect a simple program like Scratch to have event handlers. Oh yeah? How about this:

When (space) key pressed - Move 10 steps
An event handler in Scratch!

If you put in the above, it works out of the box. No Green Flag Clicked necessary. Oddly, I always thought of this as the more “basic” approach, probably because there is nothing to “start” the program. But really it could be seen as the more sophisticated approach. They have the start of full event-driven programming. Imagine if they had a block like this:

On event ( ) do:
The event handler Scratch should have

With something like this you would probably still have a few things stuff in the forever loop, but almost everything else – key presses, mouse clicks, collisions, changes in variable values, appearance and disappearance of sprites, etc. etc. – could depend on event handlers. Ideally there would be something to “turn on” the event handlers too, whether a green flag clicked or whatever. There is no reason that couldn’t be in there.

But what difference does it make? Why is the forever loop so bad?

Well, for one thing, if you ever want to teach any other kind of loop it is really difficult to come up with a way to work it in, because it’s already looping. If you try to loop something inside that, it will stop all the rest of the action of the sprite. If you want to iterate, or have a conditional loop, you have to kludge it by creating a counting variable or condition and checking it repeatedly in the forever.

But in an event-driven program with multiple different event “threads” (weird, Scratch has threading too!), other handlers could respond to different events while a previous thread is still executing. This gives you an opportunity to put different kinds of loops in.

More importantly, though, it would give students a better idea of how most programs actually work. They could create an interactive environment like a modern web page.

Also, you will help them understand that a loop that repeats forever without a built-in interrupt condition is normally a really bad idea. Really there usually is some kind of interrupt, whether the stop sign or the pause button in Greenfoot and so on. But that’s outside the program the students are writing.

More importantly, we could get away from the idea that the only reason for programming is to make video games. We’re never going to get anywhere with coding education until kids start making programs that do real things, not just play.

On Teaching Magic

I’ve been thinking about Elodin from Patrick Rothfuss’ Name of the Wind series lately. Elodin is a teacher at a magic university attended by Kvothe, the main character; he teaches Naming, the most difficult of arts. In the first class Kvothe attends Elodin arrives thirty minutes late. He tells them he’s going to throw a rock and gives them ten minutes to calculate exactly where it will land. After they’ve struggled with the math and admit they can’t he calls an eight-year old servant boy into the class and tells the boy to catch the rock, which he does. Then Elodin writes the names of twenty books on the board and tells the students to read one. Which ones are most important? a student asks, and Elodin says he doesn’t know because he hasn’t read any of them. He puts stars by three, underlines two, and draws a sad face by one, then walks out of the room. Elodin is known to have been a genius who outshone even the brightest scholars of the university; he’s also considered to be insane, and is kept on as a kindness, and allowed to teaching Naming since no one understands it anyway. He is constantly giving Kvothe pointless tasks, and at one point he pushes Kvothe out a window and nearly kills him. He is always trying to keep his students intellectually off-balance because he says Naming’s not an art you can learn in a sequential way; it’s more a kind of inspiration.

Like anything in a fantasy novel Elodin is over the top, but it made me think of the different kinds of teachers we have. Mostly, good teachers are the kind whose units are planned out through the year and who progress through a subject, carefully building understanding like an architect. And then occasionally you get the teacher who’s kind of a flake, but who shows you things that no one else shows you, either because other teachers consider it beyond your level or just not worth teaching because it doesn’t connect anything else on the curriculum. Sometimes what they teach really is beyond your level and you’re just left confused but intrigued. These teachers’ classes are either engrossing or interminable, depending on the day and their mood and yours. They may not be good at what’s known as “classroom management,” and maybe their classes are a bit of a circus. Maybe sometimes they lose their temper where a more measured teacher would be patient and mature. They may try to teach you things they barely just learned themselves, just because they’re excited about it.

I’m oversimplifying; a teacher can be both organized and imagination-stretching or one or the other depending on the circumstances. But I know that it’s the Elodin-like teachers who gave me moments in a classroom that still stick in my head now. I’m not saying I’m an Elodin or that I’m trying to be, but I’d like to be the kind of teacher who at least sometimes pushes kids to do things that is maybe beyond them but maybe isn’t. I promise not to push any kids out the window.