Monday, April 25, 2016

The Problem with Facebook and Global Variables

A few years ago, Facebook was a source of joy in my life. I was actively rediscovering friends who had slipped away over time. Reconnecting, discovering what they were up to, and filling the gap between where we had left and found each other again, ushered in a sense of everyday freshness.

Over time, as a billion people got onboard, the rate of rediscovery diminished, and so did the excitement of eagerly checking new notifications. These days, most of my Newsfeed is cluttered with click-bait, unscientific bullshit, flashy headlines, and "Hallmark" greetings.

Every now and then, somebody posts pictures of an event or vacation, or something extraordinarily interesting. Those mark the high points; the rest is mostly junk.

I don't have the Facebook app on my phone. I've pretty much stopped contributing anything original myself like so many others. The other day I was thinking about why I stopped posting, and it occurred to me that my "friends" list contains contains a motley group of people who I know in very different ways.

We are different to different people. We are different to our kids, to our parents, our friends from undergrad, our professional colleagues, our bosses etc. This is not hypocrisy. This is human nature.

Trying to post something that does not offend at least one of the groups I belong to is either uninteresting or impossible.

Because of a conversation I had earlier today, I couldn't help noticing the parallels of this "context collapse", with global variables in programming. While useful as a hack, when the program (friend network) is small, global variable ("global" posts) seriously screw things up, as the program begins to scale.

If you post something, or declare a global variable, everyone and everything can see it. When you have 20 friends, or a 20-line program, this is not much of a problem. You can use your sense of smell to detect problems, and fix them as needed.

But these beasts, they live on forever. They cause unforeseen errors and gaffes.

In the programming world, the solution is encapsulation; defining variables within a context or a subroutine. These variables are invisible to the rest of the program. They arise as soon as control flows in, and die as control flows out.

For large software projects, this is not just a good idea, but a necessary idea. You shouldn't have to worry about the entire universe getting screwed up, just because you changed the name of a variable.

To be fair, Google+ and Facebook do allow you to customize and limit the scope of pictures and comments you post. That is, encapsulation is possible. But it is cumbersome, and I don't know many people who use it skillfully. Programming is work; posting on Facebook is supposed to be fun.

This probably explains the rising popularity of messaging apps (iMessage, WhatsApp, Snapchat) where group identity is a fundamental building block. Groups automatically provide localized contexts. The proportion of original content that people feel comfortable posting on messaging apps is so much higher.

No comments: