Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

As a programmer who has used variants of SML (F# is Microsofts variant), Haskell, and Python, I would say that in terms of concise expressiveness, you have a point that the functional languages match Python's. However, the true power of programming in Python is that the programming logic is easy to understand. If you are actually experienced in functional programming, you'll realize that it is, in all definitions, code. Python is more like english and thus, the appeal will always be there.


If you are actually experienced in functional programming, you'll realize that it is, in all definitions, code. Python is more like english and thus, the appeal will always be there.

I disagree. Functional programming is about as far away from the machine as you get. When I write functional code, I feel like I am describing the problem I want to solve in great detail, just as I would if I were writing about it. (And despite being "far away from the machine", the code still runs quickly. There is something to be said for describing a solution to your problem instead of telling the CPU which bits of main memory to flip.)

As you go down the spectrum from FP to OOP, your code becomes more code-like. Create object. Call method. Save return value. Pass value to another object. Get result. This is still pretty abstract, though, and a fine way to code.

Then you get to procedural programming (C), and then your code truly is code. Allocate memory. Move bits from register to memory. Set interrupt. It's hard to even see an algorithm in there, there's just so much code.

In functional programming, things are often so abstract that you define functions in terms of other functions without even mentioning the data you are processing. Let's face it; that's not "code".


"Functional programming is like describing your problem to a mathematician. Imperative programming is like giving instructions to an idiot." -- arcus, #scheme on Freenode

(from the Scheme quotes file at http://community.schemewiki.org/?scheme-fortune-cookies)


"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/s...


The 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.


"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.


"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.


I guess I should be more specific. When I say code, I mean "cryptic and unintuitive." Yes, you may say FP is intuitive if you've used it for awhile, but at a glance, Python is much friendlier than ML.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: