4 ms·
I think that's a basic misunderstanding of mathematics and physics that is often used as a justification for functional programming. Formulas in physics often r
by vyodaiken 10y ago
I think that's a basic misunderstanding of mathematics and physics that is often used as a justification for functional programming. Formulas in physics often reference implicit state such as the time - which is exactly what imperative programming languages do.
I'm agreeing with you about the difference of perspective.
- mbrock 10y agoBut they don't typically assign a new value to the time variable. It's not part of the normal language of math to have a formula that changes a variable... Time is more like a function variable or implicit parameter, not a piece of mutable state in the imperative programming sense. Such implicit parameters are also part of Haskell, by the way...
- vyodaiken 10y agoI randomly open Feynmans lectures on physics and see E (between the sheets) = sigma/epsilon0 E (outside) = 0 assigning two different values to the variable E. In applied math, there are many expressions in which a variable y is treated as a value (depending on implicit parameters) or as a function y(t) depending on explicit independent variables. This is a matter of convenience, not principle.
- mbrock 10y agoI don't understand the context of that E example so I'm not sure what it means... Is the value of E being mutated as in an algorithm, or does it just have two different values for different inputs like a function?
- gnufx 10y agoI can't find that at feynmanlectures.info, but I think it's describing the electric field in an idealized capacitor -- so yes, a function, as you'd expect. I don't know where the idea comes from that you write basic physics as 'twere Fortran programs. If Feynman had used something like imperative programming in the Lectures, I wouldn't have been as baffled as (most of?) the rest of a class of physics undergraduates confronted with "LET I=I+1" in the introductory programming class. So I have some empirical evidence from the time when your first computer might be a PDP-10 down the road from Tony Hoare, that imperative programming is really unnatural for physicists.
- vyodaiken 10y agoYou missed my point. Probably I expressed it poorly.
- vyodaiken 10y agoIn a physics lecture, the audience is reasonably smart but slow - so you can use compact natural language flavored instructions: e.g. "as we take the limit of x to zero, expression(x) goes to c" which change values of variables. In programming, the agent being addressed is analogous to Turing's dumb schoolboy - it's very literal and needs easy to interpret instructions for each step so: c "= trytocomputelimit(f,x)". In both cases, the state of the calculating agent changes as it follows the steps of the calculation.