Better analogy is that classical musician is given sheet music to pop song and is told to play it on his favorite instrument. If he is good musician, he should be able to play it reasonably well even without practicing. There are musician who play extremely well but only after practicing one song for a long time - this type of interview sucks for them but they are minority. Most musicians suck with or without practicing so this type of interview is a good filter. Not ideal but no one came up with better one that scales up to thousands of applicants.
In an audition, musicians are usually asked to play a mix of prepared and sight-read pieces (though sometimes the sight reading is from standard repertoire, so they may have encountered before). Both are helpful in discerning how qualified the musician is. And sight-reading is incredibly important for most jobs musicians get hired for - in most freelance situations, they'd get a 3 hour rehearsal, or essentially a guided run through of the performance, then they play the gig. So that may not be an accurate analogy, given that writing on the fly isn't part of the programming repertoire - most programmers are allowed to think before they write anything down. Also musician's don't write - performing is very different than writing- so perhaps a composer would be a better analogy.
Maybe it would be a more accurate measure of ability to ask software engineering applicants to read code and explain what it does, or to judge them as you'd judge a composer, by their portfolio.
That would be an interesting way to apply something like re-captcha: ask them to fix two bugs in open source applications. One bug that you've actually already fixed, so you know how hard it should be and can calibrate; the second bug is open.
Agreed; the idea of hiring a musician without hearing them play would be madness. Not handing me a recording, not discussing intricacies of music theory, but actually playing live. And yet, a talented studio musician may suffer from performance anxiety in this situation. What to do?
I think the best thing is to ask them to warm up with something basic like a scale, and let them work their way up as their comfort level increases. I knew some people who were particularly pleasant and easy going, so they were able to relax people suffering from performance anxiety.
There are interviewers who treat coding interviews as a high pressure, adversarial exercise, though. On the other hand, those sorts of people are rarely a joy to work with.
Performing a piece of music in a high-pressure situation is exactly a professional musician's job, so an audition is quite appropriate. Another analogy could be to ask a professional composer to play one of his pieces on piano rather than listening to a competent orchestra perform it--you're using one thing as a proxy for another. Many composers would ace it--they're great players. Some aren't, though, so you'll hire only composers who happen to be great performers. It's a dumb analogy in another way, though: you only need to know whether you can work with a composer, their work should stand on its own. I suppose if we engineering types all wrote code that went into public repositories the same might be true of us, and we wouldn't be asked to perform like trained monkeys.