I used to think that finding a candidate with successful side projects was The Holy Grail of indicators. Nothing was a better indicator for success in a role than someone who demonstrated they could identify problems, research solutions, and follow that research through to completion completely on their on passion and initiative without leaning parasitically on anyone else.
"Now I know [I thought] we've found someone who is good at all the technical parts of their job, not just a mindless hanger-on who was part of a successful team! We've got a doer, dang it! This is their code. This isn't a quick coding exercise. This is how they can work, showing what they produce."
The scary thing is that finding someone with great, complete, cradle-to-crave side projects really is a great indicator of individual ability.
Unfortunately, looking for such side projects is replete with social bias, and the question, however useful it seems, is exceptionally unfair.
@Kozaky comes closest to saying why, but doesn't take this far enough:
Bear in mind that some candidates are simply incapable of taking on personal projects due to obligations such as family, travel, other hobbies etc. By all means, ask if they spend time on open-source projects but keep in mind that an answer of "zero" should not be a black mark. The technical test is usually how you can find out if they are keeping their skills up to scratch.
The argument is this: If my present situation doesn't allow me the time and space to have "hobbies", I'm not going to have time to make a great side project. Having time is a marker of exceptional privilege.
What do I mean by "not having time"? How about...
- I'm working x > 1 jobs to put myself through school.
- I'm working x > 0 additional jobs or working overtime in my 'extra' time to allow me to support my family.
- I have family members whose care requires all of my non-work time.
- Could be parents, spouse, kids, siblings, neighbors, friends... you name it
That is, I'm not just talking about people having things like kids, a partner, nearby family, religion, friends -- "a life" -- your candidates could have serious backstories that are none of your business, pun intended.
And there are worse. Let's just mention one: "I'm abused at home." You won't learn this during an interview. In the US, eg, you can't ask, thankfully. But that's sure as heck going to stop you from completing la-dee-dah side projects.
I never really realized the amount of bias this question involved until a long Twitter thread pointed it out to me. If I can find it, I'll come back and add it. The point, and it's a point I think the other answers here largely miss, is that assuming you have leisure time for any activity, much less time for coding is, let's kindly say, a classist assumption.
You have to position your questions in a way to determine, "Does this candidate exhibit evidence they have the ability to fill this open position effectively?" based on fair, in-bounds experience. If they have relevant work history, you have to ask specifically about their job. If they have relevant school history, you have to ask about what they did in school.
If you want to see them code a full project independently (in place of an overly contrived tech interview), you hire them as a contract worker to show you, and pay them handsomely for their time. And I don't mean for a week. I mean for three months, or whatever the two sides negotiate. And note that "them" here isn't "someone without a side project". It's any serious candidate.
You also realize not everyone can drop whatever they're doing now to work for you on an interim basis.
If they offer side projects as evidence, I hope it's fair to keep what you learn "in scope", so to speak, as you debate merits later, and not necessarily punish people who are privileged and self-motivated for showing they also have the skills needed for your job, but you have, have to realize there are much more motivated people with practical, real-world priorities who will never put takes care of father with dementia or cares for autistic child as bullet points on their resume or use as topics of conversation in their interview.
And yes, this is a very difficult issue. Can you try and see if someone's a good teammate by encouraging them to share how they spend time with their coworkers outside of work? You could, but is it a fair measuring stick? Ultimately no, it's not. Your candidate could be the best coworker, but have much more important things to do than have the team over for dinner or hit a bar on Friday night.
So no, you can't ask that question, not in good faith.