Ian Bicking: the old part of his blog

PHP and Application Evolution

PHP has (until 4 at least) a niche. It's great for quick development of web sites that often change so quickly a whole design is not possible, thus the lack of artifacts keeps you from shooting yourself in the foot by closing and packaging your design too quickly. (comment attached to Zend in the clowns?)
This is often how I feel about object-oriented programming, and somewhere where I think Python's imperative approach is a real feature. Starting on an application by building objects (or doing "whole design") is a bad idea, unless you know the domain well. It's better to get it doing what you need to do, and think about objects along the way. Somewhere you'll notice you keep passing around the same value(s) to a set of functions -- those set of values are "self", and those functions are methods. You'll find ways to split things into modules, etc. Designing objects and modules too early and you'll have lots of circular dependencies and poor metaphors. Of course, you can fix all those, but it's easier to add structure to a naive project than to reshape and restructure a misdeveloped project.

This might be more important in web applications, because this is important when you are starting an application. Web application developers tend to start more applications, since these applications come and go, and can be developed fairly quickly compared to other application domains.

In this way, PHP has the right development methodology -- you start with some HTML, some forms and pages. You maybe factor out a few common parts -- header and footer, say. Then you add more logic in, treating the page like a script. Later in the project's life this seems a bit silly. In the PHP applications I've written, I always end up with a large portion of my files starting with <? and ending with ?> with no HTML literals inbetween. It's also annoying to turn a PHP page into a reasonable function. But the basic concept is still good, even if PHP isn't a particularly good implementation of the idea.

This is something you can do in Zope 2, but the naive implementation is very hard to restructure -- far worse than PHP. It's not clear to me that Zope 3 addresses this problem. It provides many tools for an advanced programmer, but what does it provide for the naive developer? What path does it provide to turn a naive application into something better structured? Or rather, does it even allow a naive application? Zope 3 is heavy on object modeling, but application development should start by developing functionality and then by finding the objects in that functionality.

PHP is a very successful web development language -- and a very successful language, period -- and I think this development methodology (and a couple other features) are to thank for that. Python remains better than PHP in many, many ways. But I don't see much movement in the direction of PHP's strengths. This is disappointing.

Created 29 Jul '04
Modified 14 Dec '04


A pure object-model for web development can also be difficult because the requirements for a project mutate frequenly in some cases. The seemingly unorganized PHP structure *may* actually help in cases where the customer throws in disjointed requests. The thing I love about python is that it's philosophy of operation doesn't corner you like Java can, while encouraging logical structure.
# Eric Radman

A smooth upgrade path from 'scripting' to 'structured application' is also a concern of the Zope 3 developers, albeit it hasn't had that much attention yet.

I don't think Zope 3 is that heavy on object modelling. Zope 3, as Zope 2 has, encourages designing with objects, true, but connecting a new view consisting of a page template and a few python snippets to an existing content item is something I imagine a scripter will want to do. I don't think that requires a large amount of modelling. Customizability is what Zope 3 is all about.
# Martijn Faassen

I feel your pain. It has recently come to my attention that Zope works well for folks who live and breathe it all the time. I don't, so I face the Z-shaped learning curve every time I come back to it. That has stymied my abilities for years now (in hindsight). I haven't built the systems I've wanted to because I always get re-stuck figuring out some alien Zope syntax for doing something that ought to be easy.

I think I'll continue using Zope, and possibly even Plone, for simple things. Sure, Python scripts, maybe even simple extensions. But my current thinking is to add Quixote (the current front runner) in parallel with my Zope installation, for building "real" things, because then I can use a python mindset and the programming model becomes simple.
# Bruce Eckel

As a Python lover who also uses PHP extensively, I find that Spyce ( http://spyce.sourceforge.net ) is the Python web programming solution that is closest in spirit to PHP. With Spyce, all the right ingredients that made for PHP's [initial] success, such as immediacy of learning and integration into an HTML page, are made available while straying as little as possible from how you normally do Python programming (read: nothing much new to learn).

Spyce's Pythonic design involves a small amount of carefully designed features which:

  1. provides powerful HTML-integration features more on par with JSP (such as rockin' custom tags) than PHP (whose tag-related features you need to boost with outside help such as Smarty)
  2. retains the ease and cleanliness of basic PHP
  3. lets you reuse what Python already does well, with the least distraction
  4. allows extension with template processors (such as Cheetah)

Spyce has been around for a while and mature and stable enough for 'heavy lifting'. It was what I settled on after evaluating roughly a dozen other Python web frameworks including CherryPy, Quixote, Skunk, Zope, and Webware, none of which, imo, offered the clarity and ease of HTML integration that PHP provides and thus were not satisfactory alternatives.

Spyce can be made to run on commodity hosting that supports CGI and Python (99.9% do) easily by:

  1. just copying over the Spyce files under a cgi-bin directory
  2. creating a 2-3 line .htaccess file in a directory where your .spy files will run

Voila! You now have Spyce working together with all the features that a Python program on that server has access to (including MySQL, SMTP, etc...)

Spyce can also work on top of fastCGI, mod_python as well as its own server proxying behind Apache or other web server.

Oh... and before I forget... if its default [[ and ]] delimiter tags turn you off, you can use the more conventional <% and %> instead.

The final icing on the cake is that the free SciTE ( http://www.scintilla.org ) editor can beautifully highlight HTML, Javascript and Spyce code separately when you use <% %> and enable 'asp.default.language=3' in its 'html.properties' configuration file!

# Jonathan P.

It is arguably an a priori reality, or stated differently, it should be obvious as being true to unbiased, alert and clear-headed observers that people who perpetuate contrived and implicitly convoluted positions in support of "creationalism" or "creation" are by default just plain dumb, i.e, exhibiting major gaps in thier comprehensive understanding of the real universe, and lost in their own erroneous beleifs and simplistic irrelevant circular thinking. In my experience, such people are typically mistaking a small modicum of progress in their own personal intelllectual development as being a sort of validation for such a position, and license to expound and obsess thereon. They seem to see their advocacy of such views as being a charitable contribution and selfless act. They seem to confuse their own self-imposed incorporation of Christian values of humble stoicism and selfless compassion as representing the elegantly simple solution for our increasingly crowded, diverse and dangerous world, which is in their view in urgent need of a return to simple Christian-style discipline, charity and restraint. Conversely, they may see "science" as somehow being associated with many of the world's current evils, and therefore they opt for the simple Christian dogma, amazingly, somehow uncaringly diconnected from whether or not the scenario and methodology of creation in fact "happened" or could happen here or anywhere.

The Scientific community, inspite of being caretaker of the perpondernace of ever-evolving knowledge describing how life actually does evolve seems to unfortunately remain mostly silent on such matters where a swift rebuff of such views would seem to be vitally demanded. Outright public ridicule, including chiding, taunting of such people is unfortuntely seen as base and "unprofessional" and in contradiction to the right of people to speak their minds in a free society. I propose that perpetuation of such non-science and such non-sense should be differentiated and condemned every bit as much as racisism, antisemitism and pornography are. (as examples). Furtherance of such drivel is counter to the pure thinking needed to solve the emergencies that beset society today. It is blatantly perposterous to place discussions of how life evolves on the untold millions of planets exhibiting conditions capable of supporting life alongside creationist rhetoric as being balanced point-counterpoint subjects, ripe for thorough public examination. So, go ahead, quit tiptoeing; call them out, confront them for what they are: sadly DUMB. Let it be known to the young minds of today, that such absurdly dim-minded positions can not be left to stand unopposed.

# Steve Franseen


I've never seen a blog entry so clearly defined and so well argued that says absolutely nothing. Ian, you must have some really cool blogbots that can spew such interesting bits of blah. ;-)

# anonymous

Yes, perhaps this guy should get out of his intellectual treehouse and do some wrestling in the real world. Enough trying to impress us with your extra brain cells. Where is the wisdom?

# anonymous

Yes, perhaps this guy should get out of his intellectual treehouse and do some wrestling in the real world. Enough trying to impress us with your extra brain cells. Where is the wisdom?

# anonymous