Subscribe via Email

Saturday, January 4, 2020

[morriscode deliberate exploration #2] Erlang Message Passing


Morris-code #2: Jan 4, 2019: Erlang Message Passing
Erlang is all about fault tolerant distributed communication. Goal is to set up an mvp where two Erlang processes communicate with each other.
outcome:
  • build a program in erlang where the processes communicate with eachother

post mortem
did I meet the deliverable? (y/n) and why?
    Kinda. Here's the code. didn't have bidirectional communication working, but I think spawn passed a message to another process.

-module(helloworld).
-export([start/0,server/1]).

start() ->
    spawn(server("Hello there!")).


server(Message) ->
    io:fwrite([Message]).



what I learned?
crashdumps get reported all the time using the online compilers. I may have to install my own compiler so I can diagnose stuff better.
I had taken some example code from tutorialpoint and directly pasted it into an online compiler, and it didn't build. So 23/25 minutes was spent debugging. Got this MVP working above. From my understanding spawn creates a new process that runs the server function.
The code works even if I remove the server/1 export, which is odd.

Didn't quite get bidirectional communication working, but I was reading docs about the receive command that lets you do this.

Debugging was my bottleneck. 92% of my time was spent frantically googling to make stuff work.

lingering questions/next step inspiration for future projects?
using the receive function for bidirectional communication. got a bunch of other projects in mind too though that aren't erlang related. may pursue those first.

update: I'm going to just publish these from notion since it's quicker than making a blogpost each time.

You can find my projects here:
https://www.notion.so/morriscode/Focused-deliberate-exploration-08816681b85240d5a4027a51c968f4d1



No comments:

Post a Comment

Please feel free to give feedback/criticism, or other suggestions! (be gentle)

Subscribe to Updates via Email