22
Jul

PHP is getting closures!

Posted by dave | No Comments

I’ve seen very little from PHP that got me excited lately.  So, imagine how excited I am to hear that closures are coming to PHP 5.3!

If you’ve done a lot with today’s popular Javascript libraries like jQuery and Prototype, you’ve no doubt come across closures.  They’re little self-contained functions that can be passed around like variables.  For example, jQuery’s fadeIn() method takes a function as its second parameter, and calls it when the target has faded in.  With a traditional coding style, you may have written something like this:

 

function doStuff1()
{
	// do some stuff...

	$('#mydiv').fadeIn('normal', doStuff2);

	// do some more stuff...
}

function doStuff2()
{
	echo "hello world!";
}

This works, but there’s a visual disconnect between what happens in the middle of doStuff1() and what happens in doStuff2(). And, when you start reading doStuff2(), you don’t have any context for what’s happening (unless you left really good comments). If doStuff2() is used in more than one place, you have a justification for keeping it a separate function. But if it’s only used this one time, a closure is the way to go:

function doStuff1()
{
	// do some stuff...

	$('#mydiv').fadeIn('normal', function() {
		echo "hello world!";
	});

	// do some more stuff...
}

This code is more compact, and it makes it clear that the echo statement is related to the fadeIn() call.

I use closures a lot in my Javascript coding, and I’m sure I’ll be using them a lot in PHP once 5.3 is widespread.

Bookmark this post:
Digg Del.icio.us Reddit Furl Google Bookmarks StumbleUpon Windows Live Technorati Yahoo MyWeb
20
Jun

High-performance JavaScript

Posted by dave | No Comments

Here’s another talk I watched recently on how to speed up your web sites. This one focuses on Javascript, and offers techniques to make your scripts run faster — or at least appear to run faster:

Bookmark this post:
Digg Del.icio.us Reddit Furl Google Bookmarks StumbleUpon Windows Live Technorati Yahoo MyWeb
20
Jun

Even Faster Web Sites

Posted by dave | No Comments

I watched a great presentation from the Google I/O conference yesterday.  It’s by Steve Souders, creator of the YSlow plugin for Firefox, and he’s talking about making your web sites load faster.  He offers some sneaky little techniques to make browsers load your scripts in parallel, among other things.

Want to shave another second off your page load time?  Watch the video & slides for Even Faster Web Sites.

Souders recommends an tool called IBM Page Detailer which creates charts showing how much time your browser spent downloading & processing each part of the page (HTML, images, Javascript, etc.).  It only runs on Windows, sorry.

Bookmark this post:
Digg Del.icio.us Reddit Furl Google Bookmarks StumbleUpon Windows Live Technorati Yahoo MyWeb
07
Jun

Automated Testing Patterns and Smells

Posted by dave | No Comments

If you decide to do automated unit testing of your web applications, this presentation from Google Tech Talks covers ways to make your tests more complete and efficient:

Bookmark this post:
Digg Del.icio.us Reddit Furl Google Bookmarks StumbleUpon Windows Live Technorati Yahoo MyWeb
06
Jun

June 5, 2008 Notes

Posted by dave | No Comments
  • Check out Jeff Atwood & Joel Spolsky’s new Stack Overflow podcast, a discussion about software development.
  • PHP Sucks, But It Doesn’t Matter
  • I had someone email me looking for a LAMP developer for a 3-6 month contract in the Loop. You need framework experience and a BS degree in a computer or business field. Also, they need experience with XML, SOAP, WSDL, ASMX, and/or something. Email me if you’re interested.
Bookmark this post:
Digg Del.icio.us Reddit Furl Google Bookmarks StumbleUpon Windows Live Technorati Yahoo MyWeb
06
Jun

PHP: ADOdb or PDO for DB Access - June 5, 2008

Posted by dave | No Comments

Tom’s Presentation from this evening:

Bookmark this post:
Digg Del.icio.us Reddit Furl Google Bookmarks StumbleUpon Windows Live Technorati Yahoo MyWeb
06
Jun

PHPUnit Presentation - June 5, 2008

Posted by dave | 1 Comment

My presentation from this evening:

Bookmark this post:
Digg Del.icio.us Reddit Furl Google Bookmarks StumbleUpon Windows Live Technorati Yahoo MyWeb
04
May

Dan’s Ruby XML Presentation

Posted by dave | 1 Comment

Here’s Dan’s presentation from this month, on XML processing with Ruby.

I know what you’re thinking…Ruby?!?! But, I think it’s important to see how the other languages out there do things. Maybe you’ll like what you see and decide to become a Ruby programmer, or perhaps you’ll pick up some ideas for writing your own PHP libraries!

Download Ruby and XML

Bookmark this post:
Digg Del.icio.us Reddit Furl Google Bookmarks StumbleUpon Windows Live Technorati Yahoo MyWeb
18
Apr

My mod_rewrite presentation

Posted by dave | No Comments

Here’s the presentation I put together for last month’s meetup. I hear nobody showed it in my absence, but I thought at least some of you might be interested.

Bookmark this post:
Digg Del.icio.us Reddit Furl Google Bookmarks StumbleUpon Windows Live Technorati Yahoo MyWeb
18
Apr

High-Performance javascript: Why Everything You’ve Been Taught is Wrong

Posted by dave | No Comments

Yeah, we’re a PHP group. But most of the PHP code out there is on the web, and modern web sites rely heavily on Javascript for AJAX & DHTML effects.

This talk from last year’s OSCONconference talks about ways to improve Javascript performance. Some of these techniques are pretty sneaky, and aren’t immediately obvious. But I’ve tried some of them out, and they made a big difference in the how performance was perceived, even if they didn’t make big actual improvements.

Bookmark this post:
Digg Del.icio.us Reddit Furl Google Bookmarks StumbleUpon Windows Live Technorati Yahoo MyWeb