As noted a few posts back, my plan had been to start developing in earnest on Nitrogen. But then, days later, I found that Nitrogen is undergoing major revision. Many moons ago Jaamal suggested that I look at Webmachine. So… what better time than the present.

The first thing you’ll notice when you link into the webmachine wiki is the crisp, clear, and inviting presentation. This doesn’t surprise me. I was fortunate to chat briefly with Justin Sheehy at Erlang Factory/Palo Alto. He definitely impressed me as a competent, no-nonsense, easily approachable professional. Both the website and Justin inspire instant trust and confidence.

I had less than an hour to play when I linked into the Webmachine quickstart page. Looked simple as pie, so I dove in.

And it was simple as pie — well, a few minor chin scratches which I’ll note below to save other newbies the ten minutes or so they cost me:

  1. Make sure that you have a working Erlang/OTP release, preferably R12B3 or later.
  2. This, for me, was the hardest step. I’ve recounted my experience in My Day Of Terror — Compiling Erlang on Lenny, August 29, 2009.

  3. Get the webmachine code: svn checkout http://webmachine.googlecode.com/svn/trunk/ webmachine-read-only
  4. First, make sure you have a subversion client on your system. I needed to download the binary from the Debian repository. Otherwise, worked like a charm.

  5. Build webmachine and mochiweb:
    • cd webmachine-read-only
    • make
    • (cd deps/mochiweb ;make)

    I was momentarily confused by the function of the parens around the last step, but said, what the heck, and just did it. It worked.

    • ./scripts/new_webmachine.erl mywebdemo /tmp

      The only hitch here is that the last step left me in deps/mochiweb, so I had to cd back to …/webmachine.

    • cd /tmp/mywebdemo
    • make
    • ./start.sh
  6. Take a look! Point a web browser at http://localhost:8000/

And that was it. My browser rewarded me with “hello, new world.”

Now it was time for sheer daring:

  1. To make this resource handle URI paths other than /, modify the Dispatch term in /tmp/mywebdemo/src/mywebdemo_sup.erl.

    This step registered a blank until I looked back into the wiki to review the dispatch syntax. Clear as a bell. BUT, when you change source, don’t forget to kill the webmachine server (press cntrl C) then a), run make from /tmp/mywebdemo; and ./start.sh.

  2. to make that resource to more interesting things, modify the resource itself at /tmp/mywebdemo/src/mywebdemo_resource.erl.

And — that was it. In less than 37 minutes I had a custom webpage.

Yeah, Justin!

A pebble in the road can loom like Mt. Everest to a newbie.

For many months now I’ve been a spectator at the Erlang marathon. Then, several weeks ago I concluded that it was time to lace up my sneakers and set off apace — that is, adopt the Nitrogen web framework and see if I could develop a serious application for myself.

Now keep in mind, I’m not a professional programmer. I can program in several languages, yes. But on my worst day I can barely boot my computer, much less turn out productive code. My best day may well fall short of your worst. So this decision to get serious about Erlang is a major step in and of itself.

But no sooner did I gird myself with resolve than I came smack up against a mountain. No — two mountains; no doubt simple pebbles from the perspective of the wizards and gurus whizzing their way down the course.

First, I found out that developer Rusty Klophaus is in hibernation contemplating a significant revision of Nitrogen. Okay, I could start with what he’s produced to date. Others have and have developed some promising aps. But what’s the profit of spending hours learning a chunk of technology when you know it’s going to be obsolete by the weekend?

The second mountain has to do with setting up an Erlang development system. I did this once on my old workstation, but may have done it wrong and have lost my notes in any event.

The problem is this:

To develop on Nitrogen I need to run Erlang R13B01 on my Debian Lenny system. The current version of Erlang in the Debian Lenny repository is 12B3 — too far back even for Webmachine. Since I can’t find a backport of R13B01, it seems I need to compile it. Shudder!

So far I’ve downloaded and unzipped the source into /usr/local/src. And I’ve read the README. If I cut through the cruft it looks like:

./configure [ options ]
make

But the ./configure options total confuse and intimidate me. So, before I shoot myself in the foot, I’m hoping that some kind soul can guide me through the process. Or, better yet, point me toward a backported Debian package.

All this was two weeks ago. Rather than proceeding apace on the Erlang course I’ve frittered away valuable time on other stuff.

Amazing how such small pebbles can loom up as major obstacles.

Joe Armstrong on Nitrogen

February 28, 2009

Check out most recent posts on the Nitrogen forum for a lively discussion between Joe Armstrong and the developers of Nitrogen:

http://groups.google.com/group/nitrogenweb

The Old Tigers of Erlang have handed down a wonderful language. I, for one, am deeply grateful for their willingness to share their hard-won experience. Nitrogen, and the Erlang community as a whole, can only be stronger for it.

Bringing Up Nitrogen

December 22, 2008

Nitrogen is a new Erlang-based web framework under active development by Rusty Klophaus. It seamlessly weds the scalability and fault-tolerance of Erlang with the browser-side fluency of Javascript. Nitrogen promises to provide a marvelously clean and lean development tool. All told, it’s just what I’ve been looking for.

Learn more at:

http://nitrogenproject.com/

Rusty has documented four ways of bringing Nitrogen to life:

See http://github.com/rklophaus/nitrogen/wikis

My choice is to run Nitrogen on Mochiweb. As of today, however, the start-up instructions are out of date. Here’s what worked for me:

1. Download and install Mochiweb

* Paste the following svn command into a console command line and run it:

svn checkout http://mochiweb.googlecode.com/svn/trunk/ mochiweb-read-only

This creates a directory called mochiweb-read-only.

* Change the name mochiweb-read-only to MOCHIWEB_ROOT:

mv mochiweb-read-only MOCHIWEB_ROOT

* Under MOCHIWEB_ROOT run ‘make’.

2. Download and install Nitrogen

– Bring up http://github.com/rklophaus/nitrogen/tree/master in a browser.

– Click on download.

Since I’m running Debian Etch, I select TAR.

Nitrogen downloads a *.tar.gz file with an ungodly long
name:

rklophaus-nitrogen-bd73764b194d702f813578d2156b24594cf5ca14.tar.gz

No doubt this name will change when Rusty uploads updated source code. For now, let’s just call it <Rusty’s.tar.gz>.

– Unpack <Rusty’s.tar.gz> with gunzip:

gunzip -c <Rusty’s.tar.gz> | tar -xvf -

and change the resulting directory name to NITROGEN_ROOT:

mv <horribly long directory name> NITROGEN_ROOT

– cd to NITROGEN_ROOT directory

– Enter and run the console command ‘make.’

– Update the $MOCHIWEB_SRC variable in quickstart_mochiweb.sh to point to mochiweb root directory.

3. Compile Nitrogen; start Mochiweb

– Open a fresh console window. Enter and run ./quickstart_mochiweb.sh.

This:
- Compiles the Nitrogen Web Framework.
- Compiles the sample files.
- Starts Nitrogen on top of the Mochiweb server on port 8000.

– Minimize this console window to keep it out of the way.

5. Behold! Nitrogen

– Open web browser to http://localhost:8000.

A handsome black, beige, and brown screen headlined “Nitrogen Examples” signals success.

Here’s how to halt Mochiweb:

– Expand the Mochiweb console
– Enter ctl C to halt the browser
– Enter the character a to pop out of the Erlang shell.

CAUTION: Since Nitrogen is actively under development , these instructions may well change. Similarly, be reticent about employing Nitrogen in a production environment until Rusty posts a stable release.

You can download Erlang here:

http://erlang.org/download.html

And checkout the latest  Subversion image of Mochiweb here:

http://code.google.com/p/mochiweb/source/checkout

I’m a Debian Linux devotee, so I downloaded Erlang and Mochiweb through apt.  Couldn’t have been easier.

Here’s a brief tutorial from the folks at BeeBole that shows how you can do it too… and throws in a few extras:

How To Quickly Set Up Ubuntu 8.04 loaded with Erlang, Mochiweb and Nginx

BeeBole is doing neat things with Erlang and posting valuable Erlang lore on their BeeBuzz blog.  Their Video Tutorial To Start Developing Web Applications on Erlang is a knockout.

I’ve exchanged a few e-mails with the two enthusiastic Belgians behind BeeBole, Yves  Hiernaux  and Hughes Waroquier;  both most impressive dudes.

I’d like to thank them here again for sharing their knowledge.