3 ms·
"Python is more like english" Having written non-trivial programs in Haskell, ML, and Python, I agree with this, but I would add: Functional programming is mor
by mbrubeck 17y ago
"Python is more like english"
Having written non-trivial programs in Haskell, ML, and Python, I agree with this, but I would add: Functional programming is more like mathematics.
English expresses some ideas more clearly, while mathematics is better for others. And notations that are more "mathematical" often have other nice properties like composability and equational reasoning.*
*The best example of what I mean by equational reasoning is the Sudoku functional pearl: http://www.cs.tufts.edu/~nr/comp150fp/archive/richard-bird/sudoku.pdf http://www.cs.tufts.edu/~nr/comp150fp/archive/richard-bird/s...
- jrockway 17y agoThe paper you posted is a good example. The conclusion is: sudoku = map (map head) . search . prune . choice Note how the "code" never mentions the data to which it is applied, namely the Board object. This is why I can't agree with the GP's argument that FP is closer to "code" than anything else -- I think it's as far from "code" as you can get. There are no "instructions" here, just an equation representing something complex ("the solution to sudoku"), in terms of slightly simpler parts. The simpler parts are, earlier in the paper, the complex parts; and are of course described there by simpler parts. And, this is not just something that's useful for esoteric mathematics papers; my "enterprise" code in Haskell looks very similar.
- deleted 17y ago[deleted]
- jchonphoenix 17y ago"Functional Programming is more like mathematics." I would completely agree. In fact, I would add to that and say FP is mathematics because its "Functionally" based and was originally created for easy inductive proofs. However, from a readability standpoint, english is better than mathematics, and readability counts for quite a bit if you aren't planning on throwing away your code.
- plinkplonk 17y ago"However, from a readability standpoint, english is better than mathematics" That depends on what you are reading. Try reading differential calculus in English, without using notation. Not to take anything away from your point (and I think it is a good one), but there are all kinds of code. Functional Programs can be astonishingly elegant.