Erlang/Elixir 对象和函数编程相关的问题

chenge · 2016年12月16日 · 1461 次阅读

今天推上 Fowler 推荐了这个文章,文章的大意是避免泛泛而谈,需要思考和讨论具体问题。

下面就是例举的问题:

  • Do classes help to structure your code? Can namespaces offer the same benefit?
  • Is inheritance helpful or harmful? What about roles / mixins / traits?
  • Which problems does the actor model solve? Which ones are better solved by single-threaded concurrency? What about Communicating Sequential Processes?[4]
  • Do we need encapsulation if we have immutable state?
  • Does immutability help me write safer multi-threaded code? If so, why?
  • Which advantages do persistent data structures have? What are the disadvantages?
  • Is my team more productive in a dynamic programming language or in a language with dependent types? Where do they produce more bugs? How do concepts like type inference, gradual typing, or clojure.specs change that?

最后他用 spacemacs 作为例子,吸取了两个编辑器的优点,成功了。(确实不错,很容易实现 Elixir 的代码提示)。未来的编程一定是吸取了函数和对象的优点才能成功。

作者给了他的答案:

Is FP better than OO? I think this is the wrong question to ask. For me the question is: What concepts and ideas help me to write better code? And that answer might very well be :

“classes (no inheritance), SOLID principles, persistent data structures and immutability”

暂无回复。
需要 登录 后方可回复, 如果你还没有账号请 注册新账号