×

Loading...

Functional Programming

大学里没学过 FP,F# 刚出来的时候,扫了一眼,TBH,没有 get it...觉得平常用不上...

上周 James_2018 (thanks) 问了那个问题 #11865340 后,又去网上看了看 FP 的一些基本概念,发现其实平常用的很多东西已经是有 FP 在里面了,只是我自己愚钝,没有比较深入了解罢了。

 

这里有个很短的 video 介绍 FP vs OOP in typescript (基本上 ES6 也可以):

看完基本上能了解 FP vs OOP - 气宗 vs 剑宗之争。

但基本上我们 OOP 剑宗也可以用很多气宗的东西。比如 c# 支持 lambda 很久了。

javascript ES6 有了 arrow function 之后,大大简化了 ‘function as parameter': https://codeburst.io/javascript-arrow-functions-for-beginners-926947fc0cdc

也有了大量很好用的东西,比如  map / reduce / filter... https://medium.com/poka-techblog/simplify-your-javascript-use-map-reduce-and-filter-bd02c593cc2d

Higher order functions 语法也非常简练:https://developer.ibm.com/node/2016/01/11/higher-order-functions-in-es6easy-as-a-b-c/

再进一步,javascript 的各种 combinators: https://gist.github.com/Avaq/1f0636ec5c8d6aed2e45

 

另外,对一些 framework 的由来也会更理解一些,比如 redux 的 immutable / reducer 的概念...

 

说得不对的地方,请批评指教。

 

Report

Replies, comments and Discussions: