Erlang Debugging and UTF-16

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.
No related posts.
