Maybe, but if you treated them as more than a disposable cog, as is the trend, they might not. Show them opportunities for promotion, be respectful of their time, show them they won't be fired for petty reasons, and generally treat them like a human being and let them know they have a future with you. Searching for jobs sucks, being the new guy sucks, discovering that a new company's culture isn't a good fit and having to start the process all over again sucks. Give them enough reasons not to go through that and the money won't even matter that much if they have any wisdom in them at all.
Another advantage of training them yourself is that you shape them into precisely what you need. They know your systems, your work culture, your priorities, and are continuously adding to their institutional knowledge.
This. If https://insights.stackoverflow.com/survey/2018/#work-how-do-... is to be believed, compensation and benefits are the most important thing to most programmers. But it's not the only thing, and my guess is that beyond some "good enough" level, other factors become more important.
Imagine you were hired at a company, trained and mentored in a whole new skill set, given work you enjoy and find meaningful, working with people who encourage your further development, and were shown appreciation for your efforts and abilities.
Would you leave at the first opportunity to get a raise? Unless I really needed the money or was severely underpaid, I probably wouldn't.
I would argue that programmers are still a very special group with a bias towards/a culture of short term gigs. Within my circles, those around 40 are either not programming anymore or work at "unsexy" companies with perks and benefits like "9 to 5" and paid 6 week vacation time. The cool ones still maintain a geek-comptible culture under the hood but that is not expressed in free beers and scheduled crunchtimes.
I'm curious if it's actually possible to treat all employees as more than a disposable cog. I worked at Google and have several friends that work at Google. There's a ton of work to do that is not fun and doing it feels like disposable cog work. It's not fulfilling but it needs to be done. This is one reason lots of people leave. There's a few glamorous jobs and lots of not fun jobs. I'm sure others can come up with better examples but basically with such large code bases things take forever to implement, pass all the tests, and need maintenance forever. There's so much to do and the team so large that you personally get to concentrate on one tiny tiny part of years. Maybe another example is working on drivers for the various new ChromeOS devices. Another might be all the solutions engineers for companies using Google Cloud related stuff. I know people doing it. Their job is to take a call from the customer and then try to write code to show them how to fix their issue. Maybe there are people who want to do those things but I don't.
It was once quite common for people to work completely unglamorous assembly line jobs for decades at the same company. Maybe the real issue is that google's hiring practice selected for prima donnas?
Maybe the smart people saw what happened to those that chose to work unglamorous assembly line jobs for decades and realized it's not to their benefit.
Probably because they want actual raises over time instead of the promises of increasing pension pay, which as have many found out is just a lie. Even big companies like GM, promised good pensions years ago, hit a double and got rapid inflation to make the pension payments a fraction of what they were expected to cost, then decided it wasn't enough and went for a triple by successfully lowering pensions for people that have already long retired, bought out other's pension plans for similar pennies on the dollar caused by the fear of lowering pension payouts, and then gave bonuses to all of upper management afterwards because they did so good at destroying other people's retirement and possibly life.
I sometimes do unpleasant work because it needs to be done and I support the long-term goal. My boss talks to me like a human being and makes sure I'm being well compensated in other ways. Unpleasant work != being a cog.
Another advantage of training them yourself is that you shape them into precisely what you need. They know your systems, your work culture, your priorities, and are continuously adding to their institutional knowledge.