Categories
Uncategorized

The “FTW!” Ultimate PHP App Throwdown

For the Win! For the Web! FTW: Ultimate App Throwdown -- Professionals vs. Students

This article also appears in Canadian Developer Connection.

Wait a Minute…Microsoft and PHP?

You probably wouldn’t be surprised that Microsoft is holding a development contest that pits professional developers against student developers. You might be surprised that Microsoft is holding a development contest where the challenge is to build a PHP application.

You read that right: PHP. Microsoft’s web server, IIS (Internet Information Services) can run PHP as well as ASP.NET; in fact, it can even run both on the same site at the same time, so you can have apps like WordPress along with your ASP.NET-based apps.

Think of ASP.NET and PHP running on the same server as the great jam session with Spock and the space hippie from that old Star Trek “hippies in space” episode.

Spock and a space hippie, jamming on their instrumentsSee? We’re not Herbert!

Even more unexpected is that the beta for the 2.0 version of the Microsoft Web Platform Installer doesn’t do a “couple-of-clicks” installation of the expected stuff like IIS and SQL Server 2008 Express, it also provides a “couple-of-clicks” installation of PHP and WordPress.

The FTW! Throwdown

"Goopymart" comic of a dog holding a trophy: "FTW!"

That’s “FTW!” as in “For the Win” or “For the Web”, by the way.

The contest is pretty simple: the idea is to show the best application written in PHP and deployed on Windows. The app can be either:

  • A new application developed by you in PHP and running on IIS in Windows
  • An existing application or framework written in PHP and ported by you to run on IIS in Windows

That’s right: if you’re pressed for ideas or time to make a new application, it’s all right – you can take a PHP application that already exists, make the necessary changes so that it’ll run on IIS (and hey, for bonus points, make it tie into SQL Server instead of MySQL), and submit that as your contest entry!

Students vs. Professionals

Another twist to the FTW! Throwdown is that we’re getting student developers and professional developers to challenge each other. The pros have experience and resources on their side; students have youthful energy and fewer distractions going for them. Not since “Pirates vs. Ninjas” has there been a challenge like this!

One application developed or ported by students and one application developed or ported by professionals will be chosen from the submissions for the Ultimate Challenge, which will be a final bout at Microsoft’s Make Web, Not War conference. In that last match, it “Two apps enter! One app leaves!”. Simply put, one of the apps – either the student one or the professional one – will be declared the Ultimate Champion.

As they said in Highlander: “There can be…only one!”

The Booty

Stuffed animal prizes at a carnival

We want to reward the best contestants for their efforts in the FTW! Throwdown, and we plan to do so with some pretty nice prizes, which include:

  • The grand prize: $5000 for the winning entrant.
  • The runner-up prize: $3000 for the runner-up.
  • The SQL Server prize: $3000 for the finalist whose app showcases the best use of PHP with a Microsoft SQL Server database.
  • The PHP/.NET Mash-Up prize: $2000 for the finalist whose app showcases the best of PHP with .NET-based code working together in a single application.
  • The student finalist prize: The student developer who makes it to the last match will also get an interview and resume critique from Microsoft and a $200 Petro-Canada gas card.
  • The professional finalist prize: The professional developer who makes it to the last match will also get a chance for a published case study, enrollment in the MAPS or EMPOWER program and a $200 Petro-Canada gas card.

Hosting Options

Naturally, the apps that you submit for the FTW! Throwdown need a place to live. If you don’t already have IIS hosting, our partners at myhosting and RackForce are offering a 60-day free hosting promotion.

Deadlines and Details

The deadline for entering the FTW! Throwdown is Wednesday, June 3rd, 2009. Finalists will be announced on Friday, June 5th, 2009, and the main event where the student finalist faces off against the professional finalist happens on Wednesday June 10th, 2009.

If you’d like to know more about the FTW! Throwdown, visit the FTW! Throwdown site. I’ll be posting regular bulletins about the FTW! Throwdown on this blog, and you can follow the FTW! team on Twitter as the user @PHPOnWindows and the hashtag #FTW09.

Categories
Uncategorized

Using the Twitter API with PHP and PEAR

PHP, PEAR and Twitter logos

The Zend Developer Zone article Using the Twitter API with PHP and PEAR covers the Services_Twitter PEAR package, which the articles describes as follows:

Services_Twitter works by providing a full-fledged, object-oriented interface to the Twitter API. This interface insulates you from the nitty-gritty of working directly with REST requests and, by representing responses as SimpleXML objects, makes it very easy to access specific elements of the returned data. This not only saves time; it’s also simpler, because it’s no longer necessary to be intimately aware of the nitty-gritties of the Twitter API in order to use it effectively.

Categories
Uncategorized

My Tech Reading List for May

I got a number of books for free this past week:

Books I\'m reviewing in May 2008

  • Head First PMP – When my friend Leigh Honeywell heard that I was taking a project management course later this month, she told me that she got this book for free at a conference and had no use for it. So she gave this book to me, and I’ll be reading it so that when the course comes around — it’s May 21st through 23rd — I’ll be at least familiar with the material.

And four books from Apress, courtesy of Julie Miller:

I’ll be reading them this month and posting my reviews here in Global Nerdy. Watch this space!

Categories
Uncategorized

In PHP, There’s Equality, and Then There’s EQUALITY

Ka=Ping Yee’s Equality Test

Here’s a quickie PHP script based on the one that appears in Ka-Ping Yee’s LiveJournal entry titled Why PHP Should Never Be Taught:

<?php
$a = 0;
$b = "eggs";
$c = "spam";
$e = "eggs";

echo "<h1>The \"==\" Exercise</h1>";
echo "<ul>";
echo "<li>\$a is $a</li>";
echo "<li>\$b is $b</li>";
echo "<li>\$c is $c</li>";
echo "<li>\$d is undefined</li>";
echo "<li>\$e is $e</li>";
echo "</ul>";

echo ($a == $b) ? "\$a == \$b<br />" : "\$a != \$b<br />";
echo ($b == $c) ? "\$b == \$c<br />" : "\$b != \$c<br />";
echo ($a == $c) ? "\$a == \$c<br />" : "\$a != \$c<br />";
echo ($a == $d) ? "\$a == \$d<br />" : "\$a != \$d<br />";
echo ($b == $d) ? "\$b == \$d<br />" : "\$b != \$d<br />";
echo ($c == $d) ? "\$c == \$d<br />" : "\$c != \$d<br />";
echo ($b == $e) ? "\$b == \$e<br />" : "\$b != \$e<br />";
?>

If you’re not familiar with PHP’s quirks, you’ll find the output surprising:

The “==” Exercise

  • $a is 0
  • $b is eggs
  • $c is spam
  • $d is undefined
  • $e is eggs

$a == $b
$b != $c
$a == $c
$a == $d
$b != $d
$c != $d
$b == $e

What Happened?

In PHP, as with many other programming languages, the == operator is the equality operator, which returns true if the operands on either side are equal in value. It works as expected when used on operands of the same type, as evidenced by the program above, which states that $b is equal in value to $e, both of which are set to the string eggs.

We get into strange territory when the == operator is used to compare operands of different types. The program above evaluates the boolean $a == $b as true even though $a is set to the integer value 0 and $b is set to the value eggs. How can eggs be equivalent to 0? They’re so tasty and versatile! Damned anti-ovites!

In PHP, the == operator is what I like to call the “Slack Equality Operator”. When used to compare a string and a number, it attempts to convert the string to a numeric type and then performs the comparison. The following example code, taken from the PHP documentation, shows how PHP’s string-to-number coercion works:

<?php
$foo = 1 + "10.5";                // $foo is float (11.5)
$foo = 1 + "-1.3e3";              // $foo is float (-1299)
$foo = 1 + "bob-1.3e3";           // $foo is integer (1)
$foo = 1 + "bob3";                // $foo is integer (1)
$foo = 1 + "10 Small Pigs";       // $foo is integer (11)
$foo = 4 + "10.2 Little Piggies"; // $foo is float (14.2)
$foo = "10.0 pigs " + 1;          // $foo is float (11)
$foo = "10.0 pigs " + 1.0;        // $foo is float (11)
?>

Hence the eggs/zero equivalence: the string eggs is coerced to 0.

Enter the === Operator

I like to call the === the “Strict Equality Operator”. It returns true if and only if:

  • Both operands are the same type
  • Both operands have the same value

Here’s the code I showed at the start of the article, but with all instances of == replaced with ===:

<?php
$a = 0;
$b = "eggs";
$c = "spam";
$e = "eggs";

echo "<h1>The \"===\" Exercise</h1>";
echo "<ul>";
echo "<li>\$a is $a</li>";
echo "<li>\$b is $b</li>";
echo "<li>\$c is $c</li>";
echo "<li>\$d is undefined</li>";
echo "<li>\$e is $e</li>";
echo "</ul>";

echo ($a === $b) ? "\$a === \$b<br />" : "\$a != \$b<br />";
echo ($b === $c) ? "\$b === \$c<br />" : "\$b != \$c<br />";
echo ($a === $c) ? "\$a === \$c<br />" : "\$a != \$c<br />";
echo ($a === $d) ? "\$a === \$d<br />" : "\$a != \$d<br />";
echo ($b === $d) ? "\$b === \$d<br />" : "\$b != \$d<br />";
echo ($c === $d) ? "\$c === \$d<br />" : "\$c != \$d<br />";
echo ($b === $e) ? "\$b === \$e<br />" : "\$b != \$e<br />";
?>

Here’s the output, which behaves as expected:

The “===” Exercise

  • $a is 0
  • $b is eggs
  • $c is spam
  • $d is undefined
  • $e is eggs

$a != $b
$b != $c
$a != $c
$a != $d
$b != $d
$c != $d
$b === $e

Once More, in Ruby

Just for kicks, I thought I’d translate the original code into Ruby just to see what would happen. Here’s the code:

a = 0
b = "eggs"
c = "spam"
e = "eggs"

puts "a is 0"
puts "b is 'eggs'"
puts "c is 'spam'"
puts "e is 'eggs'"

puts a == b ? "a == b" : "a != b"
puts b == c ? "b == c" : "b != c"
puts a == c ? "a == c" : "a != c"
puts a == d ? "a == d" : "a != d"
puts b == d ? "b == d" : "b != d"
puts c == d ? "c == d" : "c != d"
puts b == e ? "b == e" : "b != e"

…and here’s the output:

a is 0
b is 'eggs'
c is 'spam'
e is 'eggs'
a != b
b != c
a != c
double-equals.rb:14: undefined local variable or method `d' for main:Object (NameError)

Links

Categories
Uncategorized

The Language Adoption Debate and “Three Stooges Syndrome”

Tim “Ongoing” Bray’s Take

Tim Bray posted a blog entry on what drives adoption of a language in which he included some tables such as the only below:

Flawed
Founders
Polished
Successors
Procedural FORTRAN, COBOL, PL/1 C
Object-Oriented C++ Java
Higher-Level Perl, TCL Python, Ruby

This table of his should inspire a monkey knife fight on a number of blogs:

Flawed
Founders
Polished
Successors
Web-Centric WebObjects, ColdFusion, ASP.Net, Struts, etc.,
etc., etc., PHP
Rails

Here’s an interesting one. What will JavaScript’s successor be? My guess for the short-term (by that, I mean “the next half-dozen or so years”) is “the next version of JavaScript”.

Flawed
Founders
Polished
Successors
Mobile-Code JavaScript ?

The one about concurrent programming is a little more up in the air. Although there are other languages designed with concurrent programming in mind (either from the ground up or with concurrency retrofitted onto an existing language) and there have been for a while (I used Concurrent C in a course back at Crazy Go Nuts University in the early ’90s), Erlang is getting a lot of the attention these days since it has both a success story at Ericsson under its belt as well the clout of a Pragmatic Programmers book behind it. There is a feeling among some programmers (Bray included) that it isn’t going to be the language to turn concurrent programming from arcane art into mainstream practice:

Flawed
Founders
Polished
Successors
Concurrent Erlang ?

Shelley “BurningBird” Powers’ Take

Shelley Powers disagreed with Tim’s assessments in her posts Flaws are in the Eye of the Beholder:

I find it fascinating when a person marks as ‘flawed’ the languages that have, literally, defined not only the web but application development of all forms. Perhaps the metric shouldn’t be on syntax, form, or function, but on usability.

Here’s her own table on languages:

'Perfect', but barely used 'Flawed', but simple, approachable, powerful, popular
Higher-Level *Ruby (every time I see 'Ruby' I mentally add, Mama's precious little…)

*I’m giving Python a slide because Python has fairly widespread use today.

Perl
Client side code (The to-be-created scripting language that will take a nice, clean, easy to use language and morph it until it satisfies the purists, while breaking faith with the millions of users just trying to do a job) JavaScript
Object Oriented Java (bloated beyond recognition with senseless additions and overly complex infrastructures) C++ (which can kick Java's ass performance and resource wise)
Web-Centric Rails (you know that thing they used for the one application?) Cold Fusion, ASP and ASP.NET, PHP

Those of you who recall Bjarne “C++” Stroustrup’s line “There are just two kinds of languages: the ones everybody complains about and the ones nobody uses” or the essay Worse is Better (or the essay that led to it or Jamie Zawinski’s commentary on it) should be feeling deja vu now.

As for Shelley’s table, I’d probably have put “PHP” where “Perl” is right now.

My Own Take

I think that right now, the “scripting languages” are stuck in something akin to “Three Stooges Syndrome”. That’s the disease where Mr. Burns from The Simpsons, being so old and frail, has so many diseases trying to get at him at the same time that they’re all “stuck in the door”. The doctors illustrated the syndrome with a model, shown below:

“Three stooges syndrome” from “The Simpsons”: All the germs and viruses are stuck in the door because they tried to get in all at once.

And since Tim and Shelley have their tables, I thought I’d make one too:

Scripting Stooge What’s Driving It
Perl Legacy: it was the original “duct tape of the internet”.
PHP Widespread adoption, drives a lot of apps, easy to program, easy to deploy.
Python Very readable, one of the 4 languages approved for use at Google (the others being C++, Java and JavaScript, according to Steve Yegge).
Ruby Ruby on Rails, which is a very nice framework from the web app developer’s point of view. That and maybe the fact that DHH is rather photogenic (although PHPer-turned-Pythoner Leah Culver could give him some competition).


Cross-posted to the Tucows Developer Blog.

Categories
Uncategorized

Sign Up for PHP Training, Get an iPod touch (or Two!)

iPod Touch displaying the PHP logoHere’s a sweet deal from php | architect magazine, to which I am a subscriber: sign up for online PHP training before the end of November and they’ll give you an iPod Touch…or maybe two! Click here for details about this offer.

Cross-posted to the Tucows Developer Blog.

Categories
Uncategorized

Facebook Development: Photos, Part 3

Facebook Polaroid Camera 3

The Facebook development articles continue at the Tucows Developer Blog, this time with Using the FacebookRestClient Class’ “Photo” Methods, Part 3: photos_getTags.