Tuesday, December 4, 2012

Part1 - Can Gevent and Socket.IO be an event-driven, asynchronous IO/Networking infrastructure for building near-realtime web applications, keeping code-ability at the centre of it?

Keywords: Event-driven architectural style, Asynchronous IO/Networking, Gevent a Python based event library, Socket.IO comet library, Near-realtime web application

An important question while choosing a technology stack for an event-driven architecture (i.e. problem domain) is:
What is the programming paradigm that would be programmer friendly? [Note! Programmer friendly refers to "lities" like code maintainability, code scalability, code testability, among others.]

The status quo for implementing event-driven infrastructure is => to use call-backs. Of-course, devil is in the details... call-backs have their +ves, but lots of -ves (references: 1, 2) when we seek for the above mentioned "lities". 

Instead, think about... what if programmers could use imperative programming style to tackle this problem domain. Well, the solution don't lie in shifting of programming paradigm itself, but in the possibility to isolate recurring implementation details like call-backs. This gets us to acknowledging the power of DRY principle. Perhaps, what if such a DRY princip can be released with a set of programming language features:
    • Automatically takes care of creating call-backs
    • Creation of a call-back is dependent on a given routine, that is if a routine acts as blocking-type (i.e. blockage of the control flow)
    • Possibility to manually declare blocking-type routines
  Gevent API for Python is such an attempt to incorporate the above mentioned DRY princip into the programming language. In addition, as a side effect this API achieves a clear cut imperative programming style. Which means that call-backs are implicitly present but also make room for explicit declaration where needed.

Importantly, I am already smelling the "lities" being satisfied... is it? Well, in-order to answer this question... it will take some experimenting with the Gevent API. I hope this will be a path to enlightenment and to be convinced of this API friendliness towards code-ability.

Upcoming post will produce a simple prototype which will bring all the above mentioned technology stack and study it further. Here's heads-up to the prototype's repository.