WHEN IT COMES to matters of sentencing, the Supreme Court has repeatedly, and correctly, made clear that children — even children who have committed heinous crimes — must be treated differently from adults. The court has prohibited the death penalty for juveniles and barred sentences of life without parole for juveniles who commit crimes short of murder. In a 5 to 4 ruling last week, the court wisely extended that principle, invalidating mandatory life sentences without the possibility of parole for juveniles convicted of homicide.

Indeed, the court went out of its way to suggest that even if such sentences were imposed on a discretionary basis, rather than automatically, they would require particularly stringent justification under the Eighth Amendment’s prohibition on cruel and unusual punishment. Given “all that we have said in [earlier cases] and this decision about children’s diminished culpability and heightened capacity for change,” Justice Elena Kagan wrote for the majority, “we think appropriate occasions for sentencing juveniles to this harshest possible penalty will be uncommon.”

The two cases before the court involved relatively sympathetic defendants, both 14 at the time of the murders. In a case from Arkansas, Kuntrell Jackson and some friends decided to rob a video store; Kuntrell learned en route that one of the boys was carrying a shotgun, stayed outside for most of the robbery, but was in the store when another youth shot and killed the clerk. A case from Alabama involved more horrifying facts but more mitigating circumstances: Evan Miller beat a neighbor with a baseball bat and set fire to his trailer after a night of drinking and drug use; the neighbor died of smoke inhalation. Evan’s father abused him, and Evan had attempted suicide six times, the first at age 5.

Writing the main dissent, Chief Justice John G. Roberts Jr. emphasized the large number of laws invalidated: 28 states and the federal government impose mandatory life without parole for some juveniles convicted of murder. Foreshadowing his majority opinion in the health-care ruling, the chief justice argued that the court was improperly substituting its judgment for that of lawmakers.

These are important points. The chief distinction, as Justice Kagan noted, involves the mandatory nature of the sentencing, preventing judges or juries from considering the age of the juvenile, the nature of the crime and other relevant circumstances. Moreover, as Justice Kagan noted, it is not clear that the large number of jurisdictions imposing life without parole for juveniles convicted of homicide was the product of deliberate choice rather than the confluence of two separate statutes (one letting juveniles be tried as adults, the other imposing mandatory life without parole for homicide).

In the end, the majority has the better argument. Juveniles who commit crimes need to be treated differently because of their lesser culpability and greater capacity for rehabilitation.