16 ms·
> If that were true there would be no point talking about language design at all. Why not? People talk about music, art and, well, design, all the time. > the
by pron 9y ago
> If that were true there would be no point talking about language design at all.
Why not? People talk about music, art and, well, design, all the time.
> the programming community does manage to eventually achieve rough consensus about which language designs are good and which are bad
That still doesn't mean there's no large aesthetic component.
> ultimately there is a fact of the matter when it comes to productivity, however difficult we find it to actually measure.
I agree, except that very large differences in just about anything are pretty easy to measure. I think it is almost an established fact at this point that no great differences in productivity exist between modern languages.
> Identifying expressions with their reductions (i.e. their evaluation) does not come cheap, but it pays a huge dividend in terms of how much it simplifies the space that we need to reason about
All formalisms have expressions and reductions. Their denotation is just different. For FP it's so-called "partial functions" (which resemble computable functions); for classical imperative languages it's Hoare triplets (or some other mathematical object). It's just that the denotation offered by lambda calculus is inconvenient when it comes to interactive/concurrent/distributed programs, precisely because the lambda calculus itself cannot directly represent any of them in its reductions, rather delegating them to externally defined mechanisms (IO types, message passing etc.).
> and my experience is that this does not just benefit the formal model, it helps the human programmer's reasoning in the same way.
I agree, but lambda calculus is quite bad at this compared to alternatives. Where it's good -- sequential programs -- not much help is needed. You can have immutability and the thing FP advocates mistakenly call "referential transparency" (when they really mean a simple denotation) in formalisms that are much better suited to modern programming than lambda calculus.
And I really wouldn't mind saying, well, LC doesn't help with the hard stuff, but it does help with the easy stuff, so we should all adopt if there had been any evidence that pure FP yields a large benefit, but there isn't.
> I've found that bug incidence has gone way down.
I believe you, but think that your experience isn't at all universal. Others may find employing better discipline (including precise and even formal analysis of programs/algorithms) in the languages they like to yield more of an impact, while adopting a very different programming style to be a distraction that just hurts overall productivity.
> I don't think I've ever seen this "looping monad"; certainly what you're describing doesn't sound at all like the usual state monad. Could you point towards an implementation of the kind of monad you're talking about?
Ugh, you made me look up Haskell syntax :)
So, you can have:
fac1 :: Int -> Int
fac1 0 = 1
fac1 n = n * fac1 (n-1)
fac2 :: Int -> Int
fac2 n = go n 1 1
where
go n i x = if i <= n then (go n (i+1) (i*x)) else x
fac3 :: Int -> Cont r Int
fac3 0 = return 1
fac3 n = do
a <- fac3 (n-1)
cont $ \k -> k (a * n)
fac4 :: (Int, Int, Int) -> State (Int,Int,Int) ()
fac4 (n, i, accum) = put (if i < n then (n, i+1, i * accum) else (n, i, accum))
(fac4 doesn't really express the full computation, but I wanted to make clear what's going on; fac3 is a better, though less clear example)
All really express the same computation -- the operational semantics are isomorphic (I could have gotten some of the details a bit wrong, but in general) -- but the functional denotation does not express that. Even in classical imperative languages the denotation (say, using Hoare triplets) is isomorphic. The reason is that the functional denotation, is, well, a function and not a computation. This is a great simplification in sequential programs, but becomes very problematic when interaction/concurrency is involved.
> That aside, the normal representation of recursion in the lambda calculus is already that you form a structure that represents the recursion to happen and then pass it to an operator that actually does the recursion (a Y combinator or similar)
1. FP programming languages are not really Church’s lambda calculus, and the Y combinator in them is implicit. You cannot define a Y combinator in a typed LC. (scratch that -- this is wrong; see comment below)
2. The problem exists even in “proper” LC, as passing the “step function” to a Y combinator or in a monad still yields isomorphic operational semantics that are incomparable types.
- tome 9y ago> 1. FP programming languages are not really Church’s lambda calculus, and the Y combinator in them is implicit. You cannot define a Y combinator in a typed LC. Well actually ... http://r6.ca/blog/20060919T084800Z.html http://r6.ca/blog/20060919T084800Z.html But that's besides the point. Haskell already has a perfectly good recursion combinator called `fix`.
- pron 9y agoSorry, you are absolutely right. This can be done if the language allows for types to occur in "non-positive" positions (e.g., you can do `data T = X (T -> Bool)`, which is a type that doesn't have a model in a consistent set theory, and can't be defined in a consistent type theory). I don't know Haskell, but I'm playing with Lean, where this can't be done (Curry's paradox), and got confused. BTW, I've been told that the limitation of LC I discussed is handled nicely in computational type theories, like PRL, which, I'm told, is similar in many ways to the formalisms I do like (and so should be able to relate the different expressions of the factorial computation), but I know nothing about PRL so I can't really discuss it. I can't judge on how simple PRL is, seeing that the documentation is quite horrific, but my point is that there are very simple formalisms, both for formal proofs, like TLA+ (see my talk https://www.youtube.com/watch?v=15uy9Ga-14I https://www.youtube.com/watch?v=15uy9Ga-14I), and for programming, like Eve (IMO, the most advanced, publicly available programming language, in terms of PL theory), that make this very, very easy; and they're far easier to learn and much more uniform than Haskell.
- lmm 9y ago> All formalisms have expressions and reductions. Their denotation is just different. Well if they have different denotations they're necessarily not identified, no? > (fac4 doesn't really express the full computation, but I wanted to make clear what's going on; fac3 is a better, though less clear example) Well, fac3 is still old-fashioned recursion on its face. I guess you could say it's constructing the recursion to happen later, but that seems like an expected mirror image to how the Y combinator does it - you can compose the recursion and the computation either way around (and I'm not sure from a YC-style perspective we recognise any distinction; as far as I can see Cont r a is equivalent to a). I'm not really sure what you're getting at with fac4 (did you mean to read the values from the state rather than accepting them as function parameters?) - it would only represent recursion if you applied a function that does recursion on it, on it's own it's no more recursive than an ordinary function. Again this is exactly what happens with a plain old function and the Y combinator, so the State monad isn't making any difference. I mean, you can make a monad have an unusual denotation by passing it to an unusual "interpreter" function, sure, but the same is true for any function or value.