I think that on the higher level Erlang is object-oriented given that you believe in the original concepts discussed around the term. By this I mean isolation, message passing, polymorphism. Erlang's processes can hold on to state, perform actions on that state, and they are isolated from other processes since they can't directly effect each other. Since any process can receive any message (and a message can just as easily be delegated to another process who could send a reply to the original sender) I believe it also fulfills polymorphism. Certainly Erlang on a lower level shows its functional aspects but again I think at the higher level (where you are passing and coordinating messages between processes) Erlang behaves in an object-oriented manner. You just can't get caught up thinking object-orientation is all about classes, inheritance, and method calling (which is different from message passing). That is only how the paradigm has been provided for us in most mainstream languages.
Joe Armstrong已经在他的博客中发表了一篇关于OO的文章,并回答了这个问题。 随着Erlang的流行,我们经常被问到“Erlang是OO吗”--当然,真正的答案是“不,当然不是”--但我们没有大声说出来--所以我们发明了一系列巧妙的方法来回答这个问题,目的是给予这样的印象:Erlang是OO(排序)OO(如果你经常挥手)但不是真的(如果你听了我们实际说的话,并仔细阅读小字)。 顺便说一句,文章对OO有一个很有趣的批评:http://harmful.cat-v.org/software/OO_programming/why_oo_sucks
7条答案
按热度按时间yks3o0rb1#
Joe Armstrong在gone on record中说他认为Erlang是“可能 * 唯一 * 的面向对象语言”(上下文添加了“这个词在Alan Kay意义上的OO”)。Json在同一次采访中指出了Sean Copenhaver在他的回答中所说的同样的事情:在小的方面,Erlang是一种纯粹的函数式语言;从大的Angular 看,它与进程完全类似于Kay-style的面向对象。
koaltpgm2#
引用自维基百科,其中引用自这里:
Benjamin Cuire Pierce和其他一些研究人员认为,任何试图将OOP提炼成最小特征集的尝试都是徒劳的。
但看着自己徒劳的尝试:
所以是的--你可以试着宣称Erlang是面向对象的。但是我可以用同样的技巧把C语言描述成一种面向对象的语言,因为你可以在其中使用面向对象风格并手动实现vtable。
任何一个理智的人看到Erlang的答案都可能是"不" Erlang是一种面向函数/消息传递的语言。
另一个答案可能是"为什么要麻烦分类"/"谁需要知道"?
slmsl1lt3#
I think that on the higher level Erlang is object-oriented given that you believe in the original concepts discussed around the term. By this I mean isolation, message passing, polymorphism.
Erlang's processes can hold on to state, perform actions on that state, and they are isolated from other processes since they can't directly effect each other. Since any process can receive any message (and a message can just as easily be delegated to another process who could send a reply to the original sender) I believe it also fulfills polymorphism.
Certainly Erlang on a lower level shows its functional aspects but again I think at the higher level (where you are passing and coordinating messages between processes) Erlang behaves in an object-oriented manner. You just can't get caught up thinking object-orientation is all about classes, inheritance, and method calling (which is different from message passing). That is only how the paradigm has been provided for us in most mainstream languages.
v440hwme4#
Joe Armstrong已经在他的博客中发表了一篇关于OO的文章,并回答了这个问题。
随着Erlang的流行,我们经常被问到“Erlang是OO吗”--当然,真正的答案是“不,当然不是”--但我们没有大声说出来--所以我们发明了一系列巧妙的方法来回答这个问题,目的是给予这样的印象:Erlang是OO(排序)OO(如果你经常挥手)但不是真的(如果你听了我们实际说的话,并仔细阅读小字)。
顺便说一句,文章对OO有一个很有趣的批评:http://harmful.cat-v.org/software/OO_programming/why_oo_sucks
n3schb8v5#
默认情况下不是,但它是can be。
xtfmy6hx6#
Erlang的创造者Joe Armstrong有一句名言:
c3frrgcw7#
你会称这段代码为"面向对象"吗?
这就实现了这种"二郎级"时钟。