My Erlang Talk With Gridlock

I’ve been pushing hard on learning Erlang for about four months now, and this week felt like a good time to give a talk on what I’ve learned so far. To aid in my learning back in December I started developing Gridlock, a multi-player minesweeper clone that I’ve built in the past with Node and Rails.

All in all it went really well and I am excited and ready to dive into learning Elixir next. I have enjoyed learning functional programming languages and think there is some really good lessons to learn from them. I’m not sure what will be on my horizon next; however, I feel more confident having added this knowledge to my tool belt!

One Year at the Terminal

I have been programming now with the terminal, mostly Vim + tmux, for about a year. The road has been long and at some points very frustrating. If there are any out there programming and would like to get started here are a couple of nuggets of wisdom that I’ve picked up on my “journey to enlightenment”.

No More Accidental Pushes to Master

If you’re like me; sometimes you’ll get cranking on some code and before you realize it, you push your changes back up with the help of tab completion auto-populating your branch for you… which was master. You quickly realize the pain you’re in as all kinds of amazing build processes kick off with the ceremonious event of a new master build! After doing this twice in a year I decided to find a way to help prevent myself from doing it again.

Wii U

Got a Wii U yesterday and my productivity has come to a grinding halt. I hope to find balance with this new toy that seems to take all of my time :)

Insane Fun’s

I ran across an Erlang fun that could recursively calculate exponentials and it was very perplexing at first.

fun(X) ->
G = fun(_, 0) -> 1;
(F, Y) -> Y * F(F, Y-1)
end,
G(G, X)
end.

This is double the fun from what I am used to seeing. The outer fun constructs another fun that is designed to take itself as a parameter. Mind blown!

After looking this over for a bit I realized it wasn’t tail-call optimized so after a couple stabs I took it to the next level.

fun(X) ->
G = fun(_, A, 0) -> A;
(F, A, N) -> F(F, A*N, N-1)
end,
G(G, 1, X)
end.

Erlang Map Pattern Matching

One of the new hot topic items in Erlang R17 is maps. In Ruby you would call them a hashes, PHP calls them associative arrays, no matter what you call them it’s the same idea: key-value pairs. Back in the “Good old days” :tm: an Erlang programmer would need to leverage a record to get the same functionality. While records are very good and carry benifit they lack some of the flexibility found in maps.

Splat Operator in Case Statement

Today I learned that this is valid ruby and is yet another example of how awesome the splat operator, *, really is.

EVENS = [0,2,4,6,8]
ODDS = [1,3,5,7,9]
result =
case 3
when *EVENS
:even
when *ODDS
:odds
else
:unkown
end
result # => :odds

Race Conditions

Spent all day battling against a race condition, and boy do they suck. Nothing seems repeatable about the errors and every test you write seems to pass. What kind of beast was I running up against? One of a high-volume nature that would only rear it’s head when the system was under a large strain of course!

The End of a Year

As the year ends I look back at the places I’ve been in the last year or so and stand in awe at it all. Learning new programming languages and living in new locations make for a great combination! All of the changes have left me a bit out of shape though…

Erlang List Comprehensions

Reading through the book “Learn you some Erlang for Great Good” and learned a bit more about List Comprehensions than I knew before. If you are new to the world of Erlang, you’ll soon discover these marvels. Here is some of what I know about them…