miércoles, 30 de julio de 2008

The complexities of event-driven programming.

A good description of event-driven programming:
He was afraid of the mouse. Among everything he had to learn, the mouse seemed the most impenetrable, and the more he read of the e-mail, the more afraid he became. He had never worked with a mouse before; neither had anyone else at Telligentsia, except for Harry, who had once read some code involving a mouse. There were perhaps a few hundred people in the world who knew anything about it, and most of them were working at Apple or at the two or three companies building mice. The documentation from SM Corp., the company that had built the systems Telligentsia was using, consisted of a few barely comprehensible pages, mostly of C-code samples, which Ethan had puzzled over in growing alarm. He felt horribly stupid about this device that had suddenly become so central to the workings of the system. Everything in the graphical user interface was centered on it: Where was the mouse? Was a button pressed? Which one? Single- or double-click? It was an "event-driven" system, code that was constantly being interrupted by the user through the movement and clicking of the mouse, code that was designed to be interrupted by the user's intentions: here, now here, now here. The systems he was used to, in contrast, moved from instruction to instruction under the direction of the programmer's imagination —if this is true, go here; if not, go there. Now he had to rearrange his mind. He had to know how these interruptions were being generated, what happened to them as they percolated up from the mouse, through the mouse device-driver software, through SM's mouse routines, finally to reach his code. He had to understand the mouse.

(Ullman: p. 43)


Obviously, thanks to abstraction layers, we don't need to do this anymore. However, it's still true that event-driven programming still requires a completely different mindset. Personally, as the Ehan Levin from the novel, I also come from the tradition where you directed the computer instruction after instruction and I still find the whole event-driven paradigm quite mind-boggling whenever I dare take a quick look. Perhaps that's why I feel more comfortable with scripting and Web development.

No hay comentarios: