Erlang hints for an OO junkie
Tue Aug 10 21:33:10 CEST 2004
Vlad Balin writes:
> There's an another problem. Erlang is functional language, where destructive
> updates and other side effects are not desirable things.
> If you will use processes as a unit of incapsulation (think of it as object)
> you> will introduce destructive updates, and loose the benefits of Erlang as
> functional language.
> If you going to use it your design as a leading principle, the better idea
> would be to use Smalltalk instead, not to emulate it in Erlang.
Desperately avoiding side effects feels a bit like trying to write
Haskell programs in Erlang. I don't know if that's better or worse
than trying to write Smalltalk programs in Erlang, but it'll also lead
to disappointment, especially when implementing a system with a lot of
inherent concurrency (e.g. a switch).
Using a process for encapsulation _is_ a common, normal and useful
thing to do in Erlang. I'm not advocating transforming an OO design
into an Erlang implementation by replacing all objects with a process,
but often a process _is_ a useful unit of encapsulation.
More information about the erlang-questions