Learning Python
I'm always eager to learn new things, so I've been exploring Python a bit lately. I'm gradually learning the ropes of Django, and I've also been working my way through this tutorial for developing a desktop-based roguelike.
I'm really digging it so far. Python's syntax is ultra-clean and easy to learn, and as far as I can tell, Django lives up to its promise of rapid, scalable application development. I've always shied away from the major PHP frameworks, which strike me as bloated and over-complex—but working with Django has been an entirely different experience. It takes care of all the repetitive grunt work, so you can focus on the creative stuff and the big picture.
It'll be a while before my Python skills are up to speed with my PHP skills, but I can definitely see myself adding Python to my daily toolbox—or even switching to Python as my primary language.
The module pattern in JavaScript
Ben Cherry of Adequately Good explains JavaScript's module pattern. This pattern is everywhere in modern JavaScript codebases, and Ben does a great job of explaining it clearly and concisely.
The reports of its death are…pretty fabulous, actually
It looks like 2010 will be the year Internet Explorer 6 finally dies. Googling for "ie6" returns a Microsoft-sponsored ad for IE9 (now in public beta), followed by a slew of sites campaigning to phase out the antiquated browser. Some of the biggest players on the web—Google, YouTube, Facebook—officially dropped support for IE6 this year, to much fanfare. Most (if not all) of my clients and colleagues have followed suit.
This is remarkable for a browser that still claims a double-digit percentage of the market. Businesses don't willingly shut out ten percent of their potential customer base, unless that ten percent is an enormous pain in the ass.
It's also exactly what needed to happen. The main reason IE6 is still alive is that corporate IT departments have been reluctant to upgrade from aging Microsoft enterprise software that doesn't work in modern browsers. By unilaterally dropping support, web developers are forcing their hand.
Sorry, guys—I know that major version upgrades of mission-critical enterprise systems aren't fun (or cheap). But you're holding back the web, and you're making an awful lot of extra work and frustration for web developers and their clients. IE6 is almost a decade old, and it's been superseded by two major versions, with a third—IE9—in public beta. It's time to move on.
Once IE9 is in general release, I suspect very few developers will continue supporting IE6.
What about IE7? It's far superior to IE6, but still dodgy. Fortunately, the situation that has kept IE6 around for so long—a widely installed base of expensive-to-replace software that only works in one browser—doesn't apply to IE7. With IE6 in the grave, IE7 can fade away much more gracefully.
We'll probably have to support it for a while yet—there will always be those users who don't know what a browser is, much less how to upgrade one or why they should do so. But IE7 won't be around a decade from now.
Who knows? A few years from now, maybe I'll even remember IE6—in all its neurotic naïveté—with fond nostalgia, as I now remember Netscape 4. Maybe.
Casting arrays as objects (and vice-versa) in PHP
I just learned that it's possible to cast an associative array as an object in PHP.
It works the other way, too—an object can be cast as an array.
This is especially useful when working with the results of database queries. A lot of codebases seem unsure whether to treat database rows as arrays, or as objects. In these environments, it's likely that you'll get one type as the return value from a particular method, but need to pass the other type as an argument to a second method.
So it's nice to have a simple and language-native way to convert between the two. Some simple demo code:
<?php // create an array $array = array( 'prop1' => 'value1', 'prop2' => 'value2' ); // cast it to an object $object = (object) $array; echo 'The value of the property prop1 is: ' . $object->prop1 . '<br />'; echo 'The value of the property prop2 is: ' . $object->prop2 . '<br />'; // cast it back to an array $array2 = (array) $object; echo 'The value for the key prop1 is: ' . $array2['prop1'] . '<br />'; echo 'The value for the key prop2 is: ' . $array2['prop2'] . '<br />'; ?>
Peter Michaux
Douglas Crockford's articles on JavaScript (and his posts at the Yahoo! User Interface Blog) have helped me greatly to understand the more exotic and subtle features of the language, along with the patterns that exploit those features.
Now I've discovered a similar collection of articles by Peter Michaux. They often riff on Crockford's ideas, sometimes offering a fresh perspective and sometimes explaining things in a more accessible way. Well worth a read for aspiring JavaScript ninjas.
Fun with hot dogs!
Check this out:
If you're using any modern browser (that rules out IE6 and IE7), you should
see a picture of a hot dog above.
But no such image file exists on my server—or on any other server. You're looking at a PNG image, but there's no PNG file anywhere.
How is that possible?
Right-click on the hot dog and view the image properties—in particular, note the image's src. You'll see a URI that begins with data:, followed by a very long string of gibberish.
Hiding WordPress page links
When developing a custom WordPress theme, it's necessary to provide prev/next navigation wherever there might be more than one page of posts: the main index, search results pages, and archive pages, for example.
posts_nav_link() provides the simplest way to do this—it automatically displays either or both of the links, as needed. If you need more control over the markup, next_posts_link() and previous_posts_link() let you display them independently.
New look! Same great taste!
If you've been here before, you'll notice that things just got a bit spiffier.
There are still some layout quirks in Internet Explorer—I'm working on it.
Let me know what you think!
Check out my new Flash game site
If you find yourself with a few minutes to kill, check out Plastic Lounge, my new Flash gaming site. There are already hundreds of free games available, and I have hundreds more to add as time allows.
Honest feedback is always welcome—it helps me to provide a better site. Hope you find something you like!
The $300,000,000 Button
If you think that usability, information architecture, and user experience design are made-up disciplines for lily-gilding aesthetes, with little practical bearing on your Web site, think again.
Jared Spool explains how changing one button in a site's checkout process increased sales by $300 million per year. (He doesn't name the retailer in the article, but it starts with "A" and ends with "mazon.com".)
