Facebook Development (in Erlang)

As promised, here’s the post about the development process of the BeerRiot Facebook app.

Aside: Wow, rereading that last post about the Walled Gardens, I can’t believe I posted it. Totally fluffy lameness. Forgive me – this post will not be as bad.

I could very easily make this another post like others out there right now. Many people are upset about how unfinished the Facebook API is. Documentation is lacking (and only available online), specifications are weak, and test environments could be more feature-rich.

But, except for that little digression above, I promise, this is not one of those posts.

Instead, I’d really like to remark about how great it is developing this app in Erlang and Erlyweb!

There are nearly a dozen different Facebook API implementations – every object-oriented web language you can name. Facebook’s own official one is PHP5. I could have used the PHP version – Yaws comes complete with the ability to run PHP scripts. But, since the rest of BeerRiot is already in Erlyweb…

I rewrote the Facebook client in Erlang. And truthfully, it really wasn’t that bad at all. Erlang comes with very simple HTTP-communciation and XML-munging code. Hell, there’s even a simple way to compute an md5 sum. Once I figured out how to actually put together a proper POST and walk a rather verbose XML tree, the rest was just mimicking as closely as possible the official PHP scripts.

All this is not to say the process wasn’t without difficulties. Yaws’ standard url_encode proceedure doesn’t like nested io_lists very much, so I’m doing some ugly string/binary flattening. And, Facebook’s errors are nearly meaningless … but this isn’t about Facebook complaints. ;)

There are yet more benefits. Rather than dealing with cron firing up processes periodically, I have fully-supervised Erlang gen_servers up to date constantly with what data needs to be pushed out to Facebook. I can log into the running server and examine the current active sessions, monitor profile data pushes, etc.

Extending my existing Erlyweb application to handle new Facebook requests from the canvas page was even pretty simple (once I finally – I think – understood the Facebook session rules). Another controller, another view – bam!

One of my few real pains was source control. I may need to finally bite the bullet and leave CVS. I’m hearing good things about SVN. But that’s another topic.

So, chalk up one more win for Erlang/Erlyweb. Fantastic existing libraries. Quick development environment. Crazy server flexibility. I’m staying as long as I can.

About these ads

7 comments so far

  1. PJ on

    Skip svn and go straight to git. You won’t regret it.

  2. masklinn on

    I support PJ, skip SVN and go either to Mercurial or to Git (just read some doc on both and go to the one you like best).

  3. Bryan on

    Damn. I was afraid this would turn into a VCS list. ;)

    Thanks for the recommendations. I have a plane ride coming up that will give me plenty of time to read.

  4. Top Posts « WordPress.com on

    [...] Facebook Development (in Erlang) As promised, here’s the post about the development process of the BeerRiot Facebook app. Aside: Wow, rereading […] [...]

  5. David Marko on

    This would be great to have app source available as good study material for Erlyweb app. Such real life app example could be a Erlyweb app booster for the others.

  6. passion on

    Developing Environment Related Problem.
    Hi,
    I am new one in facebook.I am want to start the facebook application from scratch.can anyone tell me the developing environment for this facebook in detail.I am thanks to that person.

  7. Moski Doski on

    man, thats soo cool, i’ve started playing with erlang and erlyweb and i am luving it so far …


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: