Daniel Lemire's blog

, 28 min read

Language, Mathematics and Programming

30 thoughts on “Language, Mathematics and Programming”

  1. @Bannister

    Governments and some companies will not hire you for certain jobs unless you have some university education.

    Moreover, when academia formally recognizes something, its prestige level tend to rise. It may not help the current practitioners, but it helps people who want to start out.

    For better or for worse, programming is often seen as a “necessary evil” for university-level programs. Somehow, we must teach it, but just enough so that we can get to more interesting topics.

  2. @Bannister

    I agree with everything you wrote. But who said that classes and lectures had to be offered solely on campus?

  3. Just who – exactly – denigrates programming, and why should I in any way respect their opinion?

    My guess would be this has something to do with the academic background of you and many of the other readers of this weblog.

    Admittedly, the greater bulk of code is uninspired and unoriginal. (Then again, the same could be said of many teachers I had in past.) Much software only has to be “good enough”, and does not have to meet any major challenge.

    The “Creative Programming” class where “students would come together to write great code” … that class already exists, though more often referred to as “open source software”. The classroom is the Internet, and learning is incidental (though deeply interwoven). The stream of new ideas and practices tumbling past in my feed reader offer much to be learned and used.

    But what is the role of academia in all this?

    Over the weekend was poking around through the RepRap sites. Fascinating stuff. Class is very much in session, with no (or many) instructors, with no lectures (but wikis and weblogs).

  4. Paul says:

    On programming as art: one problem is that the code that has activated beauty centers in my brain has often turned out to be a nightmare to debug. Trivially extensible, elegant: yes. But not fun when something isn’t working. I suspect it has something to do with art being related to saying a lot with a few words/brush strokes: ‘Elegant’ math proofs are usually the short versions. Being overly verbose in code removes the beauty, but increases the practicality when you’re debugging. I’m positive this isn’t a universal rule (overly long code often being worse than too short code), but it does discourage me from getting too elegant at work.

    As to ‘creative programming’, the solution might be to teach programming earlier in middle/high school. If programming takes 10 years to master, it might be too soon a year in to expect appreciation of code beauty from the practitioner. Given how much science requires computation and how many office tasks can be replaced with a perl script, I think programming is becoming generally useful enough to teach children.

  5. If it sounded as though I am hostile to the notion of academia … I am not. But I am hostile to ingrained organizational behaviors that no longer make sense.

    Universities used to be these wonderful little islands of knowledge and sharing, with relatively limited outside contact. As a student, going to University was wonderful (long ago in my case). Much progress was at universities, as sharing among the isolated minds outside university was limited.

    Now the situation is almost the reverse. All those minds that left university are now more closely connected (and communicating!) than were on-campus folk just a few decades back. Old organizational habits have on-campus minds publishing into places hidden from public view. (If you cannot find it in a Google search, to a large measure it does not exist.)

    All of which tends to render academia less relevant, and that is very sad. Odd that once-centers of advancement are so behind.

    The software group at the local university (UCI) offers an “ISR Distinguished Speaker” series. Been to a few (some were good). But getting to the campus, and driving back (almost invariably in Friday afternoon rush hour traffic) is not fun. Walking out on a bad presentation is uncomfortably rude (for me at least).

    (Something odd about an “Institute for Software Research” that still cannot manage a webcast, and has trouble posting videos.)

    There is another possible side to this. Programming and placing your work in the very-public place of the Internet means many more minds will see your work. If your work is not very good, it will be hard to hide. Some egos may not be able to bear the risk.

  6. Guess I have drifted a bit from your starting point. From my point of view, the “center” of progress has largely moved outside universities (at least for software). I think that is unfortunate.

    Google and Yahoo have developed a habit of capturing interesting videos and posting to the web. I would hope that universities could re-capture those centers (if they have good folk doing interesting work, this should be very possible).

    Heh. I wonder if a future measure of an academic might be the number and quality of the subscribers to their weblog – not so dissimilar to peer review. 🙂

    Yes, I would hope for universities to place all they could onto the web.

  7. dH says:

    I think until a 17 years old kid can make a video chat system in two weeks that can attract 1,5 million users a day, there is no way he will ever can be motivated by his school to do it as a homework. In this area /programming/ it’s unprecedently easy to materialize your thoughts into a product, while for most mathematicans first you need a context or team who will build that rocket using your calculations.

  8. Kevembuangga says:

    If programming takes 10 years to master

    I am a messy but successful programmer (cowboy programming) and it took me 3 months to master the thing during my initial training. I am just as bad/good that I was then, yet I did a few astounding feats like doubling my salary two years in a row (x 4) at the beginning of my career or cloning the IBM HDLC token ring protocol without any documentation whatsoever*, only spying the messages with a line analyzer (about like what Tridgell did with Samba).
    I have no doubt that a few other open source developers have a similar story.

    Maybe the academics are a bit intoxicated by the “learning”?

    *) It took 6 months to graft this into a bare bones point-to-point HDLC protocol and the project manager of this product would not believe I did that so he reviewed all my code and in the end congratulated me for sticking to his programming standards better than his team.
    (I know, I know, I am bragging but this is more to deride “academicism” which really pisses me off…)

  9. gavin says:

    Paul, you have to read some of what Richard Gabriel has been advocating for sometime now, essentially a MFA in Software approach, http://www.dreamsongs.com/MFASoftware.html. I think you’ll find some kindred ideas.

  10. Itman says:

    Great post, I just love Knuth citation. To add a few thoughts of mine:

    1) Knuth IS a mathematician, not really a programmer.

    2) I’d rather add to the list of similarities: programmers are known for the bad and buggy code they write (the first versions of the great code are often awful, then, comes refactoring and bugfixing). This is similar to great mathematicians: if you prove a theorem that nobody proved before, the first proof is often buggy, tedious, and contains errors.

    3) The good and reliable code is usually beautiful.

    4) Last, but not least. Education and training did make me a MUCH better and efficient programmer than I was in school.

  11. Itman says:

    I suspect it has something to do with art being related to saying a lot with a few words/brush strokes: ‘Elegant’ math proofs are usually the short versions. Being overly verbose in code removes the beauty, but increases the practicality when you’re debugging.

    @Paul, it depends greatly on what you are considering elegant. From what you are saying, I can understand that elegant means some overengineered design. However, in many cases, simple and elegant solutions do make your code simpler, smaller, and much easier to debug.

  12. Muhammad Alkarouri says:

    I think the main difference is that there is not much specialisation inside programming, as compared to mathematics, and that is due to programming being a much more recent activity. Let me explain.

    Originally Mathematics contained a lot of practical as well as theoretical aspects. These included things that are related to geometry (earth measure), accounting, statistics for government purposes, etc. Over a number of centuries, we learnt to divide all this range into theoretical mathematics which represents an investment of humanity for various reasons (potential huge breakthroughs for other disciplines, artistic and aesthetic reasons) and applications which evolved into other disciplines.

    The general public doesn’t differentiate between various levels of computer science, software engineering, programming, etc. Not that we do have clear distinctions, anyway.

  13. Paul says:

    @gamin: thanks for the link, I do like those ideas alot. In particular I’m fond of the suggestion for analyzing small code choices in detail. The parallel between writing and programming seems very strong.

    @Itman: Yeah, it’s hard to precisely phrase my thoughts here. I agree that simple, easy to debug solutions are often elegant, and certainly lengthy is in no way synonymous with quality. Perhaps examples would state my point better: highly templated C++ code, for one, like you’d find in Boost. There can be so much going on, so many nested templates, but when you finally piece it all together, there’s this paucity of expression in those templates that’s at once beautiful and maddening. Or closer to the over-engineered example, there’s trivially extensible code where whenever you find you need to add a feature it’s only a line or two of code away…but at the cost that the inner workings are so generic it’s never clear what they’re actually doing. Maybe it’s overengineering, maybe certain problems are innately complicated, but from an aesthetic point of view code I’ve really enjoyed reading hasn’t regularly turned out to be the best to debug. I’ll also say this doesn’t really apply to individual algorithms, like you’d find self-contained within a single function.

  14. Itman says:

    @Paul,
    I can hear you. There is a fine line between elegance and simplicity. Generally, templates are very useful. As well as C++ macros. But like many other powerful tools, it is easy to shoot off all your limbs.

  15. I would suggest that you add “clarity” as a dimension of “elegance”.

    In C++ you can use operator overloading, overloaded methods, implicit conversions, and templates to write code that looks short and simple – but is entirely lacking in clarity. (Been there, done that – in the early 1990’s when first starting to use C++.)

    No matter how short the code, if you cannot readily understand what the code does, the result is not “usually simple and effective”.

  16. Kevembuangga says:

    On the other hand, programming doesn’t require anywhere near a comparable level of effort.

    And nothing like “elegance” according to Joel.

  17. Jon says:

    “For most people, mastering even part of Mathematics requires a decade or more.”

    On the other hand, programming doesn’t require anywhere near a comparable level of effort.

    You comparison falls apart in lots of places. Inventing new theorems requires much more creativity and understanding than coming up with a hit iPhone app. Mathematics has also changed the world much more than Google has. (And open source, seriously?)

  18. @Jon,
    To become an “average” programmer, you may be right. The effort level is (presumably) not nearly that needed to become a first-class mathematician. Then again, what level of effort is required to become an “average” mathematician?

    I majored in Physics in school. Rather a lot of math in Physics. Was told by a friend that he thought my workload was a lot higher than his (as a Mathematics major) – and I seem to recall general agreement from the others present in his major. (We tended to study together a lot, due to shared math classes.)

    Seems I might have some relevant notion about workload.

    I think you have this backwards. The level of effort is a product of your interest and ability. The result comes from the effort of which you are capable.

    You can apply a high level of effort to many different areas, if you are capable.

    As to the “hit iPhone app” and the creativity and understanding needed, you are undoubtedly right – some of the time. (Though I could be over-rating the average for Mathematicians.) On the other hand, there are problems in designing software that stretch the mind, and can require all your ability to overcome.

    I would guess that you are far more familiar with what is hard in math, and not so familiar with what is hard in software. 🙂

  19. Itman says:

    @Preston, I cannot agree more. Actually, so called creative math is 90+ percent crap that is neither creative nor correct. Very much like programming.
    As to the programming impact on our world: considering the first tabulating and punchcard machines, it exists for 100 years. Unlike math that exists for thousands. Yet, almost every gadget that we use has a programmable component. And this is only a beginning!

  20. Yuhong says:

    I like this post.

  21. @Jon

    A CS bachelor’s degree, or really, much less than that, makes you a decent programmer.

    We are squarely in the domain of perceptions and values. Many Computer Science students at the graduate level cannot program at an expert level, by industry standards.

  22. Jon says:

    “To become an “average” programmer, you may be right. The effort level is (presumably) not nearly that needed to become a first-class mathematician. Then again, what level of effort is required to become an “average” mathematician?

    I majored in Physics in school. Rather a lot of math in Physics. Was told by a friend that he thought my workload was a lot higher than his (as a Mathematics major) – and I seem to recall general agreement from the others present in his major. (We tended to study together a lot, due to shared math classes.)”

    If you are in college, then you choose your own workload (unless you are a slacker, but then why go to college?).

    A math bachelor’s degree does not make you a mathematician at all, much less an average one. A CS bachelor’s degree, or really, much less than that, makes you a decent programmer.

    The number of programmers is so much smaller than the number of mathematicians that this comparison isn’t at all fair. I don’t think that Daniel’s list of distinguished programmers (Knuth et al.) is very impressive, though.

  23. @Jon,
    We have very different standards for “decent”.

  24. Kevembuangga says:

    Worry instead about creating a new kind of application that will change the world.

    Tsk! tsk! tsk!
    Don’t tell that to Daniel (he doesn’t believe in “heroes”, in programming either I guess)

    P.S. Speaking of programming skills, I have personally known the author of the 4D Database and had made an estimate of his productivity: he were singlehandedly doing the same amount of work than about 40 good developers, sheeesh… nothing to see here, move on!

  25. Quote: “Even if you have extensive training in Mathematics, the average Mathematics paper is undistinguishable from the ramblings of a madman. Many of these papers seek to solve narrow problems. And yet, we respect Mathematicians.”

    Quote 2: “If you dig into the average source code, it is undistinguishable from ramblings, even if you are an expert developer.”

    Although the difference is here, it is hard to tell. I am a mathematician, and a hobbyist programmer (I’m no programmer, but I can write code, and read code without any problems, but don’t work directly in software engineering). And have to disagree. I know a lot of people working on real programming, and I can tell (and they can too!) that what they do *are* mad ramblings. Yes, the average mathematician’s paper is also, but it solves something and usually is well-written and documented. But most of the software I’m referring to (mostly bank systems, ATM control centers and such) is… well, not that good. Is just a mix of code, without any real intention to be pretty.

    Programming is an art *sometimes*. There are wall-painter programmers (also mathematicians, mind you), and the art in this is zero. Why programming is viewed as flawed (by some, I don’t think it is as widespread as you say) is because the sheer amount of programmers falling into this category.

    As a little proof of concept, this Coding Horror “Horror” history about interviewing: http://www.codinghorror.com/blog/2007/02/why-cant-programmers-program.html

  26. Kevembuangga says:

    You are comparing to lousy developers.

    I don’t think so, I have seen him ditch 15000 lines of code because “they didn’t feel right”, rewrite all from scratch and have the stuff up and running in a week, ever tried that?

    Though, I will agree that productivity varies by an order of magnitude.

    Already in the 70s, according to a US army survey, they found a factor 26 between the best and the worse DOD developers (who were nevertheless qualified professionals).

  27. Amir Michail says:

    Don’t worry about the code. Users will not see it. Worry instead about creating a new kind of application that will change the world. It’s application — not implementation — level creativity that matters.

  28. Itman says:

    Kevembuangga,
    You are comparing to lousy developers. Though, I will agree that productivity varies by an order of magnitude.

  29. Itman says:

    Kevembuangga,
    I easily believe the dropping part. 🙂

  30. Lailatul Maghfiroh says:

    A program is an algorithm and so are mathematical equations and procedures.
    So that programming often provides the motivation for mathematical tools.
    particular, we believe that programming can develop problem solving skills, encourage students to be more attentive to their work, and persevere in tackling difficult problems—goals for students in every mathematics classroom.
    Programming forces students to be explicit about their problem solving strategies.
    Since the computer can only do exactly what it is told, students need to show precision with their process of translating their plan into code. This forces students to focus on details that they might normally bypass because of difficulty. can allow students to naturally grow their problem solving abilities.