Resources for Teaching C to High School Students? 166
mctk asks: "I'm a high school teacher who, disappointed with the lack of computer science in school, has promised to teach a few motivated students programming after school. As an enthusiastic novice with three semesters of C under my belt and a few side projects worth of experience, I feel competent yet ignorant. I would really appreciate suggestions for resources on C that are written to be accessible to high school students and contain lots of ideas for activities. Perhaps you've had success with a series of books that spans beginner to advanced? Do you have any activities you would recommend? How would you map a student's first year of coding? I welcome any and all suggestions. While we're on the subject, is there a brace style that is most standard in the industry?"
Re:Don't teach the language (Score:4, Informative)
Try a few exercises away from the computer where the students can learn without the pressure of a blinking cursor demanding some kind of input from them right off the bat. Look at things that are popular in their culture such as games and have them try to break the rules of each game down to instructional steps, as well think about the thought process that goes into planning a move, and then explain it in instructional terms... all of it in plain english.
Another good one, is learning how to sort various forms of data, along with the numerous ways one can achieve a sort (such as the bubble sort). A great physical example of sorting are things like the Towers of Hanoi puzzle (the one with the disks and three pegs), or a deck of playing cards.
Pushing an entire programming language on someone before they know the basics of how programs function will only scare or frustrate them... especially when they have the prospect of a failing grade looming overhead.
Get them thinking outside the box before putting them *in* one.
Re:I know I'll get modded down for this: (Score:4, Informative)
I agree with the OP, C would be a terrible choice for first-time programmers IMHO. You need to keep them motivated, and that works best when the reward-to-effort ratio is high. Python would be a great choice: learn them the basics (forced indenting! \o/), and introduce them to stuff like pygame which allow nice results with very little code. At the end of the semester they would be able to make small stand-alone games. Kids like flashy things.
For a follow-up course, you could choose to go C/C++. But it would only be of use to those who will eventually get a CS/EE degree, which already (should) have enough courses on C.
Teaching books, not reference. (Score:3, Informative)
http://www.deitel.com/books/chtp5/ [deitel.com]
Deitel & Deitel books are amazing. The professor I had in college used them to teach, even though the college didn't actually approve them. Even the worst of the students was able to understand the examples and follow along. I was amazed that he managed to teach the worst few the basics and they could actually write programs. Seriously, they had NO business trying to learn programming, and they were learning.
But don't just hand them the book and tell them to have fun. Take each chapter and make a lesson from it, as if it wasn't in the book and you had made it up yourself. (Obviously, don't read from the book.) You'll automatically say it differently than the book did, and when they go back to the book, they've got a second way of looking at it automatically.
And make them type in the code. Don't let them copy it from the CD. If sounds stupid, but it definitely helps them remember what's going on, and the mistakes they make in typing will help teach them to debug.
Re:Watch out, though... (Score:2, Informative)
It's an after school program. I really don't see cheating as a problem. They're kids who want to learn something: not just get their ticket punched. In a normal school class, though, I'd agree with you - up to a point.
I could easily make a block of code look and function different without having any knowledge of how or if it works.
They could learn a bit if they tried to replace var++ with ++var. Or, if they did this:
var= var+1; var == var + 1;
I think you get my point. And hopefully, I got yours ;-)
I'm still on my first cup of coffee.
A free book to learn CS using Python (Score:5, Informative)
If you want to teach basic programming skills using Python, there's a very nice free book which can help: How to Think Like a Computer Scientist: Learning with Python [greenteapress.com]
Educate the Educator - Resources (Score:3, Informative)
These resources provide two similar but different approaches to learning about computers and programming.
Consider Their Maths Background (Score:3, Informative)
I've seen a lot of comments saying that you should focus less on the language, and more on things like datastructures, algorithms, analysis, and design. I agree that it's important to give some instruction on the basic concepts behind coding, but I think that you're going to have to remember that these are Highschool kids, and it is highly unlikely that they will have the mathematical background to really dig into algorithms.
I also disagree with people who are encouraging you to teach them languages such as Python. While it's true that there are languages that are much better than C at allowing you to get something impressive from a small amount of code, I think that it's detremental to students in the long run. After all, you aren't trying to specifically get these kids interested in programming, rather they are students who were interested enough to come to you.
The biggest thing that I think you can probably do to give the kids a leg up is to focus on the lower level aspects of C. Do a good bit on memory allocation and debugging, and spent a lot of time on pointers. If these kids are interested in going on to become programmers, then making sure they have a solid grasp on pointers is probably one of the best things you can do.
One of the most amazing things about kids is that, when they are cooperative, their minds are incredibly malleable. Take some of the hardest parts of programming, and start getting them to adjust their thinking toward it at an early stage, and you will find that they will become incredibly skilled programmers if they stick with it. Remember that given their mathematical background, there probably isn't a lot of point in trying to get too deep into analysing algorithms, and keep in mind that there is a lot of benefit to learning close-to-the-metal programming and they might not get it in a university (which seem to be focusing on Java more and more). Be sure to keep the assignments fun and challenging, and taylored to the things that they are interested in.
The last bit of advice is that you should focus on more than just teaching them to code. Get them into the culture as well. In my programming class, for example, we used to have a weekly assignment to read and post to two stories on slashdot. We watched Revolution OS and Pirates of Silicon Valley. Get the kids into the hacker subculture and they will go much further as developers as well.
C is an excellent choice (Score:3, Informative)
1. It has a simple way to do console and file IO (scanf, printf) that will enable students to write and test simple programs.
2. It is used everywhere. As students learn more of C, they will be able to access and use the vast array of libraries available to C and go as deep as they want. When I was 16, it was common to learn C in order to start writing games, and then assembly language to make the fast loops faster. Another student learned assembly language in order to debug DOS viruses.
3. It is completely deterministic when run in one thread.
4. Its syntax is very simple. There are very few gotchas, most of which can be resolved with extra parenthesis.
Everyone else saying "pointers suck", "use a simpler language", etc. are forgetting two things about that first programming language. First, no matter what language you start with, it will be difficult to begin programming. The learning curve for Lisp/Python/Java/Ruby/etc. will be at least as steep as that for C for new programmers, and additionally there is little point in teaching OOP to people unfamiliar with structured programming and the problems OOP is meant to address. Second, it is frustrating to learn a language that has little use elsewhere, especially when it is because someone else claimed that it was better to know general concepts than to know a useful language.
Check out the ACM K-12 model curriculum (Score:3, Informative)