Data and Process

Object based and function based programming are solving the same problem. They only differ in how they represent the function-object interface.

Object based programming starts with an object and then defines operations upon it. Function based programming starts with an operation, and then defines it’s effect on different inputs (objects)

Object based:

cat {
  speak() {
    print("Meow");
  }
}

dog {
  speak() {
    print("Woof");
  }
}

Function based:
let speak cat = print "Meow";;
let speak dog = print "Woof";;

or 

speak(who)
{
  switch (who)
  {
    case cat: print("Meow");
    case dog: print("Woof");
  }  
}

This, perhaps, explains the enduring popularity of C++; it started from a more function based language, and then added object-based constructs. This allows the programmer to use the more appropriate representation. Techniques usually considered hacks allow some intermixing, but you still have to choose one for each piece of the problem. So long as we have file based languages, this situation is not likely to improve.

Posted Thursday, July 1st, 2004 under Essay.

Comments are closed.