Deterrents like hash punishments work, but only to the extent that the person has an option. Many people who turn to crime have no or few professional skills, and would struggle to make a living completely legitimately. Hence, they do what anyone would do in that situation, and commit crime to survive.
And when individuals are locked away in prisons for years at a time with no rehabilitation, nothing's really changed. They are still in the same situation as before, except now they have a criminal record, making their situation even more dire.
This leads to a revolving door effect where many individuals end up back in the same prison they just left. Not only does this ruin the person's life, it also costs the public in both lost productivity, and costs associated with housing imprisoned individuals.
Many modern countries short circuit this cycle by educating and rehabilitating imprisoned individuals so by the time they leave their cells they are ready to join the economy as an effective worker.
Think of it this way, if your child was struggling to get passing grades in school, what would be more effective? Locking them in their room with a book, or hiring a tutor?