The teenager, who cannot be named for legal reasons, punched Euan Craig, 14, repeatedly at a South Side school on May 23 after being hit accidentally by a sponge ball as they waited for gym class to begin.
Euan immediately apologised, but his attacker, who was 14 at the time, punched him five times, inflicting serious head injuries.
Euan slumped to the floor and appeared to suffer a seizure.
He was given first aid until ambulance crews arrived. Euan died the next day in the Southern General Hospital.
The attacker had admitted a charge of culpable homicide at an earlier court hearing and, as reported in later editions of yesterday's Evening Times, judge Lord Bracadale ordered him to be locked up for three years and six months.
The judge, sitting at the High Court in Edinburgh, had heard defence suggestions that detention may not be necessary. Defence QC Ian Duguid said the attacker posed a low risk of reoffending.
He also pointed to the view of an expert who suggested that placing the boy in secure care may impact negatively on him in the longer term.
But Lord Bracadale ruled a custodial term was the only appropriate sentence in this case.
He said the teenager would have been detained for five years had it not been for his early plea of guilty.
The judge described the consequences of the attack as "catastrophic" and told the court: "The assault was a wholly unnecessary one."
He said the attack had had a profound effect on the victim's family.
"By all accounts, he (Euan) was a popular and well-rounded boy," the judge said.
"He had his whole life ahead of him. His prospects were good and he had every expectation of going on to leave school, enter higher education and graduate to a worthwhile career.
"He came from a close-knit family and was plainly the apple of the eye of each of his father and mother. He was close to his sister.
"It is clear from a very full victim impact statement placed before me that his untimely death has had a profound effect on the family, who are going to have to live with this immeasurable loss."
The court heard previously that Euan and the teenager were third-year pupils at the school.
They knew one another but were not friends.