Monthly Archives: January 2016

What is the Difference Between Functions and Procedures?

[Note: Hadi Partovi and Baker Franke of contributed a lot of this and Emmanuel Schanzer offered ideas.  I don’t really know how to assign credit to specific pieces, but I want to make sure to acknowledge their efforts.  Editorial comments about possible implications of the vocabulary issues are mine.  — JEP]

In mathematics, the word “function” means this:

For a consistent set of inputs, a function returns a single, consistent output.

Notationally, a function is typically a single letter such as f, g, or h, followed by parentheses containing parameters such as x, y, and z.  The parameters are generally referred to as variables in a high school math class.

For example, if f(x) = 2x + 3, then f(5) = 13.  Always.

If g(x, y) = x * y, then g(4, 5) = 20.  Always.

If h() = 5, then h() = 5.  Always.

Mathematical functions need not take any inputs.  But they do need to be consistent.  Students are taught the vertical line test for graphs where y = f(x) to verify that consistency of output.

In computer science, programming languages allow people to give functions more descriptive names.  For example, if you want to write a function that takes a number as an input and returns the square of that number, you could name that function square.  In the programming language JavaScript, that would look like:

function square(x) {
  return x * x;

(Isn’t that much nicer than f(x) = x2?  Isn’t it nice to see the name “square” and not think that it means to multiply s*q*u*a*r*e?)

In computer science, we have procedures.  A procedure is like a function in that it takes any number of inputs.  It is different in that it need not produce consistent outputs.

All functions are procedures.  Not all procedures are functions.

Here is a JavaScript procedure that is not a mathematical function:

function notReallyaFunction(x) {
  return random();

notReallyaFunction returns a random number between 0 and 1, regardless of x.  That’s not a problem for procedures in programming languages.  There is no requirement to return consistent outputs.

Note that the word function does not imply that a function is being created in the mathematical sense. It is a keyword in the JavaScript language used to create a procedure.

From the teacher’s point of view, this seems like a simple vocabulary fix, and it would likely be just that if math teachers could reliably be aware that the word function is being used in a non-mathematical way by programmers and if computer science teachers had the depth and breadth of knowledge to be aware that this should be discussed at least briefly with their students.  To their credit, does address this in their curriculum, even if it is an issue in this widely viewed video.

Vocabulary frustration can be a reason for students to tune out of programming. The AP Computer Science curriculum demands knowledge of the Java programming language. Explaining public static void main to the intellectually curious student is quite a challenge for teachers and problematic for some.  I’ve seen students who were very capable mathematicians tune out on day one of class because this vocabulary is intimidating.  I’ve had a parent, who works at Google, express frustration about expecting novices to deal with the overhead of getting started with the simplest program in Java.  It can be intimidating.  Minimizing and eliminating unnecessary duplication and conflation of terms can make a difference between a child participating and a child opting out of learning CS. (It might also help the child learning mathematics after programming to be less confused.)

The JavaScript programming language isn’t going to be changed. It is a widely used tool for creating all kinds of wonderful programs. It’s too bad that the designers chose the word function as a keyword, but that ship has sailed.

Still, my objection to the video remains. The topic is good, Chris Bosh is a tremendous messenger, and I still wish they would go back and change the word “FUNCTIONS” to “PROCEDURES”.

What is the Difference Between Computer Science Class and Math Class?

On October 4, I watched a video produced by in which Chris Bosh (my favorite NBA player) was talking about procedures.  Only the script that Mr. Bosh was reading used the word “function” instead of “procedure”.  It may seem like a small thing, but as a teacher who has dealt with algebra and geometry students who find the vocabulary of mathematics somewhere between merely off-putting and thoroughly confusing, I thought I would defend the distinction.  So, I had the audacity to post a polite complaint to the CS Education Discussion Forum on Facebook as I know it is gets attention from the good folks at

The ensuing discussion with Hadi Partovi, Emmanuel Schanzer, Baker Franke, and others was interesting.  Because the words are conflated in the computing industry (and very specifically in some languages such as JavaScript), there was an argument that the two were synonymous.  It’s a very reasonable point, but there is a distinction between a student learning math and computer science and a programming professional.  I’m worried only about the former.  (I was amused to learn from Hadi that Bill Gates apparently takes my side of this argument.  Yay Bill!)

To my surprise–and educating me on how to deal with people with whom one has a professional disagreement, Hadi dropped me an email, asking me to look over a document that was drafting that talked about various terms as they arise in a typical math class and in a typical CS class.

More recently, Baker Franke and I talked and he suggested that I put these distinctions into my blog.  Thus begins a series of entries that discusses linguistic issues as regards the learning of mathematics and the learning of computer science.

Hopefully, this will generate some discussion.  Computer science is still a very young field and figuring out how to best communicate big ideas in the field has its challenges, vocabulary being a big one, particularly with novices.

Here are the topics that will be covered.  I will provide links to them as I create blog entries.

  • Function v. Procedure
  • Variables
  • =
  • Numbers and other data types
  • Operators
  • Abstraction