Hacker News new | ask | show | jobs
by antonvs 44 days ago
It’s a pity your father’s perspective didn’t prevail. We’d all be using better programming languages now.
2 comments

It's a notational issue. IIRC Pascal used := for assignment and = for equality testing.

Where this becomes extremely Rorsarch is the spectrum between "notation is absolutely critical: there is only one correct representation of programs in people's heads and we have to match that exactly" vs. "all program text is ultimately syntactic sugar and programmers will just adapt to whatever". History tells us that the C choice of = for assignment and == for equality testing won, but of course that's not a choice in a vacuum and it's tied up with a thousand other choices.

If you have no concept of destructive manipulation of variables, because all the variables you have ever known were the ones in math, you will still read := as equals.
I think parent was alluding to mutability.
Yes! In lazy but immutable languages like Haskell, it is totally fine to refer to the value itself during definition. This is really the same idea that a recursive function can refer to itself during definition. It’s common to define a variable for the infinite list of prime numbers, where the definition requires the list of prime numbers itself.

    primes = 2 : sieve primes [3..]
    sieve (p:ps) xs = let (h, t) = span (< p*p) xs in h ++ sieve ps (filter (\n -> rem n p > 0) t)
Here `primes` is a variable that refers to itself in its definition (called corecursion), and `sieve` is a recursive function.
While I'm a big fan of immutable design, it makes some algorithms much more expensive and ultimately DRAM is mutable. And the example we're talking about could be a loop counter!
A tail-recursive loop handles loops just fine, and is just as efficient. This is a perfect example of the misconceptions that mutable-first programming languages have caused.

> ultimately DRAM is mutable

Ultimately the CPU executes machine code, but I don’t see you directly writing that. You’re cherry-picking to defend an indefensible position.

No parent should have to learn from their child about the abuses computer people have done to mathematical notation.