Response to “Where did all the PHP programmers go?”

Ok, I’ll bite in response to this “Where did all the PHP programmers go?” blog post:

What I cannot understand is why people with more than one Bachelor Degree in Computer Science recommend using bubble sort.

Sounds wrong but harmless, as you don’t write a sort implementation from scratch in PHP. You write the comparators used for the sort order, but the actual sort implementation is provided for you by language. I presume it uses qsort internally, but don’t know for sure. I have a degree in CS, and I can scarcely even recall the bubble sort algorithm (or even most of the sort algorithms for that matter), for the simple reason that it doesn’t matter in the real world (in 99% of cases) for web developers using scripting languages. That may sound (gasp) shocking, but it’s true – PHP is not a performance-orientated language, and it’s a fairly high-level language with a decent library of native functions, so you don’t generally write sort algorithms (rather you use the library ones that are provided for you, unless you have an overwhelmingly good reason not to).

The question you need to ask is: are you running a Computer Science class on sorting algorithms, or are you looking for people who know PHP and can get your thing built?

“What is the difference between the stack (also known as FILO) and the queue (also known as pipe, also known as FIFO)?”

Maybe rephrase the question to “you want to store multiple bits of information in a data structure or an array or a collection of some sort. How would you add data to the beginning of that data structure, and how would you remove data from the end?”

I.e. focus less on the Computer Science theory, and more on the application of it.

“Using PHP programming language, create a list to store information about people. For each person you’ll need to store name, age, and gender. Populate the list with three sample records. Then, print out an alphabetically sorted list of names of all males in that list. Bonus points for not using the database.”

Here’s a trivial implementation just using arrays, I don’t claim it’s remotely pretty or elegant, and I wrote just to see what’s involved in the above task:

<?php
error_reporting( E_STRICT | E_ALL );

function sort_by_name( $a, $b ) {
       if( $a['name'] === $b['name'] ) return 0;
       return $a['name'] > $b['name'];
}

function printMales( $array ) {
        foreach( $array as $person ) {
                if( $person['gender'] != 'male') continue;
                print "Name: " . $person['name'] . "\n";
        }
}

$people = array( array( 'name' => 'Bob'      , 'age' => 36, 'gender' => 'male'   ),
                 array( 'name' => 'Alice'    , 'age' => 23, 'gender' => 'female' ),
                 array( 'name' => 'Doug'     , 'age' => 63, 'gender' => 'male'   ),
                );

print "Before:\n";
print_r( $people );
usort( $people, 'sort_by_name' );
print "After:\n";
print_r( $people );
print "\n";
printMales( $people );

?>

But you know what? I had to look up the PHP manual for usort because I couldn’t recall off the top of my head whether it was “u_sort” or “usort”, and I couldn’t recall the parameters and their order. Also I had 3 trivial syntax errors that I fixed in 15 seconds. Now, I really hope for this pen-and-paper test that you are giving people access to the PHP manual, or if you are not that you are being very tolerant of minor syntactical errors or people who can’t recall whether the function name has an underscore, or who can’t recall the exact order of the parameters, and so forth. Because the question is: Is this a test of whether someone has memorized the entire PHP manual, or is this a test of whether people who can do what you want? Because when they are working, then you will give them access to the PHP manual – right?! If you want to distress people in the interview, then sure, treat it as a rote memory test of the PHP manual and Computer Science theory, and make it awkward if they get anything wrong – but if you’ve want to solve the problem of finding people then there has to be some leeway for recollection of technical trivia that you can find through Google in a few seconds.

Look, I’ve been in a similar situation of looking for PHP people to hire (the candidates were from China in this case), and the approach we used was to give them a test beforehand that they could do (in 24 hours of their own time), and then if they looked okay then they could get called in for an interview. This allowed culling people who were very bad, or who gave code that didn’t run – as there really is very little excuse for code that’s invalid or that doesn’t work if you’ve got 24 hours and access to the internet and your own computer. Most of the people weren’t great, some were very bad, and some were okay. If it helps, that PHP test is here, and it’s only intended to be a very simple test.

13 thoughts on “Response to “Where did all the PHP programmers go?”

  1. Nick,

    first of all, thanks for the response. Commenting on my blog is indeed broken right now, but I’m working on it. :)

    After reading your comments, I see that I wasn’t clear enough in my ranting.

    It was when I asked to solve that people list problem in PHP, two candidates suggested using bubble sort for sorting by name, and they wanted to go as far as implement the actual sorting. Which was, of course, an incorrect approach, since PHP already has plenty of sorting functions to solve that particular issue.

    As for the exercise itself, you passed. :) I am tolerate to syntax mistakes in pen and paper tests. I know that PHP will complain immediately when you’ll execute the problem you’ll be able to go over the error messages and fix the typos and wrong parameters. What I wanted to see is for candidates to use an associative array (not a single one even mentioned that) and a loop of some sort. Functions and custom sorting routines were all optional, and the truth is, most of the candidates I saw, weren’t able to do either.

  2. I apologise, but I cannot agree with your view. The theory behind computing is of utmost importance, and what separates a hacker from a software designer. Even if we do not implement sorting algorithms from scratch, their study provides a basis in algorithm design and analysis:

    [quote]What I cannot understand is why people with more than one Bachelor Degree in Computer Science recommend using bubble sort.[/quote]

    This is perfectly valid: Dijkstra said that the only thing Bubble Sort had going for it was the name. No qualified developer should recommend a O(n^2) algorithm, when O(n log n) algorithms exist for the same job.

    [quote]What is the difference between the stack (also known as FILO) and the queue (also known as pipe, also known as FIFO)?[/quote]

    Again, a perfectly valid question. Stacks and queues are fundamental data structures. Your alternative is an entirely different question, which asks about practical implementation of such structures.

    I cannot agree that just being able to produce code makes one a good developer, as you imply. It is the understanding of how the underlying data structures, algorithms and logic are working – exactly as the original article outlines.

  3. Nice post. I have the same feeling, I think that guy is wrong. I have 5 years programming in PHP and sometimes I have to watch the manual because I can’t memorize all the functions while I’m also writing HTML, CSS and Javascript.

  4. Where did all the PHP programmer go? Half of them are building eCommerce and social networking sites, the other half is working at Facebook ;)

  5. Thank you all for your comments! My responses are below:

    @Leonid: Fair enough – as long as there’s some leeway with the pen and paper test (in terms of looking for a logical approach, and something that would work if any syntax errors and trivial stuff were fixed) – then I have no problem at all with that. Also if some was was actually volunteering that bubble sort was the way to go and then proceeded with implementing it from scratch, then yes, you probably want to avoid that person, because they’ve got both the theory and the PHP application of it wrong. :-)

    @Daniel: I agree that some theory is important as a basis for understanding why things are the way they are, and what the fundamental limitations are. But for comparing sort algorithms, that’s a pretty pure theoretical CS area, and it’s worth learning once, but it’s not really worth remembering all the details of every possible algorithm and their order (IMHO). Instead, all you need to know is that O(n log n) is the best we can do, that qsort is O(n Log n), and that PHP’s sort algorithm uses qsort: ( http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_qsort.c?view=markup ). Once you know that, then you know that using PHP’s inbuilt sort function is the way to go, and you can explain why. But I don’t personally believe that knowing too much more detail than that is especially useful or necessary. And I agree that being able to define what a stack and a queue are is a reasonable question – but interviews are stressful situations, so even good people can make silly mistakes or fluff a definition – so having a fall-back question about the application might help. But as long as there’s a balance of application with the most important areas of the theory, then that’s probably the best approach.

    @Abraham: Yeah, I know what you mean – I frequently have to have lots of reference sources open and combine them to get something done.

    @Ben: I have a sneaking feeling that someone might have pre-warned Obama to give that answer, but it was amusing :-)

  6. @Bradberry — “…what separates a hacker from a software designer”

    I find this a very interesting quote and when I think about it…if hackers keep us software designers, and network engineers on our toes for inventing new and different way to break the rules and our systems, perhaps we need to be as good as the hackers in coming up with our solutions.

    The difference is, the hacker is there to get something done and damn the torpedoes. What many software designers do is get too involved with the “rules” and the purity of their solution. We get caught up in our own “educated” ways of doing things and the “hackers” come along and kick our asses. Why? Its certainly not because they’re dumb…its because they’re not getting hung up all the rules.

    The obvious caveat to all of this is the “script kiddy” who uses the hackers tools to the work.

    I just found that quote interesting and it got me thinking. Perhaps we as designers need to let go, just a bit, and start thinking about accomplishing a task and not the purity of its implementation, etc…

  7. Pingback: This Dev For Hire » Blog Archive » Next response to “Where did all the PHP programmers go?”

  8. Pingback: Leonid Mamchenkov’s Blog: Where did all the PHP programmers go? | Development Blog With Code Updates : Developercast.com

  9. I absolutely agree with you Nick. Your words reflect what I feel exactly when I read Leonid’s post and your answers.

    @ Daniel: Nick has been very generous to provide you a patience-filled response but I do feel what you said was not something that really made sense. I’ve taught data structures at a university but still I’d like to have a look at the bubble sort algo once to recollect if i am 100% accurate.

    We in the real world care more about the jobs that we have to get done: the real world problems, and not the stories about what Dijkstra said in 1870s.

    @ leonid: I think you’ve just been unlucky OR your country doesn’t have too many developers (which I doubt to be a fact). PHP is a simple language. Here, ‘simple’ means easy enough for those with 0 years of experience as well as 10 years of experience. I’m also of the opinion that PHP is just a tool, look for a guy who knows the Internet and web based stuff (even on jsp/aspx) and he should be good for you as he’lll surely be able to pick up PHP in a week at max I’d say.

  10. Well, PHP programmers are still in demand in Asia, specially in the Philippines! It’s not as simple as other think though!

  11. I tend to agree ……. the last person I interviewed who could explain a sorting algorithm to me ……… I couldn’t stand to be in the same room as.

    There is so much more to what these “real developers” are claiming is the be all and end all of programming.

    Guess what, know the theory and look up the details. PHP has this covered out of the box anyway.

Comments are closed.