Extending PHP 5.3 Closures with Serialization and Reflection

PHP 5.3 has brought with it some powerful and much-needed features like late static bindings, namespaces, and closures (also referred to as anonymous functions and lambda functions). Anyone who is experienced with JavaScript or who has worked with programming languages like Scheme or Lisp should realize the value that anonymous functions can bring to PHP. The PHP Manual explains closures like this:

Anonymous functions, also known as closures, allow the creation of functions which have no specified name. They are most useful as the value of callback parameters, but they have many other uses. Closures can also be used as the values of variables; PHP automatically converts such expressions into instances of the Closure internal class.

PHP has very few predefined classes that are part of the core language, so naturally I was intrigued by the Closure class. The PHP Manual has this to say about the class:

The predefined final class Closure was introduced in PHP 5.3.0. It is used for internal implementation of anonymous functions. The class has a constructor forbidding the manual creation of the object (issues E_RECOVERABLE_ERROR) and the __invoke() method with the calling magic.

The invoke magic method is also a new feature in PHP 5.3. It is called when an object is used in the context of a function (e.g. $object($parameter);). Since Closure objects will be used like functions, this is a critical feature of the Closure object. The Closure class may be perfectly equipped to act like an anonymous function, but it does not provide any extra utility beyond that. A var_dump() of a closure will reveal the functions parameters, but there is no way to get any other information about the Closure (like the actual code of the function). Trying to serialize the Closure throws an Exception and json_encode() just returns an empty JSON string. To make matters worse, the Closure class is final, so there is no way to extend it.

That simply wasn’t going to cut it for me. I wanted to make my own Closure class that was at least able to do the following: Read More »

Popularity: 2% [?]

  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Reddit
  • Technorati
  • TwitThis

Posted in: Articles, Development

Facebook vs. Twitter Clickthroughs: More Bang For Your Buck

Facebook vs Twitter

While managing your social networking presence on Twitter and Facebook, it can be difficult to quantify the impact of each medium. While I’m a huge fan of Twitter, traffic results from earlier today on one of my sites confirmed for me what may sound like common sense: Facebook fans drive far more traffic per-user than Twitter followers for a given promotional message.

I’m currently running a contest in association with T-shirt company Threadless. (It’s called Threadknits, and it’s based on knitting and crocheting their t-shirt designs into crafts.) Today, Threadless posted a message on their Facebook page and  Twitter, both with essentially the same content: an invitation to check out Threadknits. They were both posted at nearly the same time.

The numbers are what might surprise you. Threadless has almost 1,500,000 followers on Twitter, and “only” 102,000 fans on Facebook. With the posts made within an hour of each other, my traffic on the site shot up, with a couple thousand visitors hitting by day’s end. Here’s the breakdown of traffic driven from each:

Medium: Fans: Visitors: % Audience Clickthroughs:
Facebook ~102,000 ~1,110 ~1.08%
Twitter ~1,490,000 ~682 ~0.04%

 
The difference is absolutely staggering. Whereas Facebook generated an approximate 1.08% clickthrough rate, Twitter’s was closer to, well, 0%. 232 visitors came from Twitter or related sites directly and 450 additional clicks landed on the home page without a referrer, which I’m chalking up to clicks from Twitter clients. (Though, to be fair, this could easily overstate Twitter’s influence.)

On a previous contest, Threadless would tweet and I’d see between 1,000-2,000 clicks on their roughly 1.4 million followers, so while it may be a bit low today, I think the point stands: Even at its best, Twitter for large audiences generates clickthrough rates dramatically lower than Facebook. For 2,000 clicks, the rate at 1.4M followers stood at 0.14%. A quick look at the bit.ly stats on a few links from Ashton Kutcher (the #1 Twitter personality by followers) shows they typically net about 20,000-30,000 clickthroughs, on 4.3M followers, gaining a decent amount on the Threadless best-case scenario all the way up to 0.48% ~ 0.60%. (This accounts somewhat for the viral nature of Twitter as bit.ly clicks are counted for retweets as well.) Naturally, clickthrough rates will vary dramatically even amongst popular Twitter personalities for a variety of reasons. I’d like to focus more on the significant difference between the Facebook and Twitter rates I witnessed today.

There are likely several possible reasons for this:

  • The audience may be slightly different—people willing to consider themselves “fans” on Facebook may be more picky with their allegiance than those willing to follow an account on Twitter.
  • The phrasing and formatting of the message were slightly different—not exactly apples-to-apples as Facebook includes the logo and a text clip from the website, but I imagine this had a negligible effect.
  • My mileage may vary—this is an admittedly small sample size, but I think the evidence and logic around these results indicate they’re not anomalous.
  • Most importantly, Facebook lingers while Twitter sails by. Users are probably more likely to follow links during their Facebook time than from a passing Twitter notification unless it’s of particular interest to them.

That last point is particularly important. Facebook, having reconfigured their News Feed yet again, no longer sorts things there chronologically. They’ve merged the Highlights functionality back into the News Feed which they now use to keep certain posts “stickier” than others based on what they believe you might be interested in. (It manages to do a strikingly horrible job at this compared to how it used to perform, but that’s a conversation for a different post.)

With Twitter, the very nature of real-time can be summed up: blink and you miss it. While you can use a Twitter client to review tweets over the past day or two, it’s still less likely your tweet was as visible over Twitter as a post would be on Facebook’s News Feed. I’d like to see some more statistics on total audience reach. The clickthrough rate surely only tells part of the story—I’d be far more interested to learn what percentage of each audience even saw the post, and determine true clickthrough rates from that.

In the end, it’s important to consider the overall spirit of the findings here. Twitter is great for growing virally and interacting with customers, but your message on Facebook may have a far more lasting impression and generate greater returns, even if fans are more of a fight to procure. Engage on both, but recognize the differences between them and leverage each of their strengths. I’ll likely post about the best way to do that for each site in the near future.

(The above graphic represents the total clickthrough breakdown by medium assuming a linear progression of Threadless’ Facebook audience to match their Twitter audience, maintaining the same clickthrough rates from today’s traffic. It’s likely the Facebook clickthrough rate could in fact fall some as their audience grew, but it’s my belief that it would still beat Twitter, user for user.)

Popularity: 3% [?]

  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Reddit
  • Technorati
  • TwitThis

Posted in: Articles, Cool Stuff

Nexus One Subsidy Hack: Drop Your Data Plan, Get $100

nexus_oneGoogle officially released their Nexus One Android phone today under the guise of a $179 subsidized price tag ($529 unsubsidized and unlocked). As many T-Mobile customers discovered today, that price only applied if you weren’t already a loyal customer. Instead, TMO customers were shafted subsidized based on their contract status and the presence of an existing data plan.

The official Google Support page describes the following subsidy tiers:

  • Nexus One without service: $529
  • Nexus One with new, 2-year T-Mobile US service plan for new customers: $179
  • Nexus One with new, 2-year T-Mobile US service plan for qualifying existing T-Mobile customers who are adding data plans: $279
  • Nexus One with new, 2-year T-Mobile US service plan for qualifying existing T-Mobile customers who are upgrading their data plans: $379

I’ve been a T-Mobile customer for a little over seven years now, and off-contract for pretty much that entire time. I’m thus now open to what T-Mobile calls their full subsidy. Except with the Google phone, where Google manages the subsidy, not T-Mobile. Since I had a $10/month sad, EDGE-based data plan with TMO, Google informed me after polling the TMO servers that I was eligible for the $150 subsidy, for a Nexus One price of $379. The next subsidy tier up is $100 cheaper for a price of $279.

The only distinction lies in whether you are “upgrading your data plan” or “adding a data plan.” This seemed like a simple enough problem to fix: I called T-Mobile support and asked them to cancel my data plan. They said it would be no problem, since I’m not under contract. I worried briefly that it wouldn’t be visible to the Google-based powers that be until the next billing cycle, but the TMO rep informed me that the change is instant. Since I knew I was buying a Nexus either way, I pulled the trigger.

Wouldn’t you know it, not five minutes later when I went to make the purchase again Google’s web store fetched my data and lo and behold, my Nexus price was now just $279. Easy-peasy, that.

The ironic part is that I’m moderately sure I could re-activate the data plan now without incurring any real additional fees in the day-and-a-half I may have to wait for the overnight shipping to get here, but I don’t use the slow EDGE service enough to warrant wrecking my cool here.

After all the dust settled, I realized how asinine Google had decided to make the checkout process by managing sales and subsidies of the device themselves. They limit you to just one rate plan during your purchase, which is more than a little infuriating as I received different answers from TMO reps over whether upping my minutes would cause Google to come after me for the subsidy. (It appears that you CAN upgrade your account to another Even More plan according to a recently-added note on this Google Support page.) The pricing rates are buried under a Support knowledge base article and not at all transparent. Google says $179 and then pulls an enormous J/K on you as they fetch your account information, seemingly pulling a figure out of thin air as it suits them. The T-Mobile reps can’t do anything about it since the purchase isn’t on their side of the pond at all. And Google is nowhere to be found.

Strange to me that a company so intent on delivering a device with their brand and full-throated support would instantly fawn off users to HTC and T-Mobile so that they don’t need to support their customers in any meaningful way. This isn’t the first time Google has proved shockingly absent with matters of support, but it feels very different when you’re purchasing a product subject to additional cancellation fees.

Further, it seems completely short-sighted to limit the subsidy as they have. Restricting the best price to new T-Mobile customers alone is frustrating, but they make it nearly impossible for anyone with a family plan to switch at the subsidized price. Worse, the subsidy at its lower rates really just amortizes the cost of the phone out over those two years, as the Even More plans cost $10/month more—that’s $240 over two years right there. Let’s be clear: At $379, you’re better off financially buying the unlocked phone and using the Even More Plus plan, which costs $10 less, for a total savings of $90 over the two year term. Even better since you’re not under any contract at the $529 rate.

Creating barriers to entry for new customers is always a bad idea, made all the worse when those barriers seem arbitrary and class-based. Google needs to stop with the silly tiers and subsidize the damn phone like they’re usually subsidized through carriers. They should allow purchases under family plans and not take the data plan into account. And they should allow you to select from any of T-Mobile’s Even More tiers, which would save me a phone call with T-Mobile’s (admittedly friendly and typically knowledgeable) support.

[1/18/2010 Edit: It was reported last week that Google is nixing the $379 rate entirely, so existing T-Mobile subscribers of all (out-of-contract) stripes will now qualify for the $279 offer. Early adopters who got hit with the $379 rate will have a refund check sent to them. Good on Google, but it'd be nice if it were $179 for all.]

Popularity: 3% [?]

  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Reddit
  • Technorati
  • TwitThis

Posted in: Rants, Tech News

Twitter Advice for Companies: Engage Intelligently

sp_twitterAs more and more companies move to engage their customers over Twitter, I thought it might be useful to outline a few guidelines companies should use when tweeting.

Naturally your mileage will vary, but these are tips I’ve put together based on my experience with companies who are doing Twitter right, and some who haven’t quite got the hang yet:
Read More »

Popularity: 3% [?]

  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Reddit
  • Technorati
  • TwitThis

Posted in: How To

Let’s Be Clear: There IS A Page Fold

please_scrollOver the past day or two, the website thereisnopagefold.com has been making the rounds. In a rather succinct, but incredibly tall manner, it states the following:

WELCOME TO THE WORLD WIDE WEB, AN INTERACTIVE MEDIUM IN WHICH SCREEN RESOLUTION STATISTICS ARE TRIVIAL, BROWSER VIEWPORTS ARE VARIABLE, AND SCROLLING BEHAVIOUR IS A STANDARD. THERE IS NO PAGE FOLD. LOVE YOUR SCROLLBAR.

The buzz on Twitter from “designer” types appears to be a knee-jerk “ZOMG YES SO TRUE!!!111one” while responses on the site’s reddit thread have been more measured. I especially appreciate the following comment, by one fletcher_t:

Well of course it depends on the context of what the site is providing… but there is indeed a fold and if you’re ignorant of that, may god have mercy on your soul.

Let’s be perfectly clear: There IS a “fold”. For the uninitiated, the “fold” refers to the literal crease in a newspaper. Editors recognized the importance of catching their reader’s interest “above the fold”, because the likelihood a reader will bother to look under the fold is lower as a whole. Readers who might not typically read the sports section, for instance, will notice a story above the fold if it’s of interest to them. If they’re just flipping past as they always do, they’re far less likely to look beneath the fold.

The assertion made by the “no fold” site is that, because technology has provided us with infinite page lengths, we should design our pages accordingly. We can space things out more, we can use larger print and increase readability, and we shouldn’t be so concerned with what lies above the fold because users will scroll anyway! We were on a roll there up until that third point, weren’t we?

The reality is that the science of user attention is a tricky one, and more of an art than anything. Heat maps and eye-tracking studies frequently show huge dividends by presenting the initial page-load in a clear, concise manner, with well delineated courses of action visible to the user and readily accessible. Users will absolutely scroll, if you’ve given them a compelling reason to believe anything of interest lies beneath the fold. Users are fickle types, though, who scan quickly, look for large visual cues, and make an off-the-cuff and perhaps misinformed decision to bounce away from your site in an incredibly short amount of time, if you don’t captivate them instantly. To capture their interest, you simply must pay attention to the content that resides above the fold.

With Google’s release of Browser Size the other day, Tech Crunch mentioned that Google saw a 10% increase in the number of installs of Google Earth, simply by moving the download button up 100 pixels. By placing the call to action and primary focus of the page above the fold, users were far more likely to follow through. Naturally, this will vary from site to site. Amazon.com has a rather long page, which they use to show multiple categories of products they think you’ll be interested in. Their primary feature and what they hope will have the most success is always at the top, though—a compelling enticement to scroll further and see what else they got right.

Understand, this is by no means an argument for cramming everything of any importance above the fold. Not even a little bit. (And I understand that the no-fold site is likely directed at those types—but does anyone actually try to force entire sites above the fold anymore?) Whitespace should be well utilized, large print is totally acceptable, and designers shouldn’t force pages to fit into any idea of a “standard” vertical viewport. CXPartners even argues that including less information above the fold can encourage users to scroll more, arguably by reducing the utility of the site to the point where they’re forced to scroll.

It’s not my claim the no-fold site is implying you should ignore the above-fold design or disregard its design entirely, but the cheeky site title and its assertion that there is NO page fold degrades the importance of how you construct your pages for those first 700 or so pixels. Encourage your users to scroll, not by reducing utility but by increasing interest. Facilitate this behavior by keeping large, blocking horizontal lines and blocks at bay (advice from CXPartners’ piece) and providing clear paths downward. Ensure that users see that additional content exists further down. But don’t forget that your site’s first impression is above the fold.

Popularity: 3% [?]

  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Reddit
  • Technorati
  • TwitThis

Posted in: Design, Rants

Google Browser Size: Drawn By Five-Year-Olds

Browser SizeGoogle announced a new Labs product called Browser Size. At first I thought this might be a useful tool to complement their recent spate of great developer-oriented releases. Instead, I was assaulted by a hideous overlay that requires a left-aligned design. (Though they’re ostensibly working on that.)

Browser Size allows you to enter any URL  and see an overlay of visible browser space broken up by user demographics. Specifically, you can see what percentage of the Google-using populous would be able to see what portion of your screen on an initial page load. Apparently, this is based on typical browser dimensions for users, and not screen resolutions outright. (Taking into account non-maximized browsers.)

I understand that Labs products are by their nature not fully baked, but this one lands on the other extreme: half-assed. Perhaps the overlay is a rough attempt at being cheeky, but to me, it’s ugly, and its jagged, hand-drawn lines reduce its utility, rather than amping up its “cute” factor. The percentages aren’t even consistently rendered—it’s like My First Photoshop session here.

This isn’t to say that the concept isn’t a good one. I just wish they let this one cook a bit more before releasing it.

Browser Size | Google Labs via TechCrunch

Popularity: 4% [?]

  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Reddit
  • Technorati
  • TwitThis

Posted in: Design

TweetNotebook: Custom Notebooks Filled With Your Tweets

TweetNotebook LogoTweetNotebook is a fun site by an interactive company from Belgium called Boondoggle. The premise is simple: enter your Twitter username and it generates a notebook filled with a random selection of your tweets in the footer of each page. For $12, you get a 320-page notebook with a different tweet on every page. The site lets you select your choice of cover (and print a specific message on the cover as well) before peppering each page with a random tweet from your Twitter history.

You can preview the book beforehand and regenerate the notebook as many times as you’d like, though for now, you can’t hand-pick tweets for the notebook. The notebook also appears to only have non-ruled pages much to my chagrin, but it sounds like TweetNotebook is planning on beefing up their offering in the near future if this takes off. For now, they have three different covers available, onto which your current avatar and cover tweet appears. Here’s mine:

my_tweetbook

Suffice to say, I’ve already bought mine. I think it’s a fun conversation piece, and I think that it’s a fun look into what was relevant to you a few days, weeks, or for some of us, even a year or two ago, in a blurb. It’s almost like thumbing through a diary in a sense, a simple snapshot at the bottom of each page that makes you pause and try to remember what context surrounded that tweet.

We’ve seen Threadless make T-shirts out of great tweets, and I think it’s no stretch to imagine other potential products that can be built out of a users’ Twitter feed. Consider a timeline, complete with tag cloud, friend diagrams, statistics, and more. Twitter lends itself to these sort of changes in medium because of their brevity and relevance—no one’s wearing a shirt with excerpts from their blog on it, but a poster that shows off my activity on Twitter is fun enough even if you’re not a raging narcissist.

For now, there’s also nothing to stop you from using someone else’s tweets, like a celebrity. (Or a friend, for a gift.) That situation may change if copyright issues arise. All told, my order was just $14.50, including shipping to Tempe, Arizona. Here’s hoping they’ll offer different sizes, bindings, and rulings in the future.

TweetNotebook | via TechCrunch

Popularity: 3% [?]

  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Reddit
  • Technorati
  • TwitThis

Posted in: Cool Stuff, Tech News

Google Speed Tracer Makes AJAX Optimization Easier

SpeedTracer-SluggishnessDetailGoogle today announced Speed Tracer as part of their Google Web Toolkit offerings. While most of the GWT focuses on enabling developers to create web applications in Java (which compiles down to optimized JavaScript), Speed Tracer is a useful profiling tool for any developer wrestling with XMLHttpRequest.

What makes Speed Tracer different?

Developers have long used Firebug to identify what AJAX requests were causing bottlenecks and to analyze responses to those requests. Firebug is an extremely powerful tool and does a serviceable job with this approach, but Speed Tracer takes things one step further, analyzing the “sluggishness” of your application by examining how busy or blocked the UI is in your browser. This can help developers analyze why their application feels slow, instead of simply focusing on network-based bottlenecks.

Speed Tracer makes use of specific, unique APIs built into Webkit for this very purpose, which gives it a unique advantage compared to other profiling tools. Instead of simply guessing and checking, developers will now have full visibility into what’s causing their applications to appear slow:

Using Speed Tracer you are able to get a better picture of where time is being spent in your application. This includes problems caused by JavaScript parsing and execution, layout, CSS style recalculation and selector matching, DOM event handling, network resource loading, timer fires, XMLHttpRequest callbacks, painting, and more.

Very cool stuff. What’s more, it’s free, open source, and available for users of Google Chrome right now. Check out their tutorial below:

Google Speed Tracer

Popularity: 3% [?]

  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Reddit
  • Technorati
  • TwitThis

Posted in: Cool Stuff, Development, Tech News

Anatomy of a Smart Survey: Netflix Email Surveys

netflix_surveyNetflix is a company built entirely around efficiency. When you deal with the volume Netflix does, every penny, every action, every little detail counts immensely. Take their mailer: Over the years, it has evolved from a cardboard-backed affair, to a paper-based piece with a foam insert, to today’s design: thin, simple paper. (They determined the breakage rates didn’t decrease enough with the padding to make it cost-effective.)

It’s no surprise then that they’d take the time to get surveys right. Netflix (like most companies trying to make a profit) has a need for constant feedback from their customers. They want to know how their distribution system is working, where there may be bottlenecks, and other things like how their new instant streaming service is performing. Instead of producing staid, time-consuming, multi-page affairs, they send an email with a single question.

In my most recent survey, that question read “How was the picture and audio quality?” Simple enough. The real stroke of genius lies in how the user is asked to respond: Three links are displayed, each with a different quality option: “The quality was very good”, acceptable, or unacceptable. You click the link and your survey response is sent. Done. That’s all there is to it.

The survey requires exactly one click to respond to. Users aren’t asked to login, fill out demographic data, attempt to remember details they aren’t likely to, or even read anything to qualify their answer. They are given three relatively unambiguous options and clicking the link from within the email submits their response.

Since not every company has the luxury of being able to boil their customer feedback loop down into simple multiple choice questions, let’s look at a few key points almost anyone can replicate: Read More »

Popularity: 3% [?]

  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Reddit
  • Technorati
  • TwitThis

Posted in: Design, How To

Senior PHP Developer Position in Tempe, Arizona

synapse_office

Our company Synapse Studios is hiring a senior PHP developer right now. Specifically, we’re looking for someone who can help lead our talented team and establish methodologies that scale and make for a more powerful team. More information on the position is available here, but you’d be working in our offices in downtown Tempe, Arizona, right on Mill Avenue. It’s a great space with fun people and exciting work, so if you’re interested, view the job post on our site and follow our instructions over there.

Senior PHP Developer Job Posting | Synapse Studios

Popularity: 5% [?]

  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Reddit
  • Technorati
  • TwitThis

Posted in: Announcements