November 29, 2007

small windows

There's something about a computer hooked to the internet: it's really all about small windows. We open up a program, we get a new window. Change the settings, there's a new window. Check out a website, new window. We move them around, we swap, we toggle, looking for something real, something that will push our buttons.



We say we are multitasking but that's a joke. Every window is there to hide everything else, and if we could see everything at once, we would never be able to work. And I'm not just turning the shirt backwards, we really need partitions, we need filters, we need structures to inject some sense in the randomness, to connect the dots. It's all about small windows.



We share, we comment, we blog, we email, we receive news feeds, we monitor stories, we screen others. It's a wire tap on the world. It's big, it's fresh, it's empowering, but how much do we really share at one time? When we email or comment on a story, 5 or 6 lines is too long: no one has time to read it. We need to minimize the input and maximize the effect. So what do we do? What do we do? Whatever the answer to that is, there is a common thread: we want to make an impact, a difference. We need feedback. We are feedback whores. So what do we do? As the window shrinks, we have less time to impress others and we get violent. We get mean. Violence is a way to control. We need it, because it will lead us to feedback.



When that happens we need to compress our thoughts. It's all about small windows. When we communicate, it's decision time, decisions decisions decisions. And nobody likes to be irrelevant. There is only so much time but we still aim to have an impact.



And it's getting harder and harder. More people get online everyday and the more people there are the less time we have for one single person. That's led to people saying they have a short attention span and that keeps them from achieving more. I think that's completely off. Small windows make us smarter. It's the rarity problem: by having less time to dedicate, we are forced to choose what we will spend our time on next. A short attention span is an adaptation, embrace it.



Look around, explore, surf, discover the world one window at a time. Whatever we are looking for, it's out there. Let's try something new, we can afford to crash, the next window is just around the corner.



Forget about being too small a player and quality versus quantity, nothing is binary: quality will come straight from quantity. There cannot be too many people and there cannot be too many windows. Cause we can stack them up, one on top of another, across the board. Explore, examine, use, evaluate, come back, don't come back. It's your choice. You're the driver. You're rich, you've got windows. A lot of them. I say cultivate your short attention span, there's nothing like it.



It's a scary world if we go against the grain. We need to admit it, we need to click: it's all about small windows.

November 15, 2007

python decorators


"""
DECORATORS
PEP 318
Introduced in Python 2.4
"
""

#-----------------------------------------
# simple decorator
#-----------------------------------------
def log(f):
def new_f(*args, **kwargs):
print f.__name__, ': called'
print args, kwargs
f(*args, **kwargs)
print f.__name__, ': end of call'

return new_f

class Simple(object):
@log
def do(self, *args, **kwargs):
print '...done'


#-----------------------------------------
# decorator without sugar
#-----------------------------------------
class NoMagic(object):
def do(self, *args, **kwargs):
print '...done'
do = log(do)


#-----------------------------------------
# decorator with arguments
#-----------------------------------------
def prefix(text):
def fn(method):
def new_fn(*args, **kwargs):
print text,
method(*args, **kwargs)
#rename the method to be the same as the decorated one
#new_fn.__name__ = method.__name__
return new_fn

return fn

class Args(object):
@prefix('wait for it: ')
def do(self, *args, **kwargs):
print '...done'


#-----------------------------------------
# decorator with arguments and no sugar
#-----------------------------------------
class NoMagicArgs(object):
def do(self, *args, **kwargs):
print '...done'
do = prefix('wait for it: ')(do)


#-----------------------------------------
# chaining decorators
#-----------------------------------------
class Chain(object):
@log
@prefix("I'm chaind but still: ")
def do(self, *args, **kwargs):
print '...done'

November 3, 2007

practical common lisp

Peter Seibel's book Practical Common Lisp is a jewel.


The book introduces the reader to Lisp in a gentle way, but also covers most of the features that make Lisp so powerful: macros, multimethods, dynamic variables...


The book is also filled with historical notes that make for a very interesting read.
Towards the end of the book, entire chapters are devoted to building small apps, justifying the title.


The book taught me about Lisp, but also taught me about OO (sic) and about what a modern programming language should provide. Five stars.