lunes, 8 de marzo de 2010

My name is erlang

I've been introduced to erlang by Prof.Johan Montelius.

I'm enjoying the lectures a lot (the two so far). He's a great speaker (is's quite fun to attend classes) and he managed to explain the basic concepts of concurrent erlang programming in 2 hours (provided you already knew the basic erlang syntax).

I'm taking some notes at class, and I'll eventually clean them and upload them in a blogpost format.

For the moment, here is a silly code I wrote the other day while I was in the bus.

It's interesting how:

  • Concepts learnt previously in scheme and perl (Higher Order Perl ftw!) become useful and appliable here.
  • Pattern matching is stressed to become the basis of method dispatch (with or without guards), variable binding, if/case/any_conditional and message receiving.
  • The Message Passing system is GREAT. Not just the "forget about low level sockets" but the mailbox
    system of each process, and the transparency that frees you from thinking low level.
  • Being a functional language, it does tail call optimization, and in most cases you better take advantage of it, because processes (if you think of them as DFA's) have a long life, and they just travel from one state to other by calling themselves recursively with an updated argument (you can
    pass the state along through the function arguments).


Here's the code. Just a Proof of concept. Two processes sending pings and pongs one to the other. Pretty simple, but there's pretty much a synopsis of the erlang (ugly) syntax and expressions.

2 comentarios:

Unknown dijo...

El Johan és l'ídol mundial. De les millors classes que he fet a la FIB ( i el profe havia de ser de fora...). Els labs son xunguillos alguns per això, que si chordy, rudy, etc. jeje.

Raimon Grau dijo...

No estic a la seva classe 'oficial', sinó a un curs ràpid de erlang que està fent a profes (i enchufats :p )

Vaig mirar la seva pagina i vaig veure tots els foobar-y, pero no me'ls he mirat a fons.