Archive

Posts Tagged ‘Erlang’

Installing Erlang on Ubuntu

April 6th, 2009

Lets rewind to about a month ago. As I usually do, I skipped past the README files and installed Erlang with apt-get. Ten seconds later, I had Erlang up and running on my Ubuntu development VM. Like a bad teenage horror movie, I’m sure you can see where this is going.

Fast forward to present day. I was running into another serious compiler error with Erlang. A few of the Erlang web frameworks were refusing to compile – again. As usual, the error message being thrown by Erlang was as cryptic as Aramaic spoken with a lisp. Nothing turned up in Google about the error. I even hopped on the #erlang channel on IRC hopping to get a few pointers.

No one had a direct answer, but I did get a clue. One person mentioned that Erlang is very good telling you vary far in advance if there will be any breaking changes in future releases. I also found out that I was using an Alpha release. Not good, not good at all.

So armed with this new information and a few hunches, I un-installed Erlang (again) and download the last stable release – R12B-5 at the time of this article. Here’s what I did.

sudo apt-get libncurses5 libncurses5-dev
tar xvzf otp_src_R12B-5.tar.gz
cd otp_src_R12B-5/
./configure
make
sudo make install

I had to install libncurses5 and libncurses5-dev since it wasn’t installed on my Ubuntu development VM.

After building Erlang from source, I went back to compile my code and everything worked. Erlang is definitely death by 1,000 cuts. It’s enough to make a grown man cry.

Post to Twitter

Erik Howard Erlang Erlang, Ubuntu

Erlang Debugging and UTF-16

April 6th, 2009

Erlang

I’ve been teaching myself Erlang.  It’s a great Functional Programming language. I’ve also dabbled a little with Scala.

Besides wanting to learn a new computer language, I’ve also wanted to port some of my high-traffic Ruby On Rails sites into Erlang. Erlang will be able to handle 3x-4x the traffic using less resources. Less EC2 instances up and running means more money in my pocket.

While playing around with mochiweb I ran into a compile error that didn’t make sense. At least it didn’t make sense to my limited knowledge of Erlang. The error was this:

Eshell V5.5.5  (abort with ^G)
1> c("mochijson2.erl").
./mochijson2.erl:38: illegal atom
./mochijson2.erl:2615: no module definition
error

I opened up the file and went to the offending line-numbers and could not find anything out of the ordinary. After a little Googling, I found a post on the Erlang-Questions mailing list from someone who had the same error as I did.

Turns out that there was nothing wrong with the file other than being encoded as UTF-16, which Erlang does not like at all. It would have been nice if the compiler threw an error saying that your source file is in the wrong encoding. Illegal atom / no module definition just doesn’t cut it for me.

Cryptic error messages have been my biggest stumbling block with learning Erlang. I take two steps forward, then one epic step backwards. So the moral of the story is to make sure that all of your Erlang files are encoded using Latin-1 (ISO-8859-1) and not UTF-16.

Post to Twitter

Erik Howard Erlang ec2, Erlang, software development

Twitter links powered by Tweet This v1.6.1, a WordPress plugin for Twitter.