A monopoly on communication

I came across this article by Salim Virani which describes some of the transgressions that Facebook makes. This goes well with Richard Stallman’s Reasons not to be used by Facebook.

It is more convincing, however, to read the list, prepared by Facebook itself, of a subset of the data that it collects (and saves permanently). Every search, every message, every defriending, every poke. They let you download and view a subset of this subset. For me, this download comes to around 80MB (of which around 31MB is ‘private’ messages).

xkcd: Infrastructures

xkcd: Infrastructures

A few months ago, Facebook disabled Messages on its mobile website in an attempt to get people to download the Messenger app. I refuse to do that, and because of that, I now mostly use SMS messages and emails to contact most of my friends or contacts. (There is a workaround by using the ‘basic mobile’ website, which offers limited (but sufficient) functionality.) Completely leaving Facebook has proved difficult because (a) there isn’t an adequate substitute for group chat, and (b) there are some people for whom I have no other means of contacting. When we meet new people, we no longer share contact details such as our email (or physical) addresses or phone numbers: The default is to add newly-met people on Facebook and to conduct all communication there (and asking for other contact details is seen, ironically, as too personal).

A first step towards society moving away from Facebook should be that we start sharing our contact details properly, as we used to. Mine are available on the home page of this website, and I invite you to tell me yours as well.


  • For group chat, WhatsApp and Skype are problematic for the same reasons. Regretfully, IRC and XMPP are not so widely used, even though they have good merits as open and decentralised protocols. Part of the reason is that Windows and OS X do not ship with an IRC client.
  • This is not primarily about privacy or security. Like any other form of communication, emails, SMS messages and IRC may be intercepted. The advantage of these systems is that they are decentralised, in the sense that your communications are not controlled by a single company. You can switch between email and mobile providers quite easily.
    • Unfortunately, many people’s personal emails are from Google Mail or Yahoo! Mail, which means their email address–that is, part of their identity–is tied to Google or Yahoo!.
    • Although WhatsApp and Skype promise end-to-end encryption, they are closed-source, centralised systems and you have no guarantee of it.
    • Encrypting emails is relatively straightforward using tools such as Enigmail.
  • While they are useful as soapboxes, Facebook, Twitter, Reddit and such are vulnerable to censorship (as discussed in Virani’s post) and therefore should not be exclusively relied upon.
    • An article such as this one (written to, stored on and displayed from my personal website) is at the mercy of only my ISP (currently the SRCF at the University of Cambridge), which would have no motive in taking down this website, and even then I could switch to a different ISP. (Unless, for example, my ISP receives a court order for a takedown, for example if I write hate speech.)
  • On either privacy or censorship, there is little that you can do against a sufficiently determined eavesdropper or adversary. Courts can order takedowns and intelligence services and police have the technical capability to tap lines and crack passwords. Whether they should use these privileges is a subject for policymakers, but there is no reason to give Facebook these privileges as well.

Task scheduling in MPI

I wrote this simple parallel task-scheduling system in C++/MPI, following discussions with Juha Jäyykä. It seems to work most of the time, but fails if jobs finish so quickly or so close to each other that a node does not have the change to update nexttask_ind.

I can’t work out the exact failure criterion, and would welcome any other advice with the code.

/* A simple task scheduler in C++ and MPI. 
 * Usage: 
 *   $ mpic++ taskscheduler.cpp -o taskscheduler 
 *   $ mpirun -np 4 ./taskscheduler Ntasks
// see http://stackoverflow.com/questions/11180624/mpi-task-scheduling
// and
// http://stackoverflow.com/questions/12810391/mpi-asynchronous-broadcast-gather#12810617

int main (int argc, char** argv) {
    MPI_Init (&argc, &argv);      /* starts MPI */
    MPI_Request mpireq;
    MPI_Status* mpistatus;

    assert(argc > 1);
    int Ntasks = atoi(argv[1]);
    /* get number of nodes */
    int nnodes; 
    MPI_Comm_size (MPI_COMM_WORLD, &nnodes);        
    /* get my node rank */
    int rank; 
    MPI_Comm_rank (MPI_COMM_WORLD, &rank); 
    /* get my node hostname */
    char hostname[MPI_MAX_PROCESSOR_NAME];
    int name_len;
    MPI_Get_processor_name(hostname, &name_len);

    /* This is the task that we are currently working on. */
    int mytask_ind;
    /* This buffer stores the next task that needs to be done. */
    int nexttask_ind = nnodes;

    /* We start off by giving task i to node i. */
    mytask_ind = rank;
    printf("Node %d signing on.\n", rank);
    while (true)
        /* Do our task, if there is any more work to do. */
        if (mytask_ind >= Ntasks) 

        /* Do our task. */

        printf("Node rank %d on %s is now doing task %d.\n", 
                rank, hostname, mytask_ind);
        /* Whatever we're doing takes a while... */
        int usec = 0;
            if (random() % 100000 == 0) 


            /* Every now and then, check for updates to nexttask_ind from other
             * nodes. */
            if (usec % 100 == 0)
                for (int node = 0; node < nnodes; node++)
                    if (node != rank)
                        int flag = 0;
                        MPI_Iprobe(node, MPI_ANY_TAG, MPI_COMM_WORLD, &flag, mpistatus);
                        if (flag)
                            MPI_Irecv( &nexttask_ind, 1, MPI_INT, node, MPI_ANY_TAG, MPI_COMM_WORLD, &mpireq );

        /* Advertise the fact that we have started work on this task, by
         * updating nexttask_ind. */
        mytask_ind = nexttask_ind;
        for (int node = 0; node < nnodes; node++)
            if (node != rank)
                MPI_Isend( &nexttask_ind, 1, MPI_INT, node, 0, MPI_COMM_WORLD, &mpireq);


    return 0;

libpnghelpers: A simple C library for PNG files

I have made a small and simple library for creating PNG files in C. The source code is available here.

The library (especially the workhorse inside it) is largely taken from Ben Bullock’s tutorial. I added some extra functions: a constructor and a destructor are provided, some error-handling is added, and there is a routine that creates an image out of a two-dimensional array of doubles.

To compile and install: Change the INSTALL_PREFIX in Makefile to an appropriate location (possibly something like /home/username/local or /usr/local, and then run

$ make
$ make install

To use, compile your code and link using the flags -lpng -lpnghelpers.

Some example codes are provided, although usage should be self-explanatory.

About this website

This is the first post on this website. At the moment, it consists of just a few pages describing me and my work. Occasionally, I will post things about maths, science, computing, Chinese history, or anything else that interests me.

I am starting this blog as part of a migration away from Facebook. There are several reasons for this, many of which are privacy-related. Richard Stallman and the Free Software Foundation has a more detailed list of Facebook’s transgressions. Below I explain some of the main points.


When people talk about ‘privacy’ on a social network such as Facebook, they often think about controls that keep co-workers, bosses or students from seeing posts that they make in their personal lives. This is an important aspect of privacy, and while Facebook does not offer complete protection, it has made improvements, and a savvy user can achieve these controls quite easily.

But the true danger to privacy that Facebook presents is that Facebook themselves may read posts or things said in supposedly private conversations between users. The danger is not that Mark Zuckerberg will personally read your conversations and use it for blackmailing or shaming you. Rather, it is your usage patterns, writing style or unconscious behaviour which give away the most interesting information about you. Facebook is also capable of tracking your browsing habits on other sites. Logging out doesn’t protect you from this tracking.

The upshot: Even if you never write a message or post a status explicitly stating anything, and even if you give a false name, age or gender, it is easy to build a detailed profile of you, by linking together all of the information that is collected.

Targeted advertising is not a huge worry for me; I never pay attention to adverts anyway. I am most concerned by the prospect of medical information being collected or deduced: an insurance company could use this to set my premiums, or a prospective employer could discriminate against me based on my medical conditions. (The latter may be illegal, but that wouldn’t necessarily stop them.) This is not an unfounded concern: one of my friends noted that she was getting adverts targeted towards one of her conditions.

Ownership, openness and censorship

Centralised, proprietary systems such as Facebook, but also other networks such as Tumblr or WordPress.com, are not a sensible medium for storing or publishing media such as articles or photos. The danger comes from (a) the possibility that the service could be terminated with little or no warning, causing your media to be lost, and (b) the possibility of the host censoring your media.

I don’t know anything about copyright law or fair use, but the prospect of Facebook using my photos as their own (perhaps selling them off as stock photos, for example) is actually a fairly minor concern for me.

Facebook can censor posts arbitrarily. In 2014, it removed a photo of breastfeeding. In practice, its censorship seems to be motivated not by its own morality, but its desire to keep itself unblocked in countries such as Russia and Turkey. It does this by censoring pages of dissent, essentially to appease the Russian and Turkish governments.

Although there is no evidence of WordPress.com doing the same, one has no guarantee against it.

This website is hosted independently server in Cambridge (but independent of the University Computing Service), and is far less vulnerable to this sort of censorship. If I posted something illegal, libellous or extremely controversial, then the service provider may order the shutting down of this site or the government may order my arrest, but these powers are subject to public oversight, and are harder to abuse.

(Note that WordPress.com refers to the blog hosting service; this website is powered by the software WordPress but is hosted independently.)

Facebook as a walled garden

While Facebook can be useful for sharing things amongst immediate friends, the audience of such posts is in most cases ultimately limited to other users of Facebook. Hence Facebook is not really such a public platform. (Contrast that against this post, for example, which can be read by anybody on the Internet.)

Student unions often use Facebook to make announcements, rather than university email. This means that announcements, including important announcements such as upcoming committee elections, never reach students who are not on Facebook or not connected to the rest of the student body. This is undemocratic, and particularly affects mainland Chinese students.


Writing this has taken much longer than I had expected, and I need to go and do some work now, but hopefully it will be useful for persuading some other people to leave, perhaps reverting to email (or even face-to-face contact!) for communication.