Walking through the yard at California's historic San Quentin State Prison, the oldest in the state, it's difficult to keep movie clichés from popping into one's head. Surrounded by high barbed-wire-topped walls and amidst groups of men playing basketball and doing push-ups under a blue sky, a line from the quintessential 1994 film "The Shawshank Redemption" came to mind. In the film, Tim Robbins' character Andy Dufresne, falsely imprisoned for murder, extols the virtue of hope upon his prison pal Red, played by Morgan Freeman. "Remember Red, hope is a good thing, maybe the best of things, and no good thing ever dies." For a select group of motivated inmates at San Quentin, located just outside of San Francisco, hope comes in the form of an intrepid non-profit called The Last Mile, which is teaching convicts how to code and working with Silicon Valley companies to give hardened criminals a shot at success once they're released.

Mike Newberg/CNBC

Despite the fact that there's no internet in prison, and many of the inmates have been incarcerated since the days before the flip phone, The Last Mile has made a mission out of rehabilitating prisoners through computer coding. The organization, which is now in 4 prisons with plans to expand, was founded by venture capitalist Chris Redlitz and his wife Beverly Parenti, after Redlitz visited San Quentin in 2010 and was impressed by its business-savvy occupants. "Many wanted to start businesses, they wanted to learn how to invest, and they wanted to understand what it was like in the real world," he said. According to Redlitz, that visit changed his life. They started The Last Mile shortly after. Parenti said the driving force behind starting the program was realizing how much money is wasted on locking up criminals who eventually get released and end up returning to prison. "We invest in their incarceration to try to punish and rehabilitate, they get out and they keep going back," she said. "At the time it was over 60 thousand dollars a year per inmate, and the recidivism rate was over 60 percent."

Mike Newberg/CNBC

The highly competitive program costs roughly $200,000 per year to run, and is funded privately and with the sale of prison products like license plates. Since its inception, 20 men have graduated from The Last Mile coding program and are out working in the real world. None of them have returned to prison. Kenyatta Leal spent 19 years in jail for possession of a firearm, under California's Three Strikes law, and was part of"The Last Mile's first class. Leal arrived at San Quentin in 2005, and was already in the midst of what he called a "journey of change and transformation." "I already knew that I wanted to get out of prison. I already knew that I needed to change my thinking patterns and the way that I behaved if I wanted to get a different result out of my life," he said. After getting his college degree in liberal arts within the prison's walls, Leal was looking for a new challenge. He eventually met Redlitz and Parenti, and helped launch The Last Mile. "I had always had an entrepreneurial spirit, and this just seemed like something suited for me," he said.

Following his release from prison in 2013, Leal used the skills he learned from "The Last Mile" to land a job at RocketSpace, a technology incubator in downtown San Francisco. "I started off as a paid intern...doing a bunch of dirty work, grunt work, whatever it took," he said. "With that mindset I've been able to work my way up in the company to a management position… I actually hire other formerly incarcerated people to work at RocketSpace." Leal recently returned to San Quentin, by choice, to give the keynote speech to the latest group of Last Mile graduates. "As much as I hate that place and I didn't want to be there, there's a part of me that always wants to go back," Leal said. "Because I know that I could help somebody else turn their life around too." San Quentin inmate Chris Schuhmacher was also in attendance at the graduation, and is set to be released in April. Schuhmacher has been in prison for 17 years on a murder charge, and is part of The Last Mile Works, a joint venture program that gives inmate coders the chance to work on projects for high-profile Silicon Valley companies. At the ceremony, Schuhmacher showed off a social media analytics dashboard he designed for Airbnb, which aggregates metrics from Facebook, Twitter, Instagram and Pinterest -- companies which didn't exist when he was incarcerated. Inmates hired by the joint venture program are paid $16.79 per hour, which Parenti said is the highest wage ever paid in a U.S. prison.

Mike Newberg/CNBC