describes
a harsh historical view that early punishment prevents later wrongdoing. The literal wording advocates an extreme penalty and should not be understood as acceptable modern advice.
The saying “Hang a thief when he is young, and he he 'll no' steal when he is old” can be used when a harsh punishment for a young offender might stop him or her from doing later a crime.