Striking parallels between mathematics and software engineering
radar.oreilly.com
radar.oreilly.com
Abstract algebra and category theory give you incredibly useful program and API structuring techniques; you can get lots of nice properties for free by following these well-worn existing patterns, even more so than OOP design patterns. We make use of them a lot in Haskell, but they’re basically language-agnostic.
Even simple algebraic manipulations, like noticing that “return” is distributive over a conditional:
if x then return y else return z
return (if x then y else z)
Are very useful for restructuring programs to be more readable.http://www.haskell.org/haskellwiki/Curry-Howard-Lambek_corre...
It was mind-opening for me to think of types in terms of provability (intuitionistic/constructive logic) rather than truth (classical logic). The only way to prove that a function returning a value of type T actually halts (and therefore does not actually “return” bottom/void) is to run it and obtain that T value, i.e., to find the object that the type claims exists.
As my former exercise instructor for linear algebra told to the math students at the beginning of the second semester: Those people who have not yet understood that matrices are more than a box of numbers are definitely at the wrong place here.
Software engineering is much worse in terms of useless complications developed by people who don't know previous solutions (angular.js? Great! Have you ever heard of dataflow programming? Constraint satisfaction? Dynamic binding? No? No wonder angular is such a piece of shit).
My own point of view is that linear algebra is by far the most successful part of mathematics: 'Most' questions you can come up with have satisfactory answers. This is in contrast to, say, number theory, where there's a bunch of nice elementary results and a lot of interesting questions that seem nigh impossible to solve.
As a result, it's a pretty common game in mathematics to start with something new or difficult that you want to describe, and then do your level best to turn your questions into linear algebra problems so that you can actually get answers. The extent to which this doesn't work is the extent to which you need to develop new ideas. (One example of such an approach is algebraic graph theory. Turn a graph into an interesting matrix, and then use the linear algebraic properties of that matrix to describe interesting properties of your graph.)
The link to graph theory is beautiful, too. Entries in an matrix can represent edge weights, and taking a random walk on a graph can be represented as a matrix-vector multiplication, and the stationary distribution is the singular vector. How cool is that? When you start to link together abstractions from different fields of mathematics and science, you get these fantastic insights that are just mind bogglingly awesome. This is what makes all the pain of wading through an ocean of symbols and equations worthwhile, imho.
I view that as "if you can find a way to express your problem in terms of linear equations, there are well-known techniques for finding solutions."
On the other hand, while I am always cognizant and amazed by the POV of math as a human construction, there's something a little otherworldly about it from time to time. In the same way that you sometimes hit a code design which feels so damn good, Math, especially older math, is just a huge collection of these. Somehow, despite this all coming, apparently, from our minds, we hit on these design decisions that are just so sweet that they last millennia. This is what inspired things like Voyager---maybe it's hubris, but it just has to be the case that aliens speak mathematics.
So, I encourage anyone excited by this: math isn't "hard", it's just big and wonderful. You'll never finish learning it, but the journey will be incredible.
I'll leave this linking two more great resources (edit: to be clear, really the first one is the great resource... the second is just me talking, not really great at all). First, Paul Erdös, a famous mathematician who perhaps specialized in combinatorics, loved this idea I espouse above. In his mind, God had a small number of "proofs" in his mind when he designed mathematics. These are so wonderful that their beauty is completely self-evident. After Erdös "stopped doing math" (passed away) people compiled some of his Proofs from The Book along with others they imagine he would have so regarded into a great text book called, unsurprisingly, Proofs from The Book [0].
Finally, I'll self plug a little essay I wrote, actually in another HN comment, a while ago about learning mathematics.
http://jspha.com/posts/there_is_no_royal_road_to_mathematics...
[0] http://www.amazon.com/Proofs-THE-BOOK-Martin-Aigner/dp/36420...
Imagine if you had an API that had been in use and continuously improved for millenia.
On the contrary, mathematics has formed the basis (no pun intended) of so much software engineering. Take for example the very concept of a function/subroutine/method/ - this comes straight from the world of mathematics (albeit with minor modifications to make it convenient).
The algorithms that do all the heavy lifting in order to facilitate this web browsing experience are all grounded in mathematics - memory management in your kernel, database {everything}, even HTML layout management! The whole of complexity and asymptotic analysis is actually just mathematics.
Many of the pioneers in computer science originated as mathematicians. Alan Turing, John McCarthy and Donald Knuth for example.
It may not seem like it on a daily basis writing CRUD apps in an OO language, but software engineering is inextricably linked to mathematics. Such results are the furthest from surprising!
Did you even read the article before lecturing us about Turing and Knuth??
(Disclaimer: I'm a Sage developer.)
It's about math as a human construction. Very comforting to see ones inner metaphores and mental models of math "legitimised" and exposed in a scientific framework. One could hope for a companion: Where Software Engineering Comes From.
Another book on the topic of history of mathematics is "Journey Through Mathematics" by Enrique Gonzalez-Velasco. From its back cover:
"This book offers an accessible and in-depth look at some of the most important episodes of two thousand years of mathematical history. Beginning with trigonometry and moving on through logarithms, complex numbers, infinite series, and calculus, this book profiles some of the lesser known but crucial contributors to modern day mathematics."
The other theme in the article about algebra and minimally acceptable abstractions for accomplishing a goal is unfortunately nowhere to be found in software.
Let's define something, and consider what we can figure out about it.
Now let's add another property, and see what we can figure out.
Now let's add yet another property, and see what happens.
Etc.
One winds up familiar with the whole progression group --> abelian group (although not much time is spent on that one) --> ring --> integral domain --> unique factorization domain --> principal ideal domain --> Euclidean domain --> field.
What you really want to consider is interface subtyping and layering. Actually, more than just interfaces you want to also carry along laws. For instance, a group is a monoid with an inverse operation appended (interface concatenation) cut down by the fact that the inverse operation must be "nice" (law concatenation). If you only append the interfaces you end up with free structures.