php_logo

HipHop, PHP, and the Evolution of Language

A lively little discussion developed over the past few days on the DC-PHP developers mailing list. We have a very active developers group here in the DC area – much larger than most cities, in fact. Part of what makes our group great is the diversity of background and experience that is in the group.

This was front and center over the past few days when one of our members, Hans, offered his opinions on Facebook’s new HipHop for PHP product. We have already expressed our intent to help make WordPress compliant with HipHop, something that will be beneficial to major WordPress sites like TechCrunch, Mashable, VentureBeat, WordPress.com, the NFL Blogs, the NY Times blogs, the Cheezeburger network (LOLcats, FAILBlog, etc) that carry large amounts of traffic. I hope to be able to consult with some of these organizations on moving into a HipHop system once my head is wrapped around it and WordPress is compliant.

Photo by Josh Hunter
Photo by Josh Hunter

Hans is an extraordinary developer. I have never met him personally, but his depth of knowledge on issues of security and scalability is downright frightening. He offered his own opinion of HipHop on the mailing list and so I’m going to pick on him a bit:

This HipHop thing is interesting, perhaps in much the same way as HipHop music: it feels like a hack. — And I mean that respectfully in both cases; I like hip-hop music, and appreciate how it pays homage to R&B roots, remixing/reinterpreting them, etc; and I think that the idea of taking one language and building it out to something else is also something I should support. After all, I’ve embroiled myself in code generation tools (e.g. Propel) that are operating on the same philosophical groundwork. But I also believe that there’s a general rule like “if you need code generation, there’s something wrong [in your design or in the tools you've chosen or ...]” … so those tools also feel like hacks.

In all of life, there is an evolution that happens. One iteration of something becomes better with improvements over time. This has happened on a micro level inside PHP. Without PHP 3 there would be no PHP 4. Without PHP 4, there would be no PHP 5. Ben Ramsey talked about this evolution before Christmas.

Why is it a hack to improve upon the tools used with a language? Is it a hack to use Memcached with PHP? Is it a hack to run on nginx instead of Apache or to implement FastCGI? All of these are third party software or extensions outside of PHP. So how is HipHop any different?

That’s all fair, but I feel like the problem here is that somewhere a long, long time ago, Facebook *must* have realized that they were going to have scaling problems. Long before they started having a problem, someone *must* have thought “maybe a compile-at-runtime language isn’t the right solution here”. I guess to me this cross-compiler is just a public way to admit that PHP is not the right tool for the job, but they’re stuck with all these developers that only know PHP so it was somehow cheaper to engineer a way to change PHP to C++ than it was to retrain developers on C++ (or, probably more realistic, Java).

I responded in that conversation with an only slightly edited response. While I appreciate, and always have appreciated, his frank, honest, high level view of PHP, web security, web applications, etc., he strikes me as somewhat naive and puritanical.

What I can say is *I*, along with dozens of other technology people in and out of DC, in and out of PHP, never look at our initial ideas as scaling ideas. We look at them as ideas and experiments to see if they have legs. In fact, I’d go so far as to say it is counter-productive to think about scale before thinking of concievability (is that a word?).

There’s a reason why Rails (God help us) is popular. It’s a great prototyping tool. You stand up an app quickly and let it into the wild to see if it has legs. Does it go? What are the market influences? What are the
pros and cons? Do we have to adjust?

After a concept is proven, then a solid dev team with solid tech leadership brings in their expertise to see if the idea can be built into something sustainable. As a sidebar, please take a read of Brad Feld’s very awesome
post from a few years ago “The first 25,000 Users are Irrelevant“.

My point is, it’s silly and a waste of resources for startup people to start thinking about how big they might get maybe 5 years down the road. I think you’d find out that, in most cases, successful technology, web-based companies happened by some dumb luck. Twitter. Facebook. Name-the-popular-app. Dumb luck.

Hey, I’d even argue that when too much comp-sci brain energy goes into an app, you get things like Wolfram Alpha. Cool. But useless. And not nimble enough to actually do the scaling necessary to need all that comp-sci engineering prowess.

Balance, my friend. Balance.

Facebook (and others) start with PHP because PHP is fairly ubiquitous and easy as pie to drop into production. However, there is a point of no return where you are committed to PHP and that’s where HipHop comes in.

Personally, I wish we had HipHop when I was at b5media. We had a ton of scaling problems with PHP and we were running fully clustered Apache servers (25 deep, if I recall), sharded MySQL across 6ish database servers, and we had massive I/O bottlenecks. We ran eAccelerator and Memcached and had squid-based load balancing and damn if Grey’s Anatomy or the Oscar’s didn’t pin our entire network on more than one occasion. What could have happened with an alternate to opcode caching. What could have happened if I had resources to put on developing C++ binaries of our frequently used PHP libraries.

I’ll tell you. It would have rocked. We were already committed to PHP. We were already committed to WordPress. And when the company started, we were all volunteer resources. There was no assumption that our idea had legs or I think everyone on the team would have quit our jobs immediately and put everything into building that company. It took a year to get there.

This is, for better or for worse, the way companies get started in the real world.

Read More

php_logo

Facebook's HipHop and What it Means to WordPress

This was originally posted on my company blog and reposted here for posterity.

By now, the news has hit the street about Facebook’s new PHP pseudo-compiler technology that is looking set to change the PHP world once again. It is called HipHop for PHP.

Here at Emmense, we build on PHP and more specifically, we build on WordPress. The PHP community as a whole continues to innovate the language and Facebook has been a longstanding member of that community. WordPress stands on the shoulders who have gone before, and there are certainly instances of large-scale installs of WordPress that could stand to use some acceration.

It is our intention, here at Emmense, to support the Facebook HipHop methodology where appropriate. We will be exploring the use and implementation of this technology in the days and weeks to come and will be working to build solutions that leverage it in the WordPress world for our clients. Where possible, our work will be conributed back to the WordPress core where appropriate.

While we expect that many more service providers will likely leverage this technology, we want to continue to lead in the WordPress community in an ever-open exchange of ideas between the PHP and WordPress communities.

Read More

php_logo

PHP Doesn't Do WordPress and WordPress Doesn't Do PHP

If there’s one thing I have been consistent on in the past (almost) 6 years of blogging and engaging on the web, it’s that I believe in the mantra “no sacred cows”. In politics, I confound and confuse members of both parties who look at life through sterilized lenses that reflect their party platform. I will often stir up controversy by dragging people into a process of debate that, while respectful, causes them to think and re-think their positions. At least that’s the goal. I am a fiercely independent thinker and though some of my closest friends are on the left, I’ve ruthlessly challenged the parts of the left that I don’t like while supporting the ones I do. I’ve done the same thing with folks on the right.

So as I prepare to write this article with an admittedly slightly inflammatory title, I expect it will cause some controversies – maybe, and perhaps intentionally, it will cause some rancor in the leadership of the WordPress community itself – the ones who set the tone and cadence for the rest of the community. This is not all bad and nobody can ever accuse me of not being consistent in how I approach issues I feel strongly about.

For nearly 10 years, I have been coding in PHP. For the past 4, I have spent my time focusing my energies on WordPress specifically. It seems to me that for software that is built on PHP, then, there should be some consistent crossover between the WordPress community and the PHP community. That natural convergence does not seem to exist however.

Early on, when getting started on the web, I hung out a lot over at the SitePoint Forums. It was there that, through a community of PHP developers of varying skill levels, that I cut my teeth. I knew nothing at the time and there were folks who were much more skilled than me. It was in the PHP 4 era (that era had just begun and has since ended) so there was no such thing as real classes and object orientation. XML parsing became a hot topic during those days as PHP devs wrestled with the best way (they were all ugly!) to parse XML. I was just trying hard to figure out how to connect to a database.

I spent months learning and picking up what I could and contributing back my learnt wisdom to other newbies along the way. The cycle of karma was great as people learned and taught each other.

Shortly after I left SitePoint in 2003, I started blogging (May of 2004). I started on Textpattern but within a week, as my curiosity about this new WordPress platform started hitting my ears, I switched over to WordPress. I joined the wp-hackers mailing list and began immersing myself in the WordPress community. Generally speaking, people were very helpful and I learned a lot.

Eventually, as part of that community, I would lead the technology efforts at b5media where my team was responsible for a very large WordPress farm. Having some of the best and the brightest working alongside me meant that my good understanding of the PHP involved in WordPress, and the event driven nature of its core, would increase to maybe very good.

Today, my business is WordPress. I just wrote the WordPress Bible. I do WordPress consulting. I run all my blogs on WordPress. I speak at WordCamps all over. Heck, I’m organizing WordCamp Mid-Atlantic again this year. I love the WordPress community.

During the writing of the Bible, Keith Casey, my friend and also a top developer in the PHP community (He works with Marco Tabini of PHP Architect – if that doesn’t give him street cred, I don’t know what will), offered to review anything I wrote along the way. I took him up on it even though I already had editors including a very WordPress-specific technical editor. My thinking? Having someone from the greater PHP community look at my code for the WordPress world can only make it better.

My question is, why doesn’t the rest of the WordPress world do this as well? We, as a community, can only be better by embracing the greater PHP community. We can learn things from them. They can learn things from us. Of course, the greater PHP community is going to scorn WordPress for remaining PHP 4 compatible when PHP 4 is end of life and I think that point has validity but that’s not the point. I think both sides can agree that WordPress has its way and it is not likely to change its philosophy on this soon.

However, what about the rest of the converging community? Why do WordPress people not participate in the major PHP conferences like Tek-X or ZendCon? Why was Beau Lebens the only WordPress guy that I’m aware of that attended any of the 7-conferences-in-14-days-roaming-conference CodeWorks?

Why is it that when WordPress developers are asked to speak at these events, they look down their nose in scorn (I can think of two specific incidents that have been related to me)?

Hey, if we’re going to have a war on PHP coding ability, I’ve got to side with the PHP coders of the world, not the WordPress coders. If we’re going to have a war on extensible platforms, well, I’ll probably go with WordPress.

My point is really simple: The WordPress community needs to abandon this concept of elitism and isolationism. Yes, isolationism only makes you isolated. Over the past six months, I have come to appreciate the greater PHP community more. I’ve rekindled my love for that community and the karma and learning that comes from it. I’ve discovered new things about PHP because I’ve opened my horizons again and got outside the WordPress box. Fortunately, by doing so, I can apply that knowledge and karma inside the WordPress world as well. It’s sort of like finally getting that water after being parched and thirsty for so long. It’s refreshing and gives new energy and drive.

So in 2010, I will continue to work inside the WordPress world to try to influence change. My code will reflect that change. I’ve abandoned PHP 4 (but again, that’s beside the point) and won’t work with it in my own work, plugins, etc. I hope to make a major announcement regarding some crossover and convergence in the next few weeks as well.

To the PHP World: Understand that the WordPress world is different. You already know this. We are a PHP 4 world for a reason, like it or not. We need some understanding. We also have our feelings on GPL and open source which don’t always jive. Work with us. Help us be better.

To the WordPress world: Get outside your comfort zone and embrace the leaders in the PHP world. I already mentioned Keith. Add Marco Tabini, Ben Ramsey and Cal Evans to the list of people to pay attention to.

Read More