4 ms·
Sounds like Erlang is close to Dr Kay's notion of OOP - though my Erlang-fu is not strong enough to know if it has polymorphism.
by rickmode 15y ago
Sounds like Erlang is close to Dr Kay's notion of OOP - though my Erlang-fu is not strong enough to know if it has polymorphism.
- thesz 15y agoYep. I should note that OO means "objects having state". You can send identical messages to different processes and they can respond with (structurally) same answers, so Erlang is polymorphic enough to be OO. "Erlang might be the only object oriented language because the 3 tenets of object oriented programming are that it's based on message passing, that you have isolation between objects and have polymorphism": http://www.infoq.com/interviews/johnson-armstrong-oop http://www.infoq.com/interviews/johnson-armstrong-oop
- rudiger 15y agoErlang also has support for extremely late binding method dispatch. It's a bit tongue-in-cheek to call it a lightweight object-oriented programming language, though. I wouldn't use processes as objects in practice. My successful Erlang programs usually use fewer and more long-lived processes than I use objects in C++, Java, and Objective-C.
- thesz 15y ago>My successful Erlang programs usually use fewer and more long-lived processes than I use objects in C++, Java, and Objective-C. I think I could attribute it to lack of tools in C++, Java and Objective-C. You basically forced to use objects for almost everything (especially in Java). In Erlang, however, you have tuples, higher-order functions and pattern matching, among with process creation and message send/receive. They are different from processes (and objects) and that's where your feeling come from.
- silentbicycle 15y agoYes. Rather than having a table of methods in a class or prototype, each process has an event loop with a set of messages it can pattern match on. The rough equivalent of a process changing from one class to another would be tail-calling into a different recieve { (set of pattern-matching expressions) } function. Instead of changing classes, it looks more like a state machine.