One of the characteristics of functional programming is as follows:

You’re describing the result you want rather than explicitly specifying the steps required to get there.

I found this quote at https://realpython.com/python-functional-programming/.

I don't really understand what is the meaning of this. Functional Programs still have to define steps to calculate something, there is no magic.

For example, a quicksort in Haskell looks something like this:

quicksort :: (Ord a) => [a] -> [a]  
quicksort [] = []  
quicksort (x:xs) =   
    let smallerSorted = quicksort [a | a <- xs, a <= x]  
        biggerSorted = quicksort [a | a <- xs, a > x]  
    in  smallerSorted ++ [x] ++ biggerSorted 

I don't really understand where the "you're describing the result" part is there. In imperative programming language I'd do pretty much the same thing. The only difference is that probably I wouldn't have a one-liner like [a | a <- xs, a <= x], I'd have to do some loop. However, it's just syntax sugar, normally I'd create my own method/function that does exactly the same thing as [a | a <- xs, a <= x]. So, I don't consider that syntax to be some breakthrough, because it could some as a library in any other language.

Could you help me to understand the meaning of the quote in the title of this post?


1 Answer 1


It's just someone's opinion. I don't find it super persuasive, for the reasons you've articulated. There are some situations where the code in Haskell is a bit closer to a mathematical specification than the code we'd write in C (say), but it seems like it is open to debate how common that is.

Not everything written on the Internet is 100% reliable or authoritative.

  • 1
    $\begingroup$ Thanks, couldn't agree more on the last sentence. $\endgroup$
    – mnj
    Feb 3, 2022 at 9:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.