It also depends on what you're borrowing it for. A rental property or a business? I'm good with it.
Also, borrowing $10k when you have $20k is a different story than borrowing $10k when you have $1m. I realize it's the same amount of money lost/gained, but that built up base is gone for potentially 5 years and you have nothing growing in your retirement.
I've done it 4 times for other investments. Not humble bragging, but I'm in the top 1% of 401k amounts for my age after all that borrowing. My point is that I can be done successfully. I have not done the math on whether bank money or my own money was the better move though.
Another problem is people reduce or cancel all 401k deposits while they're repaying their loan.
So really, based on those factors and the ones already posted, it depends.