Take the 2-minute tour ×
MathOverflow is a question and answer site for professional mathematicians. It's 100% free, no registration required.

Hi Guys

I'm a programmer & don't really have much of a mathematical head on me. I am curious though if a mathematician would be able to compare object oriented programming to any particular field of mathematics, and if so could you describe the properties of the relationship?

I was never really good at math as a kid, so it was only in my later years & particularly since I got involved in programming that I've been able to begin to understand things mathematically. I wonder if this is because my interest in programming and my growing ability to better visualise abstract models contributed to the improvement?

I wonder what would a mathematician say?

Thanks

Dave

share|improve this question

closed as not a real question by Kevin Buzzard, Reid Barton, Harry Gindi, Charles Siegel, Scott Morrison Mar 10 '10 at 23:36

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

    
Are you interested in what math can contribute to programming in general, or specifically what math can say about OOP? If the former, then there are quite a few things (complexity, computability, program analysis/verification, formal languages) that can be discussed. –  user3035 Mar 10 '10 at 21:16
2  
I removed the tag "abstract-algebra". In my opinion this question is not really a good question here on MO, and I'm sure there are other places (perhaps StackOverflow) more suited for this question. –  Grétar Amazeen Mar 10 '10 at 21:32
1  
I don't see why StackOverflow would be a better place than MathOverflow for this question. –  Douglas Zare Mar 10 '10 at 22:05
    
I agree with the close, as being inappropriate for MO, but I think it's a very interesting question. There are deep connections between programming and category theory, but there are also more superficial similarities that I think that mathematicians could well exploit in teaching: the idea of "data type" is a bit like "set", the two concepts of functions are very similar, constructing a proof (particularly an analysis proof) is a bit like writing a function ... and so on. –  Loop Space Mar 11 '10 at 9:08
    
How exactly was this inappropriate for MO? Who can answer a question about which field of mathematics is analogous, and how, better than research mathematicians? –  Douglas Zare Mar 11 '10 at 12:35

2 Answers 2

The practice of object-oriented programming requires understanding of levels of abstraction which are made explicit in category theory. This does not mean that the way a computer scientist views object-oriented programming is similar to the way that a category theorist views category theory, but there are strong superficial similarities on lower levels.

Both subjects have objects, and these are analogous. There are things you can do with the objects called methods in OOP, and morphisms in category theory.

Classes in OOP may roughly correspond to categories in category theory.

Inheritance and polymorphism can be related to some functors in category theory.

Does that help you to program better? I'm not sure, but if you haven't encountered category theory yet, you may find it more approachable due to your OOP background.

Here are a couple of related MO questions:

Relating Category Theory to Programming Language Theory

Programming Languages based on Category Theory

share|improve this answer
1  
Computer programming is, to me, a special case of mathematical problem solving. Even if you aren't dealing explicitly with numbers, or even very much with 'functions' per se, you are solving problems by identifying ways of re-arranging ('transforming') data and data structures. Even if the original and more profound point of Category Theory was to identify much higher concepts, the idea of proclaiming "I have here a class of objects, and these are the allowed/pertinent/etc. transformations of them" gets to the heart of what systematic problem solving is all about. –  Niel de Beaudrap Mar 10 '10 at 22:16
    
"practice of object-oriented programming requires understanding of levels of abstraction which are made explicit in category theory." - no it does not;-) –  kakaz Mar 11 '10 at 8:13
1  
@kakaz Would you care to explain what you mean instead of simply contradicting and smirking? As far as I can see, it's true. –  Douglas Zare Mar 11 '10 at 12:31

I haven't read it but there's a paper relating design patterns and mathematics: A Mathematical Formalism for Specifying Design Patterns (2002)

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.