My friend Robb just IM’d me to tell me he’s released a new PHP framework.
Continue reading about An engineering look at Framework Phails after the jump
Stuff about PHP (Personal Home Page or PHP Hypertext Processor), an open-source language for developing websites and web applications. And one of the few things out there with more market share than a Microsoft product.
My friend Robb just IM’d me to tell me he’s released a new PHP framework.
Continue reading about An engineering look at Framework Phails after the jump
Small little annoyance we found in the process of internationalizing the site for European locales.
setlocale(LC_ALL, 'es_ES.UTF8'); // Spanish from spain $a = 1.2; echo 'hi'.$a;
This prints hi1,2. Take out the first line and it prints hi1.2 as you might expect.
Not a big deal right? Well imagine if that is the index into a cache key of an object? Now when someone from Spain views the page, it thinks those objects aren’t in cache. Big mess ensues.
I noticed that I suggested object versioning to be integers in the documentation, but some of us were using floats and I wasn’t type-checking. Whoops!
Our solution is to only set the locale when rendering output from a template and then setting it back. It’s ugly and I’m a definite fan of using integers only for version numbers in my next life.
In a unrelated note, the people at work had a long discussion of how to render possessives when internationalizing. The key in the U.S. is to stop being clever and follow the first rule of the Elements of Style. This way it’s just,
printf(_('%s’s pictures'), htmlspecialchars($display_name));
Hopefully, the long argument I had trying to convince someone to do this will be returned in less neutered quotation marks on the site. I’m not holding my breath.
At Tagged, I’ve been working on the project for the last month. Basically it allows us to cache dynamic parts of throughout the site and keep the caches from having stale data. Since we call the APIs both externally and internally—over 20 calls to generate a user’s profile page alone—the caching is turned on at the API level.
The initial hit to the system was severe.
Basically, I was causing the profile page to take 30 extra milliseconds to render. The profile page accounts for 17% of all page views on the site where we do about 220 million “views” a day. This 30 milliseconds, believe it or not, was dropping profile page views by 5%. And it took about 20 hours of back and forth before I finally resolved to rewrite the whole thing so that it can be rolled out gradually without any performance hit.
That means I cost the company one and a half million ad impressions. 🙁
The second day’s cached piece is actually measurable on the live site with tools I wrote. I am saving between 17 and 900 milliseconds depending on the state of the backend and load on the server.
Since I can’t measure how much actual page views I’m adding back into the system, I was curious about how much extra server capacity these changes are getting me.
In other words, how much is a millisecond?
Continue reading about Measuring milliseconds after the jump.
“We’ve all heard that a million monkeys banging on a million typewriters will eventually reproduce the entire works of Shakespeare. Now, thanks to the Internet, we know this is not true.”
—unknown
I love to quote people quoting me. I do this by creating a vanity feed— I like to look at it as stalking myself. Skimming my vanity feed last night, I read this:
Terry Chay once said something that resonated with me — one of the few things, actually — and it was something like this: complex > complicated, and that simple does not necessarily mean “not complex”. The point is that you can have a complex implementation that covers many use cases, without the implementation being complicated, and with the API still being relatively simple.
—Matthew Weier O’Phinney
Only a few? Geez. I’m (almost) hurt. Next time, I see you, I’m going to call you Matthew O’Phinney.
For reference, here is the talk where Matthew is referring to, along with other previous references.
Since, like Matthew I work on a framework, I thought some of you might find this simple/simplistic complex/complicated distinction resonates with you as you write code.
I can’t claim credit for this idea. It comes from a different monkey, well before the internet:
“Everything should be made as simple as possible, but no simpler.”
—Albert Einstein
Friend: http://twitter.com/markscrap/status/1228353533
Me: 10 to 1 whatever kid wrote that is a ruby developer
Friend: haha
I’m just stating the obvious. When the first computer was invented, the legendary Grace Hopper created the first compiled programming language. That language is still around and is still popular today!
Programming languages don’t “die,” they proliferate.
And when a person makes blanket statements like, “PHP is a dying language,” it allows me to a make blanket statement about that person’s programming preferences and maturity.
The difference is, my statement is probably right.
As an afterthought someone decided at the last minute, that maybe the architect (me) should be on the architectural review of a product.
Normally for social networking web development, I allow for a little short term inconsistency. This is because only one user has access to modify a thing and that user isn’t likely to do two things at the same time. Because of this, concurrency is almost never a problem and. even if the data gets clobbered, the database at least is consistent and your objects are quickly fixed.
The problem with this particular project is that since a paid good is involved and many users will race to the same data store—inconsistencies can occur and they’d be more harmful than a goto statement. The solution proposed was to build a Java service to keep these eight pieces of data consistent. There was also a release plan in order to estimate the resource allocation for the new service under live site load.
Though late to the meeting, I opened my mouth and said, “You don’t need a Java service to do this. You can do it all in PHP and memcache.”
Continue reading about How do prevent clobbering in memcache using PHP after the jump
(A draft of this article appeared on Wednesday because I hit the wrong button on WordPress. I apologize for the confusion it may have caused. What can I say except, “Freedom is messy.”)
This morning Andrei sent me an article from David Heinemeier Hansson titled, “Mr. Moore gets to punt on sharding.”
Since Andrei and I work at pretty well-trafficked websites which couldn’t operate without the very thing David is advocating against, normally I’d just laugh naïveté in his observations—it’s been eight years since the the Internet goldrush and all that’s happened is that a new generation is repeating our mistakes and rationalizing the inevitable fail that ensues.
But there are tons of people who quote David Henemeier Hansson’s words to me at conferences and on the blogs. For every speaking engagement in which I’ve saved someone from a huge architectural misconception, Mr. Hansson has indoctrinated ten more future programmers who will make that same mistake. Like a glacier during global warming, I move forward one inch during the winter and retreat a foot during the summer.
If I don’t do something about this… well someone’s gotta think about the polar bears?
No, Mr. Hansson doesn’t get to shart on sharding. I’m going to Bush Doctrine it before I see this shitfart come out of the mouths of any of my colleagues.
Original article posted to PHP Advent 2008. Happy Christmas!
Take a simple PHP trick and follow it on a huge tangent to the philosophy of good web architecture.
It’s an honor to be asked to share my ideas with the PHP community. When Chris and Sean asked me to write an entry for the Advent Calendar, I had to accept. Like last year, this article will be quite long. If you need something short and sweet like the other advent entries, you can just read the first section. But if you read it all, there might be a worthwhile concept buried in this logorrhea.
Certainly some of the comments expand on that by attributing all manner of atrocities to me, the accusation by “Joe” is especially amusing:
funny, i’d never heard of chay but stumbled upon a few posts he made about ruby on rails whilst researching the value of ror vs php. i found his posts fit very much into the “intellectual bully” category. he was more concerned with “being right” as you put it, with fairly basic arguments actually “the top 10 companies use X, therefore X is right”.…i agree with the previous poster, coding is not a competition. we want to solve problems with the right solutions. there are many solutions to a given problem, much as that would break chay’s heart.
Yes, Joe, I’m a bully! 😀
Let’s take the evidence at hand (i.e. reality) instead of the arguments based on fallacies (ad hominem: “i’d never heard of chay” or false equivalence: “there are many solutions”) and such. As I see it, the examples of bullying referenced in the discussion are:
A) Asking a candidate to define design patterns
B) Asking a candidate to distinguish C++ vs. Java
C) Writing an article comparing Rails vs. PHP
My friend and colleague, Paul M. Jones, calls me out as a bully. Apparently from the way interviewees complain to their headhunter about me, I am.
Like W after 2004, and fully intend to use this new capital accumulated by my just-annointed “bully-mandate” to tell him (and the interviewees) off as being sore losers who can’t handle the new asshole I tore in their shit last night. 😉
In the real world, when a candidate fails to answer a question, I say, “Don’t worry. It’s okay,” and move to a different topic area as I have lots. I’ll also point out that none of these candidates actually were around when I gave my evaluation. They’d see that the only trouble they get into is if they lied to me or express something wrong with absolute confidence. Those show a lacking the ability to be able to work well in teams or learn new things. The question is designed to test those qualities in a candidate—not whether they can recite some book definition of a design pattern.
Okay, fine, but what about Paul who stands up to The Great Bully? Well let’s get down to the nitty gritty of defining (programming) design patterns…
Continue reading about Defining Design Patterns after the jump