Showing posts from July, 2014

Erlang Maps

I am on the process of programming the bitcoin protocol on Erlang. Erlang is great for pattern matching binary messages and the OTP gen_server offers an incredibly powerful way to generate state machines that can talk to sockets.

When decoding different protocol messages, there are a number of variable data attributes that come out. So programming the protocol, I chose tuples as I was starting to decode the first type of message. Soon I realised when coding the second message type, that the decoded values where entirely different and pattern matching a variable number of parameter tuple, would be difficult.

So I thought of proplists. Now this does gives us more flexibility on the list of parameters but we lose the one line pattern matching ability. I regard this last point as important because when we are deep into the state machine, the current state and the message type are key to decide what to do. Pattern matching these it's very interesting from my of view.
It was then whe…