6 ms·
(I assume this was inspired by https://news.ycombinator.com/item?id=16803874 https://news.ycombinator.com/item?id=16803874) The use of ‘=’ for assignment in pr
by kps 9y ago
(I assume this was inspired by https://news.ycombinator.com/item?id=16803874 https://news.ycombinator.com/item?id=16803874)
The use of ‘=’ for assignment in programming languages comes, not directly from mathematics, but indirectly from the use of mathematics in science and engineering. As an example, consider the formula for kinetic energy, commonly written
𝑚𝑣²
𝐾 = ───
2
Why isn't it written 2K=mv², which expresses the same mathematical equality in a smaller, simpler form? Or any of the other equivalent rearrangements? It's because formulas have a convention, where the LHS is a single term naming the value you want, and the RHS contains the terms for values you have. That is, a formula doesn't just state an equality, it states a method for calculating something. That usage predates programming, and was explicitly copied by early programming languages like For[mula]tran[slator] that were designed for scientific & engineering calculations.
- jonnybgood 9y agoI believe it comes directly from conventional math exposition. In a general form it’s about emphasis. “The change of subject from “The dog bit the boy” to “the boy was bitten by the dog” is similar to the change of subject in a formula, as for example … In each case, the two sentences state the same relationship, but with different emphasis.” [1] [1] https://medium.com/q-e-d/that-loser-woman-mathematician-who-changed-my-life-7df96e218eb1 https://medium.com/q-e-d/that-loser-woman-mathematician-who-...
- no_identd 9y agoSpeaking of subject, I find it helpful to have awareness of changes in agent/patient, and not just object/subject: https://en.wikipedia.org/wiki/Thematic_relation https://en.wikipedia.org/wiki/Thematic_relation https://en.wikipedia.org/wiki/Agent_(grammar) https://en.wikipedia.org/wiki/Agent_(grammar) https://en.wikipedia.org/wiki/Patient_(grammar) https://en.wikipedia.org/wiki/Patient_(grammar)
- hyperpallium 9y agoBecause I started programming before taking maths at school, I didn't properly appreciate equality for a while. Sure, algebra was fine, a(x+y)=ax+ay can go either way; but not ratios and other relationships. What helped me was was geometry, where you can see it's just a relationship. All the components move together; one part isn't priviledged as the result. e.g. you enlarge a circle. It doesn't make sense to ask whether the radius made the circumference bigger, or the circumference made the radius bigger.
- golergka 9y agoI remember starting with QBasic when I was around 7 or 8 years old, and I quickly got an idea – just put in the equations from math homework to find out the answer! Fighting through the error messages without English and trying to wrap my mind around the basic concepts of procedural programming was a world of pain.
- nitrogen 9y agoNice. I had fun in some junior high math competitions in part by writing TI BASIC programs on my calculator to brute force hard problems while I did the easy ones. Eventually they stopped allowing calculators altogether and focused on cheap memorized tricks instead of generalized problem solving.
- deleted 9y ago[deleted]
- nitrogen 9y agoI'm curious what prompted two people to disagree with this comment so quickly, with no comment.
- gaurav_v 9y agoI didn't downvote, but the reason is likely because your comment is off-topic. The parents are talking about experiences un-learning one-sided equality that they picked up programming before learning algebra; your comment is about programming a T-83 to help with schoolwork.
- taylorexpander 9y ago> It's because formulas have a convention, where the LHS is a single term naming the value you want, and the RHS contains the terms for values you have. This is simply not true.
- corndoge 9y agoI agree this is not entirely true, I have often heard physicists express similar formulas in the way the parent described (I.e. 2K = mv^2)
- dnautics 9y agoPV=nRT
- baddox 9y agoWhile I don’t think the terminology is explicitly standardized, I think most people in the relevant fields would call that statement of the ideal gas law an equation but not a formula, the latter being a special case of the former.
- grigjd3 9y agoAs a trained theoretical physicist, I am entirely unaware of the distinction you are trying to draw here.
- baddox 9y agoCan you find any reference to the idea gas law as a “formula?” As far as I can tell, equations without a single variable on the left side are referred to as simply equations, while solutions of such equations in terms of one variable are referred to as formulas. This seems to be the case for every well-known identity I can think of, like the quadratic equation/formula. Can you think of any counterexamples?
- fjsolwmv 9y ago
- kqr 9y agoWhile this reasoning may be common, I don't think it's to anyone's benefit. Talking about "the" formula for kinetic energy seems nonsensical, when there are so many ways to state that relationship. Another option is p^2=mK. But there is a good reason to write it as K=mv^2/2 which has nothing to do with specifying a computation. It is the result of symbolic integration of p=mv with respect to v.
- a1369209993 9y agoAnd, perhaps more intuitively, its the second integral of m with respect to v. This pattern also shows up in eg A = ∫∫τ∂r² for the area of a circle.
- ancarda 9y agoOff-topic: how did you format that equation (K = mv^2/2) so nicely? e.g. mv is in italics. It looks really nice. Does Hacker News have built in LaTeX, or is that just very clever use of Unicode?
- filmor 9y agoIf the expression is supposed to be the definition and not just a derived equality, at least Mathematicians (and some Physicists) would use := instead, just as Niklaus Wirth tried to establish with Pascal.
- dhimes 9y agoor ≡
- Nullabillity 9y agoI've only seen that used for congruence (x ≡ y <=> f(x) = f(y), for some context-dependent f).
- dhimes 9y agoIt used to mean "define" in ancient times.
- bhnmmhmd 9y agoI'm always asking "why haven't scientists come up with more symbols yet?" I also ask "why haven't more symbols been introduced to our keyboards? Just !@#$%&*..." It's strange, esp. when you realize coming up with a new symbol that everyone uses is easier these days than it was 4 centuries ago!
- swiley 9y agoThere are many strange symbols in math already that can be difficult to type without something like LaTeX. I feel like something pronounceable is usually better unless you have a sufficiently general idea.
- fjsolwmv 9y agoYou'd love APL
- paulddraper 9y ago> "why haven't scientists come up with more symbols yet?" Take an advanced math test and try to type it out. Being in no sense historically limited by typewriters/keyboards, you might be surprised at the complexity of the symbols.
- coldtea 9y ago>Why isn't it written 2K=mv², which expresses the same mathematical equality in a smaller, simpler form? Because you want to find the value of K, which means that if it was expressed thusly, you'll still need to divide by 2 to get to the desired result.