]> Sergey Matveev's repositories - stargrave-blog.git/commitdiff
Лучшее объяснение почему функциональные языки -- отстой
authorSergey Matveev <stargrave@stargrave.org>
Tue, 14 Sep 2021 05:04:14 +0000 (08:04 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Tue, 14 Sep 2021 05:04:14 +0000 (08:04 +0300)
https://probablydance.com/2016/02/27/functional-programming-is-not-popular-because-it-is-weird/
Буквально именно так и ощущаю себя когда программирую на функциональном языке:

    Writing functional code is often backwards and can feel more like
    solving puzzles than like explaining a process to the computer. In
    functional languages I often know what I want to say, but it feels
    like I have to solve a puzzle in order to express it to the
    language.

Ну и отличные примеры того, как испечь императивный пирог:

    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.

и функциональный:

    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…

Именно вот про это я и говорю что для функциональщины нужно по другому
мыслить. Не как yet another ordinary human, а как математик с абстракциями.


No differences found