inicio mail me! sindicaci;ón

Erlang is damn intuitive

Erlang is a multi-paradigm language since it has functional, declarative and imperative functionalities. Erlang exploits concurrency in a wonderful way through an asynchronous message-passing model. Erlang’s processes are lightweight (about 300 byte each) and the overall architecture is very fast.

I’m learning Erlang for fun and yesterday I tried to implement the simplest master/slave architecture: a master with N slaves linked to it; when the slave dies the master gets notified and regenerate it.

Sounds quite complicated in… Java but in Erlang takes 50 lines of code.

The key to the heaven lies in link/1 used to create a bond between two processes. When a processes dies Erlang automatically notifies the master with a failure message. The master has to trap those kind of messages with processflag/2 and handle them in the receive block.

Does the module sound simple? It is simple.

master slave

Related posts

  • Toying with Erlang
  • Erlang and the GUIs
  • Lost comments
  • Installing stuff in Parallels
  • Zurich City
  • Leave a Comment