Introducción a Programación Orientada a Eventos

De la Wikipedia ():

In computer programming, event-driven programming (EDP) or event-based programming is a programming paradigm in which the flow of the program is determined by events—e.g., sensor outputs or user actions (mouse clicks, key presses) or messages from other programs or threads.

Event-driven programming can also be defined as an application architecture technique in which the application has a main loop which is clearly divided down to two sections:
  1. the first is event selection (or event detection)
  2. the second is event handling.

In embedded systems the same may be achieved using interrupts instead of a constantly running main loop; in that case the former portion of the architecture resides completely in computer hardware.

Event-driven programming is similar to data-driven programming, in that both are structured as pattern matching and resulting processing, though they are typically applied to different domains.

Event-driven programs can be written in any language, although the task is easier in languages that provide high-level abstractions, such as closures 13.6

De Ruby’s EventMachine – Part 1 : Event-based Programming by Phil Whelan on September 14, 2012:

Within an event-based application, everything must be non-blocking to get the real benefit of event-based programming.

The event-loop is running in a single thread within a single process.

Therefore, the first time you do something that is blocking, it causes the whole event loop to stop and wait for you.

That means while you are talking to you database for just 10 milliseconds, nothing else happens.

You would be surprised at how many operations you can perform in those 10ms of halting your entire event loop.

In that time, potentially hundreds of connections, that only hit RAM, could have come and gone, but instead they get queued waiting for your blocking action.

Casiano Rodriguez León 2015-01-07