What is Megaphone?

What is Megaphone?
The Megaphone project is about enhancing open source chat software. Specifically, the goal is to allow ejabberd to support 1,000,000 simultaneous users. See The Plan page for more details on how I plan to solve this problem. See the About this Blog page for more details on why I created this blog.

Monday, December 19, 2011

Why I Love Erlang

Previously

  • I identified a possible entry point for delivering packets from mod_megaphone.
  • I started coding up mod_megaphone.
  • IT'S ALIVE!!
Unfortunately, erlang is not quite that easy to work with.  I spent a good deal of time chasing down an annoying problem where the code was compiling, testing OK, but ejabberd was refusing to load it.  But not to worry, I was getting the following, very helpful error message:

    undef

There is a school of thought that says "less is more" when writing software and I do agree with it.  That error message, however, goes a bit too far.

For the curious, the following statement was compiling OK.  I was able to load it and run the code that was not part of the conditional that it belonged to:

BinConnectionId = binary_part(Binary, ?CONNECTION_ID_INDEX, ?CONNECTION_ID_LENGTH),

The correct statement is

BinConnectionId = binary:part(Binary, ?CONNECTION_ID_INDEX, ?CONNECTION_ID_LENGTH),

Did you notice how the underscore was replaced with a colon?  You did?  Well, why didn't you tell me earlier?!!  At any rate, this was the cause of much hair tearing, but I did finally end up catching it.

No comments:

Post a Comment