Leo's Technical Blog

I'm not against patterns. I'm against languages that rely too much on them.

Introduction

user

Leo Soto


python, advising, java, javascript, patterns

I'm not against patterns. I'm against languages that rely too much on them.

Posted by Leo Soto on .
Featured

python, advising, java, javascript, patterns

I'm not against patterns. I'm against languages that rely too much on them.

Posted by Leo Soto on .

Some people misunderstood my last rant as a direct attack against patterns. It's not. It's indirect.

So here I go again: I'm not saying that some patterns are bad by themselves. I'm just saying that many patterns are workarounds for limitations of programming languages that aren't expressive enough. Good workarounds, but workarounds anyway. And that's OK. Some languages are designed to not be very expressive (assembler being the extreme example). But when you start to fill your code with such patterns then it's a good time to question whether you have chosen the right tool for the job.

Look how the abstract iteration over a collection (the Iterator pattern) has become a very common language construct nowadays. It's even in Java 5. Now the pattern is invisible, avoiding distracting noise (example: Node node = (Node)nodesIterator.next())

Look how writing the producer side of an iterator is really easy to do in Python, via generators and the yield keyword. As far as I understand, Ruby's yield works similarly. Hey!, even Javascript got it's own yield (also in spanish).

See? In sufficient expressive or specialized languages, many patterns are invisible, which is a Good Thing.

More examples:

So here is my point: Patterns are not bad. But their abuse is a symptom that something is bad. And often, the "something" is a bad language choice.