XMPP Adventure

Aug 18, 2011

I’ve been attempting to write my own XMPP server just to exercise protocol development and network programming skills. But when I actually needed one, I realized it doesn’t make sense to roll out my own. There are a lot of issues involved and the most important is time. I simply don’t have it.

Read about Ejabberd and how people have overcome the initial adaption barrier, Erlang. I concluded that learning a new language to be able to tweak the server will be more productive. And, it doesn’t have to be Erlang all the time. I can write server extensions (Components) using Python (Twisted), and C++ (Swiften).

So on to Ejabberd and Erlang!


Using friends

May 15, 2008

I am not referring to the punk next door whom at 2 years old has too much to say but none can be understood; not even the links on your social network account whose friends are really just the ones I want to see; or the people I usually get drank with. No, this is not about them. C++ talks of access and scope that are available when something is a friend [Stroustrup, 1997].

Why am I using it?
There is a limited framework that I have come across where the only easy way to hide controls is to make them delete themselves, and to be able to reuse such controls, I have to create another. Reuse here is an inappropriate term but it is used because in the context I am referring, they are class members. An issue arises then when a member calls delete this; and the compiler does not guarantee to set that pointer to null. Compilers today would be more standards compliant but this particular port of GCC I am using is not.

When am I using it?
There is no way then for checking for P’s validity if it were a member of a class C and when P deletes itself.

class P{};
class C {
    P* p;
    void m()
        if (p) /* is undefined */

Usually, this situation warrants setting P to null after deleting it. However, if this should happen in one of P’s methods this = NULL; is semantically incorrect. Making C::p public is easier but it will be exposing data unnecessarily.

Here comes friend. Declaring P to be a friend will make C’s private parts accessible to P:

class C {
    friend class P;
    P* p;
    void m();

Now I can do something like this:

class P {
    C* c;
    void doSomething()
        c->p = 0; // c->p is actually this
        delete this;

Should you use it too?
Honestly, I don’t know if what I am doing is right. It works for me and as I have said previously there is no other easy way. Well, there might be… 😉


[Stroustrup, 1997] Bjarne Stroustrup: The C++ Programming Language

My new friends say “Hello, World!”

May 3, 2008

Congratulations to Pepper for successfully delivering 3 healthy pups!

Matagtag na Republika

Aug 25, 2007

Isn’t it amazing that the Philippine Peso rose to 46.47 in exchange to a dollar? I was quick to defend this phenomenon that it gains for the Philippine currency a greater buying power in the world market. After having said that to a friend who is a dollar earner, I realized that hard-earned dollar loses on the other end. Take on the red pill from Action for Economic Reforms – Matagtag na Republika.

Hello compiled world!

Aug 23, 2007

Been on the LAMP universe for quite sometime, I lost track of the compiled goodies I used to work with. Regular expressions commonly supported by interpreted languages was the first I looked for. Guess where I started looking…yahoo dance. And there it is, Dr. Dobbs | Regular Expressions in C++.