The way my CS teacher in high school handled this (we had the benefit of 2-hour class periods twice a week and a normal 1-hour class period on Mondays) was to let the students go to their own level. Essentially running 2-3 classes at once.
The first part of the first semester was the same for everyone more or less: An introduction to the language (BASIC, this was in the 90s) and some basics of computing. Then for the very motivated/advanced (had already learned some programming or were just more interested0 students he provided instruction on deeper topics in CS and programming and it became increasingly self-directed. For the less motivated (pretty much everyone else) it was a series of projects that kept most of them engaged enough to learn the material. So students who came in knowing some programming or who were particularly motivated got an "honors" introductory course (in university course description terms) and the rest got the typical introductory course.
That did take him being particularly motivated as a teacher and knowing the material well enough to pull it off, though). Evaluations can be challenging if students obsess over "fairness". The advanced students are getting As almost as a given, and some of them might resent that the other students can also get As for doing less work. But that's just kids being kids. The advanced students opted to go in for extra work, it wasn't forced on us and technically we could have fallen back to the regular coursework at any point.
The first part of the first semester was the same for everyone more or less: An introduction to the language (BASIC, this was in the 90s) and some basics of computing. Then for the very motivated/advanced (had already learned some programming or were just more interested0 students he provided instruction on deeper topics in CS and programming and it became increasingly self-directed. For the less motivated (pretty much everyone else) it was a series of projects that kept most of them engaged enough to learn the material. So students who came in knowing some programming or who were particularly motivated got an "honors" introductory course (in university course description terms) and the rest got the typical introductory course.
That did take him being particularly motivated as a teacher and knowing the material well enough to pull it off, though). Evaluations can be challenging if students obsess over "fairness". The advanced students are getting As almost as a given, and some of them might resent that the other students can also get As for doing less work. But that's just kids being kids. The advanced students opted to go in for extra work, it wasn't forced on us and technically we could have fallen back to the regular coursework at any point.