The OOP Concept according to Erlang

To me an OOPL has the following properties:

  • Isolated objects (= Erlang processes) - if one process can in any way damage another object then you cannot write decent code

  • Polymorphic (example you could send a “print_yourself” message to any
    process and it would know how to deal with it - this makes life easy for the the programmer) -

  • Late binding (You can send a message to a process, and send code to a process, provided the code gets their first, everything is fine)

  • Dynamic (possible to evolve in a biological sense) - keeping the entire world strongly consistent (in the sense of a strict type system) is impossible - even types change with time - in live systems the code must be able to evolve.

All this stuff about classes and methods is “just” a way of defining and grouping
abstract data types.

Inheritance is just a hack - in Erlang/Elixir you can just send a message down a
chain of processes until somebody recognises it.

In my opinion Erlang/Elixir/Pony etc are the only languages which can be called
OO.

Java/C++/Smalltalk do not protect objects - send a “message” (or evoke a method) that leads to an infinite loop and you screw up the system.

Erlang/Elixir are rather nice send a message to a process that sends the process into an infinite loop and you won’t even notice it.

And yes you can break beam code - but you have to try hard.

Alan Kay was right - “it’s all about messages” (as was Carl Hewitt)

Cheers

/Joe

33 Likes