Is programming a subset of math?

Math

Math Problem Overview


I've heard many times that all programming is really a subset of math. Some suggest that OO, at its roots, is mathematically based, but I don't get the connection, aside from some obvious examples:

  • using induction to prove a recursive algorithm,
  • formal correctness proofs,
  • functional languages,
  • lambda calculus,
  • asymptotic complexity,
  • DFAs, NFAs, Turing Machines, and theoretical computation in general,
  • and the fact that everything on the box is binary.

I know math is very important to programming, but I struggle with this "subset" view. In what ways is programming a subset of math?

I'm looking for an explanation that might have relevance to enterprise/OO development, if there is a strong enough connection, that is.

Math Solutions


Solution 1 - Math

It's math in the sense that it requires abstract thought about algorithms etc.
It's engineering when it involves planning schedules, deliverables, testing.
It's art when you have no idea how it's going to eventually turn out.

Solution 2 - Math

>Programming is one of the most difficult branches of applied mathematics; the poorer mathematicians had better remain pure mathematicians. > >--E. W. Dijkstra

Solution 3 - Math

Overall, remember that mathematics is a formal codification of logic, which is also what we do in software.

The list of topics in your question is loaded with mathematical problems. We are able to do programming on a fairly high level of abstraction, so the raw mathematics may not be staring you in the face. For example, you mentioned DFAs.. you can use a regular expression in your programs without knowing any math, but you'll find more of a need for mathematics when you want to design a good regular expression engine.

I think you've hit on an interesting point. Programming is an art and a science. There are a lot of "tools of the trade", and you don't necessarily sit down and do a lot of high-level mathematics in order to simply write a program. In fact, when you're programming, you many not really being doing much mathematics or computer science.

It's when we start to solve difficult problems in computer science that mathematics shows up. The deeper you go, the more it will flesh itself out.. often in lower levels of abstraction.

There are also some realms of programming that you don't necessarily have to work in, but they involve more math. For example, while you can certainly learn a language and write some apps without any formal mathematics, you won't get very far in algorithm analysis without some applied math.

Solution 4 - Math

OK, I was a math and CS major in college. I would say that if the set A is Math and the set B is CS, then A intersects B. It's not a subset.

It's no doubt that many of the fathers and mothers of computer science were Mathematicians like Turing and Dykstra. Most of the founders of the internet were either Phd's in Math, Physics, or Engineering. Most of the core concepts of computer science come from math, but the act of programming isn't really math. Math helps us in our daily lives, but the two aren't the same.

But there is no doubt that the original reasoning behind the computer was to well, compute things. We have come a long way from there in such a short time.

Solution 5 - Math

https://imgs.xkcd.com/comics/purity.png">

Doesn't mention programming, but idea is still relevant.

Solution 6 - Math

Einstein was known in 1917 as a famous mathematician. It wasn't until Hiroshima that the general public finally came around to the realization that physics is not just applied mathematics.

When people don't understand something, they try to understand it as a type of something that they do understand. They think by analogy. Programming has been described as a field of math, engineering, science, art, craft, construction... None of these are completely false; it borrows from all of these. The real issue is that the field of programming is only about 50 years old. People have not integrated it into their mental taxonomies.

Solution 7 - Math

There's a lot of confusion here.

First of all, "programming" does not (currently) equal "computer science." When Dijkstra called himself a "programmer" (more or less inventing the title), he was not pumping out CRUD applications, but actually doing applied computer science. Let's not let that confuse us-- today, there is a vast difference between what most programmers in a business setting do and computer science.

Now, the argument can be made that computer science is a branch of mathematics; but, as Knuth points out (in his paper "Computer Science and its Relation to Mathematics", collected in his Selected Papers on Computer Science) it can also be argued that mathematics is a branch of computer science.

In fact, I'd strongly recommend this paper to anyone thinking about the relationship between mathematics and computer science, as Knuth lays out the territory nicely.

But, to return to your original question: to a practitioner, "enterprise/OO development" is pretty far removed from mathematics-- but that's largely because most of the serious mathematics involved at the lower levels of operation have been abstracted away (by compilers, operating systems, instruction sets, etc.). Similarly, advanced knowledge of the physics of the internal combustion engine are not required for driving a car. Naturally, if you want to design a more efficient car....

Solution 8 - Math

if your definition of math includes all forms of formal logic, and programming is defined only by the logic and calculations extant in the code, then programming is a subset of math QED ;-)

but this is like saying that painting is merely putting colored pigments on a surface - it completely igores the art, the insight, the intuition, the entire creative process

one could argue that music is a subset of math by the same reasoning

so i'd have to say no, programming is not a subset of math. Programming uses a subset of math, but requires non-math skills/talent as well [much like music composition]

Solution 9 - Math

Disclaimer: I work as an IT consultant and develop mainly portals and Architecture stuff. I have a Psychology degree. I never studied Maths in University. And i get my job done. And usually well. Why? Because I don't think you need to know Maths (as in 'heavy' Maths stuff) to write code. You need analytical thinking, problem-solving skills, and a high level of abstraction. But Maths does not give you that. It's just another discipline that requires similar skills. My studies in Psychology also apply to my daily work when dealing with usability issues and data storage. Linguistics and Semiotics also play a part.

But wait, just don't flame me yet. I'm not saying Maths are not needed at all for computers - obviously, you need real Math skills when designing encryption algorithms and hardware and etc -- but if, as lots of programmers, you just work an a mid/low level language (like C) or higher level stuff (like C# or java), consuming mostly pre-built frameworks and APIs, you don't really need to understand the mathematical principles behind Fourier transforms or Huffman trees or Moebius strips... let someone else handle that, and let me build value on top of it. I am not stupid. I know the difference between linear and exponential algorithms and data structures and etc. I just don't have the interest to rewrite quicksort or a spiffy new video compression technique.

Solution 10 - Math

Well, aside from all that...!

Math is used for many aspects of programming such as

  • Creating efficient and smart algorithms
  • Understanding Big O notation
  • Security (such as RSA)
  • Many more... I think that programming needs math to survive. But I wouldn't call it a subset. It's just like blowing glass uses properties of physics, but those artists don't call themselves physicists.

Solution 11 - Math

The foundation of everything we do is math.

Luckily, we don't need to be good at math itself to do it. Just like you don't need to understand physics to drive a car or even fly a plane.

Solution 12 - Math

> The difference between programming and pure mathematics is the concept of state.

Have a look at http://en.wikipedia.org/wiki/Dynamic_logic_(modal_logic). It's a way of mathematically analyzing things changing through time. Also, Hoare triples is a way of formalizing the input-output behavior of programs. By having some axioms dealing with sequential composition of programs and how assignment works, you can perfectly well deal with state changing over time in a mathematically rigorous way.

If the math you know is insufficient, "invent" some new math to deal with what you want to analyze. Newton and Leibniz did it for analysis (aka calculus, I think). No reason to not do it for computation and programming.

Solution 13 - Math

I don't believe I've heard that programming is a subset of math. Even the link you provide is simply a proposed approach to programming (not claiming it's a subset of mathematics) and the wiki page has plenty of disagreements in it as well.

Programming requires (at least some) applied mathematics. Mathematics can be used to help describe and analyze programs and program fragments. Programming has a very close relationship with math and uses it and concepts from it heavily. But subset? no.

I'd love to see someone actually claim that it is one with some clear reasoning. I don't think I ever have

> Just because you can use mathematics > to reason about something does not > imply that it is, ipso facto, a > mathematical object. Mathematics is > used to reason about internal > combustion engines, radioactive decay > and juggling patterns. Using > mathematics is not doing mathematics.

Solution 14 - Math

I would say...

It's partly math, especially at the theoretical level. Imagine designing efficient searching/sorting/clustering/allocating/fooifying algorithms, that's all math... running the gamut from number theory to statistics.

It's partly engineering. Complex systems can rarely achieve ideal levels of performance and reliability, and software is no exception. A lot of software development is about achieving robustness in the face of unreliable hardware and (ahem) humans.

And it's partly art. Creative and idiosyncratic software design often comes up with great new ideas... like assembly language, multitasking operating systems, graphical user interfaces, dynamic languages, and the web.

Just my 2¢...

Solution 15 - Math

Math + art + logic

Solution 16 - Math

You can actually argue that math, in the form of logical proofs, is analogous to programming --

Check out the Curry-Howard correspondence. It's probably more the way a mathematician would look at things, but I think this is hitting the proverbial nail on the head.

Solution 17 - Math

Programming may have originally started as a quasi-subset of math, but the increasing complexity of the field over time has led to programming being the art and science of creating good abstractions for information processing and computation.

Programming does involve math, engineering, and an aesthetic sense for good design and implementation. Algorithms are an extension of mathematics, and the systems engineering side overlaps with other engineering disciplines to some degree. However, neither mathematics nor other engineering fields have the same level of need for complex, flexible, and yet understandable abstractions that can be used and adapted at so many different levels to solve new and evolving problems.

It is the need for useful, flexible, and dynamic abstractions which led first to the creation of function libraries, then class/component libraries, and in more recent years design patterns and service-oriented architectures. Although the latter have more of a design focus, they are a reaction to the increasing need to build high-level abstractional bridges between programming problems and solutions.

For all of these reasons, programming is neither a subset nor a superset of math. It is simply yet another field which uses math that has deeper roots in it than others do.

Solution 18 - Math

The topics you listed are topics in Theoretical Computer Science, and THAT is a branch of Pure Mathematics. Programming is an applied science which uses theoretical computer science. Programming itself isn't a branch of mathematics but the Lambda Calculus/theory of computation/formal logic/set theory etc that programming languages are based on is.

Also I completely disagree with Dijkstra. It's either self-congratulatory or Dijkstra is being misquoted/quoted out of context. Pure mathematics is a very very very difficult field. It is so enormously abstract that no branch of applied mathematics is comparable in difficulty. It is one field that requires enormous leaps of imagination. I did my first degree in computer science where I focused a lot on theoretical CS and applied areas like programming, OS, compilers. I also did a degree in Electrical Engineering - arguably the most difficult branch of engineering - and worked on difficult areas of applied mathematics like Maxwell's equations, control theory and partial differential equations in general. I've also done research in applied and pure mathematics, and to this day I find applied far easier. As for the pure mathematicians, they're a whole different breed.

Now there's a tendency for someone to study an year or two of calculus unhinged from application and conclude that pure mathematics is easy. They have no idea what they're talking about. Studying calculus or even topology unhinged from application does not give you any inkling of what a pure mathematician does. The task of actually proving those theorems are so profoundly difficult that I will defer to a computer scientist to point out the distinction: "If P = NP, then the world would be a profoundly different place than we usually assume it to be. There would be no special value in 'creative leaps,' no fundamental gap between solving a problem and recognizing the solution once it’s found. Everyone who could appreciate a symphony would be Mozart; everyone who could follow a step-by-step argument would be Gauss..." —Scott Aaronson, (Theoretical Computer Scientist, MIT)

Solution 19 - Math

I think mathematics provides a set of tools for programmers which they use at abstract level to solve real world problems.

Solution 20 - Math

I would say that programming is less about math than it used to be as we move up to 4th Generation Languages. Assembly is very much about math, C#, not so much. Thoughts?

Solution 21 - Math

If you just want the design specs handed out to you by your boss, then it's not much math but such a work isn't fun at all... However, coming up with how to do things does require mathematical ideas, at least things like abstraction, graphs, sometimes number theory stuffs and depending on the problems, calculus. Personally, more I've been involved with programming, more I see the mathematical side to it. However, most of the times IMO, you can just pick up the book from library and look up the basics of the thing you need to do but that requires some mathematical grasp upfront.

You really can't design "good" algorithms without understanding the maths behind it. Searching in google takes you only so far.

Solution 22 - Math

Programming is a too wide subject. Good software based not only on math (logic) but also on psychology, linguistics etc. Algorithms are part of math, but there are many other programming-related things besides algorithms.

Solution 23 - Math

As a mathematician, it is clear to me that Math is not equal to Programming but that the process which is used to solve problems in either discipline is extremely similar.

Solving a higher level mathematics questions requires analytical thinking, a toolbox of possible ways of solving problems, experience with the field, and some formalized ways of constructing your answer so that other mathematicians agree. If you find a particularly clever, abstract, or elegant way of solving a problem, you get Kudos from your fellow mathematicians. For particularly difficult math problems, you may solve the problem in stages, and codify your stage arguments using things called conjectures and proofs.

I think programming involves the same set of skills. In programming, the same set of principles applies to the solving and presenting of solutions to problems. When you have a partial solution to a programming dilemna, you include it as part of your personal library and use it as part of another bigger problem later. These skills seem very similar to the skills used in mathematics.

The major difference between Math and Programming is the latter has a lot more in common between different disciplines of programming than Math does. Two fields of mathematics can be very, very different in presentation and what is used to communicate the field. By contrast, programming structures, to me at least, look very similar in many different languages.

Solution 24 - Math

The difference between programming and pure mathematics is the concept of state. A program is a state machine that uses logic (maths) to transition between states. The actual logic used to transition between states is usually very simple, which is why being a math genius doesn't necessarily help you all that much as a programmer.

Solution 25 - Math

Part of the reason I'm a programmer is because I don't like math. I have no problem with math itself, and I'm fine with it conceptually, I just don't like doing calculations by hand. When I found I could tell a computer what the math problem is and let it do the calculating for me, a life-long passion and career was born.

To answer the question, according to my alma mater, math == programming since they allowed me to take Intro to C++ to fulfill my math requirement.

Edit: I should mention my degree is in telecommunications which, at the time, had only the standard liberal arts math requirement of one semester.

Solution 26 - Math

Math is the purest form of truth. Everything inherits from math.

Amen.

Solution 27 - Math

It's interesting to compare programming with music too. In UK, anyway, there are computing based undergrad university courses that will accept applicants on the bases of music qualifications as supposed to computing due to the logic, patterns, etc. involved.

Solution 28 - Math

Maths is powerful, programming is powerful, if maths is a subset of programming then it is equally true to state that programming is a subset of maths.

Maths is described using language, often written down. Therefore is maths a subset of writing too?

Historicly maths came before computer programming, but then lists and processes probably preceded maths, both of which could be equally thought of as mathematical or do with programming.

Cirtainly programming can be represented using maths, so there is some bases for it being true that programming is a sub-set of maths. However a computer program could also implement maths, representing information symbolically, as maths typically does when done on paper, including the infinite and only somewhat defined, from the fundamental axioms, as well as allowing higher level structures to be defined that use each other and other sorts of relationships beyond composition, supporting the drawing of diagrams and allowing the system to be expanded. Maths is equally a subset of programming.

While maths can represent structures such as words, maths is by design about numbers. Strings for example are more programmatic than mathematic.

Solution 29 - Math

It's half math, half man speak, duh.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionmoffdubView Question on Stackoverflow
Solution 1 - MathMartin BeckettView Answer on Stackoverflow
Solution 2 - MathMark CidadeView Answer on Stackoverflow
Solution 3 - MathkeparoView Answer on Stackoverflow
Solution 4 - MathCharles GrahamView Answer on Stackoverflow
Solution 5 - MathpersonaelitView Answer on Stackoverflow
Solution 6 - MathAlan HenselView Answer on Stackoverflow
Solution 7 - MathMichael DorfmanView Answer on Stackoverflow
Solution 8 - MathSteven A. LoweView Answer on Stackoverflow
Solution 9 - Mathaxel_cView Answer on Stackoverflow
Solution 10 - MathstalepretzelView Answer on Stackoverflow
Solution 11 - MathCodeRedickView Answer on Stackoverflow
Solution 12 - MathJonas KölkerView Answer on Stackoverflow
Solution 13 - MathPhilip RieckView Answer on Stackoverflow
Solution 14 - MathDan LenskiView Answer on Stackoverflow
Solution 15 - Mathnewbie777View Answer on Stackoverflow
Solution 16 - MathTylerView Answer on Stackoverflow
Solution 17 - MathJoel HoffView Answer on Stackoverflow
Solution 18 - MathxsistorView Answer on Stackoverflow
Solution 19 - Mathkhursheed ahmadView Answer on Stackoverflow
Solution 20 - MathferventcoderView Answer on Stackoverflow
Solution 21 - MathprasannaView Answer on Stackoverflow
Solution 22 - MathSergey StolyarovView Answer on Stackoverflow
Solution 23 - MathDavid WeesView Answer on Stackoverflow
Solution 24 - MathJoeri SebrechtsView Answer on Stackoverflow
Solution 25 - MathMichael ItzoeView Answer on Stackoverflow
Solution 26 - MathzubinmehtaView Answer on Stackoverflow
Solution 27 - MathRossView Answer on Stackoverflow
Solution 28 - Mathalan2hereView Answer on Stackoverflow
Solution 29 - MathMetaGuruView Answer on Stackoverflow