What if PHP were Completely Rewritten to be More Elegant?

PHP gets a lot of flak for some of it’s strange idiosyncrasies. It’s lack of consistency about argument order (needle then haystack in str_replace,  haystack then needle in strstr) and function names (stripslashes vs strip_tags) are particularly head-scratching examples. This partly comes from PHP’s roots; it’s basically a wrapper around existing C functions, and it pretty much mirrors them for convenience. (The MySQL functions are a good example of this.)

Now I like PHP. It’s not perfect, but it gets the job done. I like it’s C-style syntax, and it’s installed everywhere. Python and Ruby lack that kind of support, as well as having syntactical quirks that just bother me. (Python’s lack of braces is icky, and Ruby’s syntax, though interesting to study from a distance, is a bit too weird for me to wholeheartedly adopt.)

What if there was a way to fix PHP, bringing in some of the awesomeness of Python and Ruby while still retaining support for existing software? I’ve had this idea simmering for awhile that a major effort could be made to restructure the language.

I’m thinking of the “everything as an object” approach, like in Python and Ruby. Instead of strtoupper($mystring) you would have $mystring->upper(). Parameters would be better standardized, that namespace character would be replaced…

But what about backwards-compatibility? Here’s the clever part: the developers would leave dummy functions that would just return the value of the new, more object-oriented function. For example:

function strtoupper($a) {
    return $a->upper();
}

Having an alias to each of the old-style functions would make it possible to maintain support for legacy scripts, at least for a couple of major versions.

Of course, this would probably never happen. Unless someone were to fork PHP, which might create more problems than it would solve…

Dive Into HTML5

Looking to bring your HTML skills up-to-date, now that HTML5 support is growing in modern browsers? Mark Pilgrim has a nice online book by the name of Dive Into HTML5 that covers most of the big new things. It is also available in print,…

Angry Birds Comes to the Web, in HTML5

Rovio, on the 10th of May, released an unexpected new version of their popular Angry Birds game. Previously available on iOS, Android and OS X, Angry Birds is now available on the web. You can find it in the Chrome Web Store, or at…

Klout: Measure Your Twitter Influence

Klout is a service that provides all sorts of fascinating metrics about you—and the people you interact with—on Twitter. It measures things like the number of users who are actively engaged by your tweets, the “type” of Twitter user you are, and your influence.…

Tumblr-style Links with WordPress Post Formats

There are a few blogs, such as Daring Fireball and Digging into WordPress, that have microblog-style “link” items interspersed with ordinary posts. The post title links off-site instead of to a permalink page, and a more compact styling is usually used. Basically, like Tumblr…

BlogBuzz May 7, 2011

Caffeinated RSS Reader Beta Now Available

A couple years ago, I heard about an interesting Mac RSS reader in development. Caffeinated, as it was called, sounded like a good alternative to my current feed reader (NewsFire). There were some neat screenshots, but the software was nowhere near ready for release.…

Rackspace is Shutting Down Slicehost

Customers of the well-liked VPS service Slicehost will be shutting down sometime over the coming months. Rackspace, the company that acquired Slicehost back in 2008, says that this is because of the difficulty of managing “two brands, two control panels and two sets of…

Using Shortcodes in WordPress Widgets

If you, like most WordPress users, have a widget-enabled theme, you probably have wished you could use shortcodes in them at one time or another. Many plugins allow you to add functionality to your posts via shortcodes, but for some reason they are not…

Flattr to No Longer Require Publishers to Keep an Active Balance

Flattr, the social micropayment service, will no longer be requiring that publishers maintain an active balance and be actively participating in the service in order to accept “Flattrs” from users. This will go into effect starting on May 1st, and should increase the number…