On Erlang, communities, and folding bikes

On Erlang

On the bus into work this morning, I learned something important about Erlang [1] [2]: a Fun isn't the same thing as a function. That is, this does not work:

itemCost({Item, Count}) ->
    Count * cost(Item).

total(ShoppingList) ->
    lists:sum(
      % The error here is in the use of itemCost.
      lists:map(itemCost, Shoppinglist)).

The right way to epxress this is:

total(ShoppingList) ->
  lists:sum(
    lists:map(fun (X) -> itemCost(X) end, ShoppingList)).

I ended up just embedding the logic into the Fun and deleted the itemCost function:

total(ShoppingList) ->
    lists:sum(
      lists:map(fun ({Item, Count}) ->
                        Count * cost(Item) end,
                ShoppingList)).

REPL languages are fun; I got to build this up while in the REPL. I almost decided to just skip over this and copy / paste the code in the book and move on, but spending the time to figure this out was valuable [3].

I was reading the section on building lists in natural order, and the advice is

  1. Always add elements to a list head.
  2. Take elements from the head of an InputList and adding headfirst to an OutputList will result in a reversed OutputList.
  3. If the order matters, call lists:reverse/1.
  4. Avoid going against these recommendations.

I like that. It feels Lispy. Then, there's this advice:

The best thing to do is first write your programs as clearly as possible and then, if there are performance problems, measure before making any recommendations.

Sold.

On communities

I've been feeling a lot lately that I've missed out on having solid technical communities that I can learn from and grow from. I'm not sure how to fix this yet - maybe trying to go to a few conferences this year and meeting people? Maybe finding good meetups in the area?

I RSVP'd to an Erlang meetup Wednesday night; then I realised there's a Rust meetup that I haven't RSVP'd to on the same night. It's on BPF stuff, so it could be interesting - it's certainly up my alley. But I think I'm going to do the Erlang one. I'm not sure if this is the right call, but I guess we'll see how it turns out. Maybe I should try going to PWL again too, but it doesn't look like there's any talks scheduled.

I'm not sure where this all leaves Rust. I know that while some people are doing cool things in Rust, the community so far doesn't seem to have the same peculiar kind of intellectual thoughtfulness and curiosity that I've seen in the Erlang and Clojure communities, and that particular brand is really what I'm looking for right now.

On folding bikes

My commute right now isn't great - I have a 10 minute walk to a bus, which takes, at best, 20 minutes to get across the Bay, then a 20 minute walk to work. Using the Ford Go bikes [4], it still takes about 20 minutes from the bus terminal to the office, but that depends on the bike stations having bikes and empty docks to park at. I use to take my own bicycle, but that's subject to having empty racks on the buses; a bus with full racks means I have to wait for the next bus, which tacks on another 20 minutes. Towards the end of my time at Cloudflare, every few weeks two or three busses in a row would have their bike racks full. The other thing about the Go Bikes is that it takes me 5 minutes to talk to the docking station near the bus terminal, and 5 minutes to park the bike and walk to the office from there. When I worked at Cloudflare, bus to parking my bike inside the office was 7-10 minutes; I also enjoyed that ride (which is similar to the ride I'd be making now, just with an earlier cutoff) - you get to look across the Bay over to the Port of Oakland and you get to do it on a bike.

The alternative to the bus is to take the BART, which is a 10-15 minute bike ride, depending on traffic, then about 10-15 minutes across the Bay, then about another 10-15 minute bike ride. The problem with the BART is getting your bike on it can be problematic [5]; I've definitely shown up to the station to find the Go Bike rack full, and I've found the Go Bike rack near the BART station empty, too.

So, I've been thinking about getting a folding bike. For a commuter, I'd probably do an electric. Ryan pointed out the Luna and there's an electric bike festival coming up around here that should have some test rides and whatnot. Still, we're going to be moving offices this year and the commute is going to get a lot worse and there's no way I'm moving to San Francisco - Oakland is home. My girlfriend is also in the East Bay, and that would just make both of our lives miserable trying to make that work. Something to keep in mind. I'm not sure how viable the SF situation is long-term.

[1]I have the second edition of Programming Erlang loaded on my Kindle for the commute.
[2]It was probably mentioned in the book and I missed it.
[3]I'm trying to balance not getting hung up on things and making progress with building the intuition and problem-solving skills that I'll need later on.
[4]These are shared bikes that you pick up from a docking station and drop off at a docking station.
[5]Just getting on can be problematic...

Tags: