Looking at the wrong side of persistence

Looking at the wrong side of persistence.

Lastcraft brings up a good point about persistence in PHP in this SitePoint forum post:

The java people write a lot of the enterprise patterns books. That's
OK, because most of these patterns work fine regardless. However one
difference is in how much gets loaded on each request. For example in
Java it's worth loading a big chunk of the database because it will
still be useful on furture requests. We win by cutting down database
traffic. With a Java persistence layer, you feel as if you are working
with a real object that happens to have the common sense to save itself
to the database every now and again. It really does feel like a
“persistent object”.

In PHP that is a difficult illusion to sustain.

Lastcraft continues by suggesting a different metaphor which doesn't
excite me at all. As long-time readers will know, I'm not impressed by
the typical object-relational schemes used in PHP. They are primarily
derivative of Java with all its disadvantages and none of the
advantages because there is no real persistence. The object is
recreated on every page reload due to PHP's shared-nothing design.

But I do think one type of persistence is worth-while
implementing in PHP+Javascript. It's client-side persistence. I'm
talking about a gmail style model, where the objects persist on the
client, the web browser. That makes a heap of sense because:

  • It's very scalable — the data is decentralised.
  • As web-based apps become even more widely used, the reduction of latency will become more important.
  • Persistence schemes where the data is local to the browser will dramatically improve response times.
  • Javascript/Flash
    are sufficiently mature, making it easier to manipulate client-side
    persistent data models with fewer round-trips nowadays.

So in my opinion, we're all looking on the wrong side of the mirror. As
gmail and oddpost have shown us, the rich client is making a comeback.
Better be ready…

PS: I'm not alone, see what Jon Udell says. And here are my notes on Rich DHTML Clients.

[PHP Everywhere – By John Lim]

Leave a comment