Back to Front Page

12.10.2014 Hacking With Myself

or: How to learn Erlang in 48 Pomodoros.

I am looking for a job and I am constantly hearing questions whether or not I am proficient in programming with a language. I always respond that languages and libraries are tools that I have seen come and go and I am proficient in learning new ones if necessary. The latest language that was important for a potential employer was Erlang. So what do I know about Erlang at the point of writing this?

Erlang is a language designed by a Dutch-Icelandic whaler named Erlan Gúdmunsson. It is used widely in marine engineering. Alternatively it is a functional language developed by Ericsson and most widely known and used within the company. I do remember that CouchDB was written in Erlang and that is my level of practical knowledge that I can recall right now. I am not going to Google it right now. That is beside the point.

I had an epiphany that I should actually have some concrete evidence about how easy it actually is to learn a new programming language and I am going to spend 24 working hours on learning and producing something real with Erlang.

The project

I have been recording the weight of my body for a few years now. This is with an intent to lose some weight. I have an application running on Heroku already written in Flask that does exactly that. I am going to rewrite that. Knowing exactly what I want takes some of the edge off. Also, I am going to make the front-end as a single-page JavaScript application. I know, the current thing is also a single page. I am going to use React.js. Need I say that I have not even Googled it before?

So I will still have to learn things like making a REST API in Erlang, operating with CouchDB, setting up the environment and various other things. I will most likely not become proficient in this language within this timeframe. However I want to see how far I can go. My minimum set of requirements is that I can replace the Flask thing with a piece of Erlang that generally performs better and has at least one new feature. I do not have any idea what that feature might be.

The tools

I am going to continue running on Heroku. The front-end is going to be hosted on Github Pages or something else that is completely free and something like a CDN. We will see. The current set of data is on CouchDB on Cloudant. I am going to replicate that just to be safe.

For text editing I will use Vim. I have no idea what kind of tools are generally useful when working with Erlang. I will start learning quickly. If any of these tools will fail me, I will replace them with something better. That is a natural part of learning a new language and assuming the old tools will be any good.

The method

I did say that I will give this experiment 24 hours. In fact I will split this time into 25 minute increments and use a kitchen timer. According to the Pomodoro technique ruleset, there should be a 5 minute break between each 25 minute increment and a longer, 15-30 minute break after four Pomodoros. I will try to follow that.

Mathematically speaking 24 hours is split to 57.6 times 25 minutes. I just do not care. I will spend 48 increments. I will deduct void Pomodoros from the total time.

Following up

I will post more or update this post whenever I feel like it. That does not count as working time.

The app

The application I am building will live on http://erfat.herokuapp.com/

The First Four Pomodoros: hd(s) or tl(s).

Sunday

During the first four Pomodoros, or the first two hours, I spent learning and setting things up. I browsed through the online version of Learn You Some Erlang for Great Good! from the beginning to the end of the conditionals. I also set up version control and installed the environment.

The first look at the language puts it somewhere between Scheme and Haskell. I knew it to be functional so I am not surprised. The lack of strings in the language is not a surprise as I do remember the horror from Scheme. It seems that some of the syntax has also made its way into Python. Ending sentences with a full stop feels like somebody tried to make this into a real human language. That did not go very well when looking at the binary handling side.

Considering the string parsing problems, this may not be the best option for the web where everything is a string.

Five, Six: Wiring Things With rebar

Monday

There is only so much you need to know about the syntactic sugar of language at one go. The book was helpful but I wanted to learn something more. How to create applications? How to download third party packages? I Googled for Erlang and REST and found a blog post that gave me an idea on both things.

After getting a working rebar in my environment I found that there is something fishy in my hosted shell environment that I cannot change easily. So I started looking for an alternative. I have been using Nitrous just for kicks before and a search showed that somebody has had the idea to run Erlang there before me. So I just did that and pulled my repositories over. I decided to use a node environment as a template since it is likely that the front end needs some npm and/or bower heavy lifting eventually.

On my way I also learned that there are various web servers I can use for my REST backend. So far I have stumbled across Cowboy and Webmachine. The blog post I found earlier is based on Cowboy. However the other one is found under Basho Technologies on Github. That is the people behind Riak, right? That sounds cool. I will go that way.

Meta: On the Road

Tuesday

I am not happy with the amount of time I can allocate to this project. Most job opportunities are 40 minute commute away yet within a five kilometer radius in the city. That means a few hours between appointments is idle time in the town. Most of today will be spent on the road.

I did look at my options on the bus yesterday and it appears that I cannot access Nitrous IDE on my phone but JuiceSSH works great. So I will take my tablet, a Bluetooth keyboard, a stand and a mouse. Then I set camp in a cafe between places and find an Android app that beeps after 25 minutes.

Presto, I am plowing on on the bus.

Oh and the title refers to Billy Idol