Archive for the ‘erlang’ Category

Building CouchDb on Mac OS X

Friday, September 21st, 2007

I, like Sam, *really* want to play with CouchDb. But I’m a MacOSX box that I barely understand after 3 months of ownership.

Install MacPorts and run:

sudo port install erlang icu subversion

Add these two lines to your .bash_profile (or .profile if you’re running tcsh).

export ERLANG_BIN_DIR=/opt/local/bin/
export ERLANG_INCLUDE_DIR=/opt/local/lib/erlang/usr/include/

Run those two commands in your current shell or open a new one. Now, back to the install.

cd ~/projects
svn co http://couchdb.googlecode.com/svn/trunk couchdb
./build.sh | tee couchdb_svn_build.log
./build.sh --install=$HOME/sys | tee couchdb_svn_install.log
mv couchdb_svn_*.log ~/sys/log

Now, for convenience, we set up an easy way to start the CouchDb server. This assumes that $HOME/sys/bin is in your $PATH. Make a file called couchdb in $HOME/sys/bin containing:

#!/bin/bash/
cd $HOME/sys/couchdb && ./bin/startCouchDb.sh

Next, fix its permissions:

chmod +x $HOME/sys/bin/couchdb

Then, start the server:

couchdb

(I follow this up with a ln $HOME/sys/bin/couchdb $HOME/sys/bin/db but that might not be best for you.) Finally, follow the rest of Sam’s post to get a quick introduction to CouchDb.

Bonus Round: Ruby on top of CouchDb.

There are two Ruby gems for work on top of CouchDb, couchobject and CouchDb-Ruby but couchobject seems the most promising. Why? Well, for one, its respository doesn’t include tests with syntax errors. And, two, it lets you write CouchDb views in Ruby, which is fantastic.

I haven’t gotten a chance to find its limitations, yet, but considering the deep magic involved and the 0.5.0 version number, I’m sure it has a few.

To get it, hit the site for the link to the tarball or grab the repository with:

git clone git://repo.or.cz/couchobject.git

I’m terribly excited. Enjoy!

Update: Now leaving Typo City.

erl_interface is Deprecated and I Hate the Erlang Docs

Sunday, September 2nd, 2007

I’ve been learning Erlang in fits and starts for a few months now, and trying to play with the C interface to it. Unfortunately, it wasn’t until tonight that I learned that the best documented interface, erl_interface, is deprecated in favor of ei. (That link is not all of the ei documentation. See the end of this post).

Oh, but you’ll still have to include erl_interface.h in order to get your code to run since ei requires it. Be careful to put -lerl_interface before -lei.

And all of the docs about interoperability with C have you including both ei.h and erl_interface.h and make no mention of the relationship between them or the deprecation of erl_interface. Hell, they barely mention ei, anyhow.

This is the kind of thing that makes languages on the verge of true popularity spin down until they find themselves in the graveyard of “interesting but irrevelant”. There will be no fiery crash, no awe-inspiring fight to the death, no raging against the dying of the light. Nothing more than the slow frost bite of a crumbling community.

I love what Erlang can do, but if you’re going to make a language that proudly shows it roots in a Prolog interpreter, you’ve got to give the plebeians like me a chance.

Oh, and could we get a decent math library while we’re at it? I shouldn’t have to break out to C just to work with matrices. Combined with a quickly made mnesia database you could have some serious distributed work going.

You would probably have to move to a more lightweight data structure than what mnesia gives, but what a great way to write a proof of concept! Of course, you’ll first have to find documentation for mnesia that isn’t ages old.

Since the mnesia and ei documentation (along with everything else) is pretty much unGooglable in all of those frames, I suggest using the documentation tarball (lastest release). In the the current release, hit ./otp_doc_html_R11B-5/lib/erl_interface-3.5.5.3/doc/html/application_ei_frame.html for ei and ./otp_doc_html_R11B-5/lib/mnesia-4.3.5/doc/index.html for mnesia.

Blech. The things you do for love.

I’ll be writing up my experiences and some posts to help others with ei as I go along. Let’s hope I can be as productive as I am critical.