Video Tutorial To Start Developing Web Applications on Erlang

Please find hereunder a video tutorial highlighting the key points of developing a JSON based web application with Erlang and Mochiweb.

Note that, for best performances (HD Definition), you have to directly go to the Vimeo website where the video is stored and watch it in full screen mode.

You may want to download the video. In that case, you will have to follow the instructions at the bottom of the video page on the Vimeo website.

Click on the image below to go the the video page.

Go to the video page

The purpose of all this, aside from arousing your curiosity, is to provide you with a getting started pack and allow you to go a step further in the Erlang web application sphere.

I invite you to download the example application (as illustrated in the video stickyNotes.zip) in order for you to understand all the pieces of the puzzle and to venture behind the scene.

Just keep in mind that stickyNotes is a one shot application that I’ve developed from scratch with the unique aim of illustrating the video example.

Having said that, any comment or suggestion is always welcome, especially about ‘struct.erl’, a module that I’ve created when I was learning the language in order to play with the tree structure resulting from the mochijson2 decode function.

We are using it in our mainstream development and I’m still wondering if I might have missed something important with regard to the Erlang distro or Mochiweb itself.

In order to install this stuff on your system and assuming that Erlang is properly setup on your box, just follow these steps:

1) Download stickyNotes and extract the archive in your home directory:

stickyNotes.zip

2) cd to stickyNotes dir and compile the code :

make clean && make

3) Start the application and initialize the db from the Erlang console (only once)

./start-dev.sh
stickydb:reset().

4) Browse the following address 127.0.0.1:8000

Super easy isn’t ?

Enjoy

10 thoughts on “Video Tutorial To Start Developing Web Applications on Erlang

  1. Wow, excellent video.

    I’ve been playing around with Mochiweb a bit lately, but never gotten far past the “hello world” level with it. This really shows off how to get up and running :)

  2. Given that the structure of the JSON return values is {struct, X} you can actually make your struct module a parameterized module with a Proplist parameter, and call things in-place like the Request “object” in mochiweb. This would probably break if they optimize parameterized instances but it works fine now ;)

    Here’s a minimal example:

    -module(struct, [Proplist]).
    -export([lookup/1, to_proplist/0]).

    key(Key) when is_binary(Key) ->
    Key;
    key(Key) when is_atom(Key) ->
    list_to_binary((atom_to_list(Key)));
    key(Key) when is_list(Key) ->
    list_to_binary(Key).

    lookup(Key) ->
    case proplists:lookup(key(Key), to_proplist()) of
    none ->
    none;
    {_K, Value} ->
    {Key, Value}
    end.

    to_proplist() ->
    Proplist.

  3. @Bob Ippolito

    Thank you very much. That’s certainly the kind of feedback I was waiting for ; ) Your small example brings a good point and I’ll test implementing this module that way. I really appreciate it.

    @madlep, JT Archie

    Thanks both for your positive comments

  4. This tutorial is clear and complete. The online documentation about web servers in Erlang is desperately poor, but here is all the useful info to get started.

    Looking forward for more info on your server-side work. Nice that you keep it open.

  5. @Tim

    Thanks for sharing. Just as a side note, we didn’t choose to go Restful because we wanted a clear separation between our client side/view stack and the business logic.

    @Justin

    Really interesting article. I like the lightweight approach you have taken.

    My tutorial is definitively not full-fledged app minded as I wanted it as close to the mochiweb metal as possible ;)

    Having said that, we are addressing some of the details you mentioned in your post but using a home made layer since we are not building a http general purpose application.

    We are actually tunneling all of the ‘Jsons’ trough both the GET(jsonp) and the POST method and we are using a unique interface to handle them (the exceptions are few).
    Keep up the good work.

  6. Pingback: How To Quickly Set Up Ubuntu 8.04 loaded with Erlang, Mochiweb and Nginx | BeeBuzz