Andrey (azangru) wrote,
Andrey
azangru

Via HN, a beautiful illustration of the difference between imperative and functional programming style, pastiched through an example of a cake recipe:

Imperative:
1. Preheat oven to 175 degrees C. Grease and flour 2 – 8 inch round pans. In a small bowl, whisk together flour, baking soda and salt; set aside.
2. In a large bowl, cream butter, white sugar and brown sugar until light and fluffy. Beat in eggs, one at a time. Mix in the bananas. Add flour mixture alternately with the buttermilk to the creamed mixture. Stir in chopped walnuts. Pour batter into the prepared pans.
3. Bake in the preheated oven for 30 minutes. Remove from oven, and place on a damp tea towel to cool.

Functional:
1. A cake is a hot cake that has been cooled on a damp tea towel, where a hot cake is a prepared cake that has been baked in a preheated oven for 30 minutes.
2. A preheated oven is an oven that has been heated to 175 degrees C.
3, A prepared cake is batter that has been poured into prepared pans, where batter is mixture that has chopped walnuts stirred in. Where mixture is butter, white sugar and brown sugar that has been creamed in a large bowl until light and fluffy…


(source)

Also via HN, an impressively long and outrageously funny commit message in mpv-player.
Subscribe

  • (no subject)

    On the dreadful state of the style of modern Russian communication. "There is no alternative", writes an author, and then immediately outlines an…

  • Via Twitter

    Via a tweet, but I thought I'd get my own copy. A beautiful illustration of how a caption totally misrepresents what's been captured in the photo.…

  • (no subject)

    Here's an extract from Uncle Bob's book Clean Agile. Although he has fallen out of grace with the champions of social justice, the sentiment…

  • Post a new comment

    Error

    default userpic
    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 0 comments