[erlang-questions] How to think and reason when designing process- and message-centric systems?
Mark Bucciarelli
mkbucc@REDACTED
Fri Dec 16 02:39:53 CET 2016
On Thu, Dec 15, 2016 at 12:04:45PM +0000, IRLeif wrote:
>
> This is my first email to the mailing list. I apologize in advance if this
> is odd or off-topic.
>
It has generated some good discussion, thanks for kicking it off!
I have been teaching myself Erlang since June and lurking on this list since
then and have always found it to be welcoming and helpful. I suspect no one
found your message off-topic.
>
> Coming from an object-oriented and data-centric background, I have
> cognitive difficulties when it comes to conceptualizing, thinking about and
> designing systems consisting of modules, processes and key-value data
> stores.
>
Before Erlang, that was my background and how I still make a living.
> ...
> Questions:
>
> 1) How do you unlearn "bad habits" from object-oriented way of thinking?
>
I am not sure what you mean by "bad habits", but will hazard a guess: shared,
mutable state and or deep stacks of inheritance and layers of abstraction.
Erlang prohibits you from these "bad" behaviors by design. For example, once
you assign a value to a variable it is bound to that value. I like to think of
it like a math proof, where you say "Let x = 1. In this case, ..." In a
proof, you would never then say that x changes it's value ... it is immutable
state.
It is interesting to read the original rational for OOP in Meyers orange book:
that nouns change less frequenly in a system than the verbs. Since most
software work is maintence, to minimize maintenance you should structure your
system around the stable things: which Meyers hypothesize was the nouns.
I think that approach has been replaced and that we are at the start of an
industry shift towards a focus on verbs with things like event sourcing and
CQRS. If you want to build a system that focusses on the messages and the
contents of them, Erlang is a perfect fit.
>
> 2) How do you think and reason about process-centric systems designs?
>
Lot's of great responses on this topic already. For me, the simplest thing is
to think of the verbs (messages) in your system instead of the nouns.
>
> I would appreciate any practical tips, examples, "mind hacks" and resources
> that might help.
>
Here are a few that I have found particularly useful.
"The Road to the Generic Server" Chapter in Joe Armstrong's Programming Erlang.
* Builds up slowly the core idea behind OTP behaviors in a accessible
way. (I highly recommend this book in general, but that chapter is
gold.)
"The Universal Server" (http://joearms.github.io/2013/11/21/My-favorite-erlang-program.html)
* Such. an. awesome. hack. I smile each time I think of it.
"Error Handling" (http://erlang.org/course/error_handling.html)
* Concisely presents the primitives that underly any robust process tree.
Planet Erlang (http://www.planeterlang.com)
* Aggregator of Erlang blogs. Unfortunately, it is heavily diluted by
Elixer content.
Blogging about Erlang has actually helped me a lot. To start to write something
for publication pretty quickly tells you how well you really understand it. :)
Enjoy,
Mark
--
Blogging at markbucciarelli.com
Tweeting @mbucc
P.S. My next blog post (this Wednesday) will be a second post on event handling
with gen_event.
More information about the erlang-questions
mailing list