Live data from Hacker News

Why do most programmers work so hard at pretending that they’re not doing math?

richardminerich.com

21–30 of 74 posts

Re: Why do most programmers work so hard at pretending that they’re not doing math?

#21
post #10

We work in an environment where heresay [sic] and taste drive change instead of studies and models. We are stumbling in the dark. Another way to look at it is that we’re making progress, but with lots of false starts, like most progress. Hearsay and taste are what happen when people are working with imperfect information. Probably not even Knuth has perfect information about all the studies and models that might be r…

I'm writing a bunch of webapps in Scala making heavy use of Scalaz, which is Scala's Haskell-envy library of typeclasses. The typical pattern is to compute everything as a Validation, which you can think of as the Maybe monad, except there is information attached to the failure case. It's a very nice way of coding. Everything composes and at the end of the request handling chain you just convert to a response and you're done.

It took a bit of thinking to get the basic patterns, and there is the occasional bit of head scratching to get the type right. This feels very much like algebra.

Anyway, the point is that this style of programming is both "mathematical" and practical.

Re: Why do most programmers work so hard at pretending that they’re not doing math?

#22
post #10

We work in an environment where heresay [sic] and taste drive change instead of studies and models. We are stumbling in the dark. Another way to look at it is that we’re making progress, but with lots of false starts, like most progress. Hearsay and taste are what happen when people are working with imperfect information. Probably not even Knuth has perfect information about all the studies and models that might be r…

I'm writing a bunch of webapps in Scala making heavy use of Scalaz, which is Scala's Haskell-envy library of typeclasses. The typical pattern is to compute everything as a Validation, which you can think of as the Maybe monad, except there is information attached to the failure case. It's a very nice way of coding. Everything composes and at the end of the request handling chain you just convert to a response and you…

For reference, Haskell's version of that is called Either.

You also sometimes use ErrorT which is a way to slap an Either on any other Monad. The T just denotes that it's a monad transformer.

Coincidentally, I agree wholeheartedly about how practical programming like this is--this sort of error handling is at once easier and more explicit than exceptions.

Re: Why do most programmers work so hard at pretending that they’re not doing math?

#23
post #15

Because they're not doing math? Seriously - what is the useful model for a router or malloc? Oh, and Babbage was not the first person to write an algorithm.

Routing is heavily based in graph theory, as far as I know, and so is actually fairly mathematical.

Memory management can also require a good bit of math. A perfect example would be taking an existing algorithm and optimizing it to use fewer memory accesses. We covered this sort of optimization in my recent algorithms class (for some algorithms) and it figuring out how to do required a good bit of math.

Really, the issue is that a programmer who doesn't use math is much less likely to see how math would be applicable to any particular situation. This is just like the programmer who does not know about, say, hash maps--he would not realize what he is missing.

Re: Why do most programmers work so hard at pretending that they’re not doing math?

#24
A seductive idea, but ultimately of stunningly limited use in software engineering. By far the most costly defects in software creation are due to incorrect requirements or poor systems design. Knowing with mathematical certainty that your software component does exactly what you have specified it to do helps little when what it does is still the wrong thing.

And that doesn't even touch on the fact that crafting components is but a tiny part of the work required to produce software.

Re: Why do most programmers work so hard at pretending that they’re not doing math?

#25
post #22

Earlier quoted context omitted.

I'm writing a bunch of webapps in Scala making heavy use of Scalaz, which is Scala's Haskell-envy library of typeclasses. The typical pattern is to compute everything as a Validation, which you can think of as the Maybe monad, except there is information attached to the failure case. It's a very nice way of coding. Everything composes and at the end of the request handling chain you just convert to a response and you…

For reference, Haskell's version of that is called Either. You also sometimes use ErrorT which is a way to slap an Either on any other Monad. The T just denotes that it's a monad transformer. Coincidentally, I agree wholeheartedly about how practical programming like this is--this sort of error handling is at once easier and more explicit than exceptions.

Why is it easier? That's just doing the monad transformation by hand instead of letting a compiler take care of that for you (in the case of EitherT and do-notation the compiler takes care of the intraprocedural transformation for you). It's rather in the same category as Node.js programmers doing CPS transform by hand.

Re: Why do most programmers work so hard at pretending that they’re not doing math?

#26
post #10

We work in an environment where heresay [sic] and taste drive change instead of studies and models. We are stumbling in the dark. Another way to look at it is that we’re making progress, but with lots of false starts, like most progress. Hearsay and taste are what happen when people are working with imperfect information. Probably not even Knuth has perfect information about all the studies and models that might be r…

Haskell's advantages lie in being pure. It can't be 'friendlier,' because friendly languages let you hack things up (and are impure) as opposed to the planning required to lay down some Haskell.

I find it hard to believe that Haskell could not be friendlier. And I say that as a fan of Haskell.

Re: Why do most programmers work so hard at pretending that they’re not doing math?

#27
Walking is math too, it can be modeled in math, but that doesn't mean all people who walk are mathematicians.

Physics is math too, but the difference is that while Physics uses the same constructs as math, Programming has radically different constructs.

Math and Programming does not require the same mindset, in math you need to find the absolute truth, when programming, 99% is good enough.

Being good at Math does not make you a good programmer instantly, and vice versa.

> This is also why programmers who use typed functional languages frequently brag about their low bug count yet eschew methodologies like test driven development: tests pale in comparison to the power of actual models.

If I brag about something does that make it a fact? I think writing this in math context is silly to say the least. It doesn't matter what you program in, you still need to test most of the time, this has nothing to do with how you program, it's what you program, I highly doubt that you could model a video game, and get it right the first time, without ever testing it.

Overall this article is pretty confusing, it tires to raise some good points, but gets stuck on the details.

Re: Why do most programmers work so hard at pretending that they’re not doing math?

#28
post #27

Walking is math too, it can be modeled in math, but that doesn't mean all people who walk are mathematicians. Physics is math too, but the difference is that while Physics uses the same constructs as math, Programming has radically different constructs. Math and Programming does not require the same mindset, in math you need to find the absolute truth, when programming, 99% is good enough. Being good at Math does not…

Your post reminds me of what xkcd says about it:

http://xkcd.com/435/

There's a truth to it -- CS is just applied math, that doesn't mean you have to understand math to program, but it will be very beneficial.

Re: Why do most programmers work so hard at pretending that they’re not doing math?

#29
post #3

Imagine if physics was done this way. But it is... 1) We test theories with experiments to see whether they fail for that particular "input", we don't prove them correct. 2) One of our two best theories (QFT, the other being GR) doesn't even make sense, mathematically. In fact the great challenge of physics today is that we have neither experiment nor mathematical rigor to stand on: http://groups.google.com/group/sci…

True, but that's a fairly recent phenomenon and it's not even true for the more fundamental discoveries. Unless you mean the philosophical ideal of empirical research, in which case I would say that your view of the situation is flawed. It's only really true for simulation experiments, like those that try to simulate the entire universe, from a uniform inflation onwards. Few discoveries have been made that way though.

The use for limited-application theories is obvious. With the exception of lithography for chip design, all of electronics works with classical electricity theories. All of architecture, by now capable of constructing objects that are several kilometres high, works on classical mechanics. All of computer science works on ZFC, when it's obvious that real machines don't actually implement that. Or dumb mistakes in algorithms that are "assumed correct" anyway because we don't know how to fix them (such as several tree traversal techniques claimed to be O(N) yet in reality more like O(N^2) because they fuck up virtual memory by allocating memory like Obama allocates money.

Hell, I'm told that even ITER's reactor design is tested with classical simulations, with one or two correction factors to "compensate" for quantum phenomena (but not using the quantum formulas, because that doesn't work). Even inside the LHC 99% of the design is made using classical formulas, basically everything except the targets.

Physics itself could be said to use pre-Godel mathematical models (since we haven't quite figured out how to fix the problem Godel pointed out while getting pelted with tomatoes, that's more of necessity than stubbornness of course).

The reality is that science is back in the 1900's before Einstein : we have several big flaws in our theories staring everyone in the face, making lots of people angry. At the same time scientists are telling everyone that science will solve every problem very soon now (or at least not contradicting it). In the meantime nobody has any clue how to fix the gaping holes in our most fundamental theories.

Maybe it's time we did an exhaustive search of patent offices and Italian kindergarten teachers ...

Re: Why do most programmers work so hard at pretending that they’re not doing math?

#30
post #23
post #15

Because they're not doing math? Seriously - what is the useful model for a router or malloc? Oh, and Babbage was not the first person to write an algorithm.

Routing is heavily based in graph theory, as far as I know, and so is actually fairly mathematical. Memory management can also require a good bit of math. A perfect example would be taking an existing algorithm and optimizing it to use fewer memory accesses. We covered this sort of optimization in my recent algorithms class (for some algorithms) and it figuring out how to do required a good bit of math. Really, the i…

Modern IP networking relies extensively on graph theory. The Spanning Tree Protocol is a prime example of this.
Post reply on HN