Section 28. A defendant aggrieved by a judgment of the district court or of the superior court in any criminal proceeding may appeal therefrom to the supreme judicial court.