# Why Aspect-Oriented Programming? What's wrong with pub/sub (or hooks)?

Is there any substantive difference between [Aspect-Oriented
Programming](http://en.wikipedia.org/wiki/Aspect-oriented_programming)
and the
[publish/subscribe](http://en.wikipedia.org/wiki/Publish/subscribe)
messaging pattern, where you explicitly publish a message at join
points? (I consider [hooks](http://en.wikipedia.org/wiki/Hooking) and
the [observer pattern](http://en.wikipedia.org/wiki/Observer_pattern) to
be pretty equivalent to pub/sub, too.)

To ask the question another way, is there really any point pushing for
[existing languages to be enhanced to support
AOP](http://en.wikipedia.org/wiki/AspectJ) when you could just use
pub/sub and get nearly all the benefits? With pub/sub you avoid all the
syntax weirdness, the source code transformation weirdness (if you’re
doing it that way), the cultural resistance from introducing AOP to
language that doesn’t already have it, the need to learn a new
syntax/DSL to express join points…

The main disadvantage of hooks seems to be that you need to be able to
modify existing code to use them. They’re also ugly if you want hooks
absolutely everywhere, but against this they’re explicit, they can be
triggered at absolutely any point, and they don’t need language support.

(Some examples: [WordPress](http://codex.wordpress.org/Plugin_API),
[Rails](http://apidock.com/rails/ActiveRecord/Observer).)
