Autoloading and Lazy Loading

Two and a half years ago, when first wrestling with the Tagged codebase, I asked Andrei about replacing all my PHP includes with __autoload. I was told under no uncertain terms to not do this.

I did it anyway.

It’s not that Andrei is wrong in his admonition. Far from it! For reasons that I don’t quite care to know, there are caching and lookup optimizations that APC cannot do when it has to switch context to run __autoload. But the problem in practice was two-fold:

  1. The company was bug-driven and the easiest way to eliminate an “Undefined class” error was to go into the preinclude script and include it. Voilá! problem solved at the expense of code bloat. (This bug happens often when deserializing nested objects from cache.)
  2. There are slowdowns when you use include_once where include would do, or when you don’t use the full path in your include, or when you construct your full path from symbols. How many of us do this? Heck, I’m still trying to get used to the idea of include_once and require_once. Ahh the days when I’d have to write symbols with every include file!
  3. More to the previous. If you have deep dependencies and don’t use a FrontController pattern, you’re going to have to use require_once() which will get executed multiple times. An __autoload only gets executed once.

At a certain point, optimization gives way to convenience and practicality.

For Tagged, this was that PHP would allocate 12MB/80ms to say “hello world”, 20MB/465ms to display the homepage, and 22MB/1965ms/1207ms to return my profile page

After the rewrite it takes 0.3MB/3ms to say hello world and 3.7MB/109ms to return my profile page.

Continue reading about lazy loading after the jump

Vee-oh-la

Voilá!

I am forever reminded of the French section of my Latin I class when reading the first lesson, J— pronounced this “Vee-O-La!”

If it isn’t obvious from the repeated mentions of me almost failing French I, I’m glad J— was called to read that day.

New York vs. New Yorker

There was been a lot of hoopla a couple years ago that New York Magazine was eclipsing my beloved The New Yorker.

It bothers me that people often confuse the two.

So for your edification, The New Yorker is the magazine where we first found out that America was torturing people and it published a photo essay moved a prominent politician to switch parties. And New York Magazine publishes stuff like this:

Jake DeSantis, a 40-year-old commodities trader at AIG, was an unlikely face of Wall Street greed. Stocky and clean cut, with an abiding moral streak, he’d worked summers for a bricklayer in the shadow of shuttered steel mills outside Pittsburgh; he was valedictorian of his high-school class and attended college at MIT.…

When DeSantis arrived at the office the morning his letter appeared in the paper, the AIG traders gave him a standing ovation. In some quarters of the press, he was vilified.

It might help to remember who Jake DeSantis is. (The whole article is similarly unintentionally revealing more of the magazine’s values and the author’s preferences than of anything else.) And lest you think that this is some weird outlier for the Magazine, it’s not.

While I applaud Jake for donating his bonus, Really?, I mean, Really?!?

Continue reading about Some comparisons after the jump

Join Kiva for a Developer Drink-up

Image:Kiva.org logo.svg

Halle is interning at Kiva, which, given her personality, I figure is her dream internship.

Kiva is a microfinance site for the poor that allows anyone to give flat-rate microloans via PayPal. As a coincidence of the “I seem to have a lot of cash” and my New Year’s resolution to be a more responsible person, I’ve recently started to put a tiny fraction of my income into Kiva. You can view my lender page here to see that I currently participate in 17 microloans.

I mention all this because Kiva will be sponsoring a Developers Happy Hour this Thursday at their headquarters in San Francisco. Considering I give 5% of my money lent back to Kiva, I’m going for the drinks. 🙂

(Find out more about the concept from Muhammad Yunus’s Nobel lecture, the FrontLine program on social entrepreurship, conservative columnist Nicholas Kristof’s editorial in the New York Times, and the books Banker To the Poor, and Creating a World Without Poverty.)

Continue reading about Moneywatch.com after the jump

CableBox

The CableBox

I like to wait at least a day to mull over a purchase, sale or no sale. But I was waiting months on a purchase of some stuff, so tacking on a <a href="http://www.bluelounge.com/cablebox.php" title="CableBox—Blue LoungeBlueLounge CableBox (or two) to my A+R order didn’t seem such a bad idea.

Blue Lounge Cable Box(es)

Blue Lounge CableBox(es). You can Buy them in white or black.

Usually snap buying decisions are a bad idea, but this one turned out not so bad.

White side preinstalledWhite side installedThe white CableBox installed

The “white side” before, during, and after the installation.

Who knew a bunch of plastic boxes with cutouts could do so much!

Continue reading about More shots of the CableBox after the jump

Making it personal

Media moguls—journalism moguls, anyway—need two sets of skills. They have to be able to select and package material from the world in a way that gives it order and narrative drive and swagger. They also have to forge, through creativity, cunning, and force, a set of arrangements with customers, competitors, governments, advertisers, production facilities, and distribution networks which can generate a lot of money. Even in an era of focus groups and marketing research, any news publication that attracts an audience has to have a personality, which means that it has to bear the stamp of a real person.
—Nicholas Lemann on Joseph Pulitzer, William Randolf Hearst, Barney Kilgore, and Rupert Murdoch in “Paper Tigers”, The New Yorker, April 13, 2009

[To a friend on what I liked about her latest blog posting.]

“It’s like the Lauren ad from Microsoft. Using the recession to talk about things holds a lot of serious interest,” I said.

“That’s what I think too,” my friend replied, “But I remember when I used to make references to it in posts for someone else, the editor would always delete them.”

“He hails from a school that’s outdated. The biggest blogs make it personal. Take Orangette—that’s a blog about cooking. Why is it one of the most popular blogs? Or ZenHabits—how did it in two years become one of the top self-help sites?

“When I write personal articles with wide application, they take off on FeedBurner.

“It’s about making it personal, without taking it personally.

My problem is I always take it personally, 😉 ” I finished.

She laughed. “Well I already know what I’m going to write tonight!”