Hacker News new | ask | show | jobs
by JackRabbitSlim 2281 days ago
> The math states something much more general, and often much deeper, than some mundane for-loop

Eh? Code can be just as generalized and "deep". The code may (probably) not be usefully executable, but it could describe any concept. At that point it's just "math" again, albeit with different format and symbols.

So I guess your point stands, but its a very thin distinction of common usage.

1 comments

Code can be studied, reasoned about, interpreted with some semantics, and often even turned into some manner of equations. Heck, Standard ML is even defined by a bunch of equations. But very rarely is code written for the same reason a mathematical expression is written. I agree code can be as you say, but most often isn't.

Code, at the end of the day, more often than not, is written to express some logic to be executed by a computer. At least 80%, if not more than 98%, of code is written to express imperative commands to a machine. I say this as a fan of abstraction, Lisp, Prolog, etc. I just don't buy that

    s = 0
    for x in a:
        s += x
    return s
is interpreted with the same generality and depth as

    s := \sum_{x\in a} x,
the latter of which is seen in and of itself more as an "object" which may or may not be used to represent a computation that the code above indicates.