Revenge is definitely another story. Here we are dealing with our base emotions. I had no idea how woefully weak is my understanding of punishment until I started to think about it. All I can do here is list some of the problems that bother me. The ages around 14 and 15 mark the start of frontal lobe development, while the end occurs near 20 and 21.
Frontal lobes are where rational thought occurs.
Therefore, if talking about rehabilitation, the age of the criminal should be taken into account. It would serve Society's interest if young prisoners were forced or induced to learn skills or get a high school education. Perhaps, a college education could be offered. The cost of the degree could be paid off as if it were a student loan which, indeed, it is. Perhaps, we could craft sentences so that achievement is preferable to time in the eyes of the prisoner.