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

chenge · December 16, 2016 · 1461 hits

今天推上 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”

No Reply at the moment.
You need to Sign in before reply, if you don't have an account, please Sign up first.