Posts tagged: PROGRAMMING

Quick, but not dirty, PHP

Though I’m doing more and more work in Python, I still write a lot of PHP code, especially for quick one-off web automation tasks.

There is plenty of activity on the other end of the scale in the PHP world now: frameworks like Cake, WASP, Solar, TaniPHP, the forthcoming Zend Framework. All this action is very cool, but doesn’t address the one-page script – and the one-page script is still worth doing right.

Many people come into PHP helter-skelter, not realizing that “Wow, it works!” is not the highest level of achievement possible. I don’t offer myself as a PHP guru, but below are some of the conventions (I dare not call them “patterns”) I use that I think are worth passing along.

BASIC Computer Games

BASIC Computer Games

book cover In 1981, I was 13 years old and teaching myself BASIC on my TRS-80 Model III from official Radio Shack manuals – accurate, comprehensive, and terminally bland.

Into that gray scene came the book Basic Computer Games: Microcomputer Edition (edited by David Ahl of Creative Computing magazine). It changed my life.

I can’t remember now where it came from. Neither my parents, nor my friends, nor my teachers knew much about the home computer scene. It’s possible that I found out about it in Creative Computing magazine and ordered it by mail, or “borrowed” it from somewhere and forgot to return it. The book, subtitled “101 great games to play on your home computer,” was 8-bit-nerd heaven. Pages and pages of program listings in tiny, all-caps, dot matrix type, with brief introductory paragraphs. Plus, funny illustrations of strangely plausible robots. Don’t underestimate the appeal of the robots.

Big Nerd Ruby Ranch

Big Nerd Ranch, which became well known on the strengths of Aaron Hillegass’s Cocoa training and writing, has a new offering in their “bootcamp” series: Ruby on Rails Bootcamp. It’s taught by Marcel Molina Jr., a longtime Rails contributor. Most of the stuff Big Nerd Ranch teaches has been around in one form or another for ten years or more; it says something that they are tackling something so relatively new. Another jump in mindshare for Rails.

Django, Rails, and PHP

Sam Newman has posted a useful high-level comparison of Django and Rails on his site. In it, I think he hits on one little-discussed reason why these two projects are grabbing so much mindshare right now:

[Rails and Django] … historically would have ended up being written in Perl or PHP - but ended up being written in Ruby and Python respectively.

When I heard DHH speak at OSCON, he mentioned switching to Ruby after giving up on trying to make PHP do the kind of stuff he wanted to do. Back in July I asked Simon Willison (of the Django team) about PHP; he said that both he and Adrian Holovaty had worked in PHP for years, but it was Python that “gave us the flexibility we needed to pull everything off.”

A Ruby happening

The place to be during the afternoon break today was the Portland Ballroom, where the Artist Currently Known as why the lucky stiff and musical accomplices unleashed a multimedia explosion involving Ruby, cartoon foxes, animation, repeated MPlayer crashes, video artifacting, rocking out, shadow puppets, and network timeouts. I think this is the show he did at FOSCON last night. The quality of the stuff that did work was so high that the stuff that didn’t work wasn’t such a big deal. My favorite bits were the hilarious animated imaginary Ruby Cabal meetings. A good time was had by all and I don’t think that there will ever be another conference presentation where someone says, “You’ll notice we’re using octagonal paper… as seen on Battlestar Galactica.” Check why’s site to see if he comes through on his promise to post those media files.

CodeZoo

O’Reilly has been running CodeZoo for a few months now. Today they announced CodeZoo subsites for Python and Ruby. CodeZoo is very slick – you can track changes to a particular app or component via a special RSS feed, for instance. Downloads are fast and simple, even for Sourceforge-hosted projects. And they’ve got this new thing called DOAP (why do you think they call it DOAP?), an XML schema for component information. (Tangent: I’m thinking that DOAP could be a nice standard upon which to build phone-home version checking features.)