Ordered Keyword Args in Python

May 18, 2014

I had fun implementing ordered keyword arguments in Python. The code is up on GitHub. It's handy for defining data models, where the order of fields is important. The README on GitHub has more information.

Beware of Sync Platforms

Jul 12, 2013

Recently, Dropbox announced their database sync platform.

At first sight, it looked simple and clean. But I was disappointed when I saw this:

Forget conflicts and combining changes when people use your app from different devices. With datastores, Dropbox can now understand the structure of your app data and automatically merge changes made at the same time. For example, simultaneous edits to a contact's phone number and email address will be merged without sync conflicts or any action from the user.

Any sync-platform that claims to perform automatic conflict resolution is broken. This is because conflict resolution is fundamentally a domain specific problem that cannot be magically solved by a generic platform.

Let me explain with an example.

Dropbox does not consider changes to two different fields of the same record as conflicting. That's a problem.

To see why, consider the following scenario:

My wife and I are going on a picnic with friends. We use a task-list app with two fields per task - "task name" (a string) and "completed" (a boolean) - to create a shopping list that's shared between the two of us.[1]

The list contains the following items that are yet to be completed.

  • 12 AAA batteries
  • 4 foldable chairs
  • bread and butter
  • dry wood for fire

Once an item is completed, it is moved off the list and displayed in a separate section.

Let's say my wife realizes we actually need 5 chairs, not 4. She goes ahead and changes "4 foldable chairs" to "5 foldable chairs". She happens to be offline when she makes this change, and hence this change isn't visible to the server immediately.

At around the same time, I buy the 4 chairs. I go to the app and look for the item "4 foldable chairs" and mark it as completed. The item is moved off my list into the completed section.

Once my wife gets online, the app pushes her changes to the server. My wife's change modifies the "task name" field. My change modifies the "completed" field. If Dropbox were used for syncing, since the two fields are independent, it would automatically apply both changes. Dropbox sees that there are two simultaneous changes to the same record, but it does not consider this to be a conflict because the two changes operate on two different fields.

This effectively results in the item "5 foldable chairs" being marked as completed.

In the context of this task-list app, Dropbox's automatic merging has resulted in a situation that's akin to losing data! We did not buy 5 chairs, but the app makes us believe that we are done buying chairs. That's just as bad as losing data.

In essense, the notion of a conflict depends on the meaning that we assign to the data. Dropbox knows nothing about the meaning. It only knows the shape of the data. And that's not enough to resolve conflicts.

  1. Dropbox doesn't yet allow two different accounts to share the same datastore. For now, assume that my wife and I share a common dropbox account.

What made C great

Oct 13, 2011

The man himself said it best:

C is quirky, flawed, and an enormous success. While accidents of history surely helped, it evidently satisfied a need for a system implementation language efficient enough to displace assembly language, yet sufficiently abstract and fluent to describe algorithms and interactions in a wide variety of environments.

Thank you, Dennis Ritchie, for giving us C.