Resources for Teaching C to High School Students?
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?"
Don't try to teach the language, any more than you teach someone how to use a pen when writing.
Teach the mentality, the methodology of problem solving.
Teach basic algorithms, data structures and coding theory - give them an understanding of where the libraries they are suing will come from.
More importantly for modern world working teach colaberation, give them a real group project to do, each of them writing different interfaces or different parts of an interface for a whole program (something like a simple game such as tron is ideal for this)
By doing all of this the language becomes almost incidental - which is really what you want, who knows what the demand for C, C++, javam C# will be in a few years time, but learning the right methodology and colaberative practices will stand them in good stead for years to come.
$_="Slashdotter";$syn="OTT";s;..;;;sub _{print shift||$_};s!ash!Perl !;s=$syn=ack=i;tr+LLEd+BLAH+;_"Just Another ";_
... plagiarism is bound to be a possibility, especially with access to the internet. I know what when I was doing my C course years back at school, a lot of students ended up borrowing chunks of code from each other. And, in a few cases, taking one listing and just modifying it for their own purposes. And since they moved the code around a bit no-one really got busted. That was before we even had access to the internet, either!
But don't teach them C. Teach them a language that focuses on how to structure programs without bogging them down with memory management, pointers, etc, etc. A firm understanding of OO would also be much more useful and much easier to grasp.
There's a reason there are so few resources on teaching C to high school students; it wasn't meant to be taught to high school students.
// MD_Update(&m,buf,j);
You need more of 3 things.
1. Funding to buy letters.
2. A better lesson plan so you can aim for something higher than a class of C students.
3. A tech savvy room of students.
1. For a class of 30, I would suggest 10 As, 20 Bs, 10 Cs, 5 Ds and 2 Fs. Yes, it doesn't add up to 30, but you should give mostly As and Bs, a couple Cs for those seniors who just want something, anything to take and pass while they transition from HS to college, and the D/Fs are for those who are truly slackers and just don't even give you the half effort.
2. Sorry, I hate to shoot down others, but you seriously want a class of C students? I'm sure administration wouldn't be too happy with that.
3. I hate to lay it to you, but I've seen average college students have a hard time dealing with scripting, and teaching programming is thinking differently to a higher level. You said you want to teach a few motivated students, yet you need to be open to everyone who enrolls. I would suggest you have lower and upper level classes. Lower level will teach the basics of how a computer thinks, and how to write a basic program. Those in the upper level, is more independent study and you're there as their troubleshooter, adviser, and teacher for when they need new concepts and get stuck. And while you're at it, make writing a short paper (maybe 300-1000 words) on the project they did. It's good for them to learn documentation, communication and know you're boss.
Ok, 1 and 2 were a joke, but 3 was serious. If anyone is upset, laugh. it's meant to enlighten your day. god its 3am, and i have a final in 5 hours and i'm only 50% prepared.
Grump.
Is it true that more people vote for the winner of American Idol, than vote for the president? -Ali G.
I'm not sure there is a standard in the industry - or atleast a single standard.
On your brace style question, about the only agreed thing in the industry is that each dev team/company should pick a standard. Preferably with reasons for each decision.
Its not just about braces either, what about constants, variables, upper/lower case, underscores, sub routine calls, tab indenting, spaces vs tabs, the lsit goes on.
I'd recommend that you read Damian Conway's Perl Best Practices (O'Reilly) - not to say that those rules map to C, but for a guide as to sensible reasoning behind such decisions.
Rather than teaching your class a particular set of rules, why not cover several of the rules or guidelines others suggest, then as a group have them sit down and decide on their "department" coding standard. The excercise in itself will be more valuable than simply saying where to put a curly brace. Quite possibly as a precursor to the group colaberative effort I suggested above.
$_="Slashdotter";$syn="OTT";s;..;;;sub _{print shift||$_};s!ash!Perl !;s=$syn=ack=i;tr+LLEd+BLAH+;_"Just Another ";_
For example, did you know that 99.99% of high school students can't read Perl?. Shameful, shameful.
[foot icon here]
It takes a man to suffer ignorance and smile
Be yourself no matter what they say
The first course where I had to use C there was only a bare minimum of introduction to get started. It was the course Numerical Physics in the second year of university. Almost nobody had any programming experience. The first day we received an introduction to C and we where assumed to know at least basic C things (simple flow control, variables arrays and functions. No pointers, structs etc.). From the start we where graded on the use of comments and you could net get any help if you did not indent your code. I don't know if this method is good for everyone, but I do know a lot of students learned at least decent (for such a short time-span) programming skills. There where even students, who had never programmed before, who went home and started typing in notepad. When they brought there code the next week it almost compiled at the first try. Of course you have students who copy almost all of their code and don't know what they are doing. So my experience is: don't explain everything, just let them start with the bare minimum and let them ask for help and let them solve their own problems.
If you want to teach basic C (such as function calling, variables, and basic expressions), probably any "Learn C in X days" book will do the job. But at that rate, there's not much point in learning C over a simpler language, like Java. Teaching memory organization is essential to anything beyond trivial C, so for high school students, teaching a language that stresses the higher level concepts first may be wiser.
Many books don't do hardware / memory fundamentals right, if at all, and that might be a problem for finding good reference material. I find that everyone I teach C to runs into the same problems, which are usually either poorly explained or just don't "click" until after a while:
1. The fact that an array, a pointer (of any level), and an address are fundamentally the same. I.e. not seeing that there's no conversion needed from "type[]" to "type *"
2. The fact that the '*' character is syntactically confusing: in a type declaration it defines a pointer, in an expression it deferences one. Mistake example: const char *ptr; *ptr = "String";
3. The fact that a C-style string is an array of characters.
4. The fact that declaring a pointer does not "create" memory - it creates a variable which holds a (potentially uninitialized) address to memory. Mistake example: const char *ptr; strcpy(ptr, "This will probably crash.");
As for books, unfortunately I don't know of any off the top of my head. Finding one that clearly explains those issues would be my best choice (Randall Hyde's "Write Great Code" is excellent but is about assembly, not C, unfortunately). Good luck, teaching C can be hard, but leads to a far greater understanding of how computers work. You may end up choosing an easier language.
If you say "here goes my karma" I will bite you!!!
In univeristy the text book I used was Data Structures and Algorithm Analysis in Ada - Ada was just picked by the university to ensure no student had an advantage from already knowning the language as it is rather obscure - it is also a very strict language to write in.
I found the text very good and the same author offers the same text aimed at C (though I will admit I have never looked at the C version, though I suspect it would be similar to the Ada text in most places)
Data Structures and Algorithm Analysis in C (Second Edition)
Mark Allen Weiss
* Published by Addison-Wesley, 1997
* ISBN: 0-201-49840-5
It might be worth a look for you
$_="Slashdotter";$syn="OTT";s;..;;;sub _{print shift||$_};s!ash!Perl !;s=$syn=ack=i;tr+LLEd+BLAH+;_"Just Another ";_
I had a really strict C teacher by the name of John Perry and I loved him. Make sure that you don't let the write sloppy code or they'll never cut it as programmer. If you don't know the difference between sloppy code and good code then you shouldn't be teaching C. Write a thousand lines of code and hand it to a person who has written plenty of C programs in his lifetime and if he said it's clean then you're golden. Structure is very important. First of course you need to teach the basics. the main function and modularizing code. The structure of the program. Operators and variables and stuff. control statements, loops...ect All these things can be found in just about any basic C book and just about any tutorial online. http://www.its.strath.ac.uk/courses/c/ After you teach them the basics and about pointer, design, methodology, ect... then heres an idea... The best way to get high school students excited about C is to write a game. Unfortunately game programming could be complex for new programmers. A programmer typical is responsible for a small portion of code. So, you write most of the game and have your students write little modules for stuff. For example high score records. Thats pretty easy and only requires someone to know how to edit a text file and sort scores. Describe a function for your students to write in as much detail as possible. After all the modules have been written put it all together. Then when they see they see the game working they have a sense of accomplishment. I think that most of todays students think they want to go into programming because of games. Why not play on their interests?
Please someone mod parent funny - that article nearly had my in tears!
"A Book on C". Apart from the errors in this book (which, when I last looked about 7 years ago, are few), I think it's great. The errors, by the way, will be picked up by the better students. I'm not convinced that C is a great first language, but if you insist, I reckon that book is good (if it's still available). Then again, lots of stuff is written in C and available as source code; so, in that sense, C would be a great first language. There's not many current applications written in, for example, modula-2 that have their source available. Taking into account "learning by example" then C is, in my opinion, top of the stack.
When I learned C it was as an independant study in high school and I used primarily O'Reilly's "Practical C". I thought it did a pretty good job, but I also used variety of other books like K&R. The most useful book for me besides Practical C was "C: A Reference Manual" by Samuel P. Harbison and Guy L. Steele, but as the title implies, it was not a book about learning C.
If you're talking about programming C++ and not straight C, I think a good book would be "How to Think Like a Computer Scientist". It's a free text (FDL) that has a versions written for Java, C++ and Python. I think it's a great text for beginning programmers because it teaches some of the fundamentals of computer science. Not a great text for college CS classes, but perfect for high school students or intro to programming classes.
1. Realize that you are only qualified to do so much with this. Your job here is to facilitate these students' independent learning, rather than to try to teach them C programming, since you barely understand that yourself.
2. Get a few copies of The C Programming Language, Second Edition, by Kernighan & Ritchie. Aside from the ISO standards, it's the authoritative source for C, and it describes the language in detail without a lot of fluff. As a side benefit, it will also familiarize them with the K&R coding style (but this is by no means important at this stage).
3. Give them some existing code (read: games) to modify. They'll learn a lot just by looking at what other programmers have done, and it they'll be able to see results quickly, which is important if you want to maintain their interest. If you're using Linux, there's a ton of open-source code they'll be able to use. If not, you might be better off with something like writing Quake II mods.
4. If it's not fun, you are failing.
http://outcampaign.org/
currently studiying Computer science So I could have forgotton how hard it was (is?) :)
;) )
Anyway... K&R's The C programming Language
1) Cheap
2) Most importantly it's clear,short and to the point.
This is believe, suits motivated students better than crappy 1000+ pages books ( American style!
The first chapter(s) are fine as an introduction.
As a plus they can actually use it to look stuff up, instead of just tutorial oriented books.
It's clear and short. And gives you the basics
Ofcourse you could argue that the problem is teaching them C, but i don't believe it matter that much. Really.
still reading?
I was tought Pascal (allthough I allready know some stuff atvthe time, like BASIC and Z80 Machine code). And I would suggest teaching them Pascal using "Programming by design" by Miller & Miller.
I found that to be an excellent course...
Some posters have actually recommended that you teach from reference books, instead of books meant to teach the language. I'm amazed and appalled.
http://www.deitel.com/books/chtp5/
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.
"If you make people think they're thinking, they'll love you; But if you really make them think, they'll hate you." - DM
Use Koenig and Moo's Accelerated C++ to teach modern C++ rather than C. Modern C++ (meaning C++ written in a modern style) does not require much memory management or other "nitty-gritty" stuff, but it allows the students to learn in a framework in which such bookkeeping tasks can be introduced with minimal fuss when appropriate. Also, the book is succinct, thorough, and pedantically correct.
It's always a long day... 86400 doesn't fit into a short.
In high school, I took an AP Computer Science class that taught C++. If I understood then what I understand now, learning C++ would have been a whole lot easier. My teacher focused too much on the language instead of concepts.
After several failed attempts at trying to learn how to program, I finally understood basic concepts such as variables, integers, arrays, etc. I then took a more basic computer science class, "Algorithm Design/Problem Solving," that used the book Programming Logic and Design. This book does not use or concentrate on any specific programming language. All our assignments were done in pseudo-code and we had to show the logic of what we wanted accomplished. I have to admit it was a lot easier trying to convey the logic without having to worry about the syntax.
It's been a couple semesters since I've taken that class, without any programming in between, and now I've picked up The C Programming Language. I am currently half way through the book and ,I must say, I finally understand and appreciate the concepts being taught. I wouldn't quite recommend this book to the pure beginner, because it assumes knowledge about basic concepts such as variables, compiling, etc. The book, at a little less than 300 pages, is written and presented much better than the 1000+ page programming books I've run across.
If I were back in high school, I would love to have these concepts introduced at a gradual progression. Basic programming concepts -> Logic & Design w/ pseudo-code -> the actual language of choice using an easy to learn (30 minute intro) compiler. Of course, hindsight is 20/20 and I'm not too sure if I would have paid as much attention to the first two concepts. Since you are teaching in a high school, I take it you have 2 semesters to teach the class. Perhaps dedicate the first half of the first semester with logic. You can have them play different logic games and tie that in with the lessons.
Creating a good foundation makes learning and teaching a whole lot easier.
hackers of the world unite!
Ritalin.
Most high school students I've dealt with don't have the patience to simply pay attention during programming classes... they're all too busy daydreaming that they're game programmers.
Nothing! They get C's on their own!
Am I in the wrong forum?
Show them hell of assembly language programming (that will teach them computer architecture in sufficient detail) then offer them salvation of C. They'll understand it in a click.
Repeat with C in place of assembly language, C++ in place of C.
Repeat with C++ in place of C, Java in place of C++.
Repeat with Java in place of C++, C# in place of Java.
Berkeley Machine Structures first 8 lessons or so provide a quick and dirty intro to C.e riesid=1906978347
http://webcast.berkeley.edu/courses/archive.php?s
Yeah it might be over their heads, but you should be able to watch it ahead of time and glean enough understanding to show it to them.
Dan Garcia, who i think is currently teaching it is also a great and entertaining prof.
I'd imagine many high school students will not be very interested or they might be turned off by what they perceive as something that will not be useful to them. I would argue it might be best for a highschooler's first programming class to spend a good bit of time initially going over all the various things that they themselves find interesting (perhaps you could run an anonymous survey on what they would like to do with programming). Maybe they want to hack or program games or start the next google... You should further emphasize and demonstrate that C is an excellent language to learn for both practical uses and similarities to other languages. You could dazzle them at first by showing them things like game programming, security (focus on perhaps decryption/encryption and viruses), robotic vision, databases (emphasis on size and predictions via data mining), robotics, etc... not to mention computer related jobs, the big companies pushing them, and all the money behind it. If interest seemed generally low, you could even test them on their knowlege of such things, or do a week of group presentations on various points of interest.
Next I'd say foundations are of key importance. They should refreshed / taught on what integers vs. real numbers are and how the computer emulates them. They should be taught binary, and the concepts of different base numbering systems. They should be given a refresher on order of operation, and also taught the modulus operation. Either get them on a simple ide, or set them up with a good simple text editor like editpad and an installed gcc compiler. Get them to code Hello World, get them to code some mathematical operations, get them to code something that takes input(input to give them that power, not confuse them with memory addresses)... Go through the different variable types; go through the core of structured programming: if/else/while. Maybe you could craft a program with such a crafty structure it would take some understanding in terms of getting it to exit and return the right result...
I've gone on longer than I should, but a good late project could be to have them make a small and simplified old school text based adventure.
> But don't teach them C. Teach them a language that focuses on how to structure programs without bogging them down with memory management, pointers, etc, etc.
My thoughts exactly: think of the children.
In addition to the book recommendations, you might also like to introduce your students to the relevant Usenet newsgroups, particularly alt.comp.lang.learn.c-c++. There are a lot of people on these groups willing to help out newbies with genuine questions, and the level of understanding and correctness is much higher than many other resources (including a lot of the books you'll find in a store). Usually, all they ask is that students make a genuine attempt to solve a problem or read up on a subject before asking questions about it, and since you said these were keen students that shouldn't be a problem.
If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
I'd say python, or a similar language with a good interactive shell, and similarily equipped with with poweful libraries would be much better, because it would allow the kids to actually do usefull stuff.
... python would be an almost perfect fit, especially paired with a couple of modules/packages like http://www.pygame.org/ and http://ipython.scipy.org/.
On the other hand, if you want to give them a feel for how the computer "really" works, teach assembly programming. C has a place in modern programming, but I think it's a bad choice for a first language.
For just about any language, you can demonstrate basic concepts, and give such thrills as being able to print out your name 10 times etc. But for moving on to doing really cool stuff that you can show your friends, such as consuming rss, doing interactive 3d etc
Java comes a close second, but even using a tool such as http://judo.sourceforge.net/ or http://www.bluej.org/, java requires much, much more setup pr project to get up and running. Additionally java has no transparent compilation, which means you're stuck with the write-compile-test-cycle, rather that just write-test-change-test...
Another alternative would be http://www.squeak.org/ and/or http://www.opencroquet.org/. But it's a pretty steep learning-curve going from c to smalltalk, IMNHO. You're students should have an easier time of it, though.
Give some thought to what platform you and your students will be working on, too. For Mac OS X, I suppose objective-c might be a good place to start. On linux, I'd go with python, on windows, either python or c#.
The one good thing about c, that is also true for assembler *and* python, is simplicity. You don't *need* an IDE to get from idea to working program. Programming java with notepad and javac very quickly becomes difficult to manage, due to classpath-issues. But with c and assembly you'll still need linking for anything but the most trivial programs -- another win for python (or perl, ruby tcl, lisp etc).
First, C is a horrible language to learn on. Try something like Python or Ruby. There's a book out there that teaches Python where every project is some type of game. That's a good one. There's also the free online textbook, How to Think Like a Computer Scientist. Haven't tried that one, but it's free.
Also, you asked about brace style. Yes, there is One True Brace Style . Unfortunately, no one can be told what The One True Brace style is. You have to see it for yourself.
On a similar note, I'm surprised you didn't ask whether to use vi/emacs. Or maybe whether to teach on linux or windows.
Powered by Web3.5 RC 2
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
Morality is usually taught by the immoral.
- a poorly presented list.
The Wikipedia article on C lists some tutorial material.We had C during our Computer Architecture classes. The fact that it translates easily into assembly and machine code can be a benefit.
One of the coolest things we did was to write an asm method, write a C program that uses it, compile them with -O0 and debugging info, and then link them together manually, load them in a debugger and see what exactly happens. Not something you should do in your everyday life, but a fantastic experience.
However, I agree that it's not a language to teach day-to-day programming with, or to start learning to program. There are a lot of better languages for that.
One CS student VS 893 DOS games: Let's play oldies
"Absolute Beginner's Guide to C" by Greg Perry. It covers C, it's conversational, and it's a very gentle introduction for somebody who has not had a whole lot of programming background (this is not to say it's some fluffy book!). Deitel and K&R and all of those books are great books, BUT they're dry as a bone and might not exactly motivate your budding class. I feel that this book is the kind that they might actually *want* to read rather than be the book that they consiously decide to ignore.
The GP2X is an excellent platform for C development .. its a very straightforward environment, there is very little setup stress, and the results are fun and definitely playable.
.. nothing says "fun" more than getting the code, compiling it, running it and seeing it work and play ..
Plus there is a veritable cornucopia of examples and projects out there that students can learn from
As for the brace indent question, there is really only one answer: indent -kr -ts4 somefile.c
; -- the corruption of government starts with its secrets. a truly free people keep no secrets. --
Some good program assignments I give my CS1 tutees are:
It is more simple and straight forward than a higher level language. I taught myself using a free book online, Art of Assembly, and later took the class. The book covers some basics of computers and programming that is useful for many languages. We were required to document each line of code. They recommended that we document as we go, but reading Assembler after the fact and documenting it is no harder than doing the same for C++. Many people consider it their hardest CS course, but I would reserve that label for the advanced automata and lanague theory course.
I only look human.
My mother is a halfling and my dad is an ogre, so that makes me an Ogreling
The other advantage is that Java and C++ can be had for free with nice helpful IDEs. The Eclipse CDT (http://www.eclipse.org/ ) with cygwin (http://www.cygwin.com/) provides a fairly full IDE (and you can tailor it's key interface to EMACS :-) ). Eclipse also looks to be a fair Java IDE and there is also netbeans (http://www.netbeans.org/).
As a book I would suggest one I have enjoyed using in its online form, Thinking in C++ by Bruce Eckel (http://www.mindview.net/Books/TICPP/ThinkingInCPP 2e.html). It has the advantage that there is also a second volume that takes you into using more advanced features (fancy templating, STL, and some more complicated patterns) that they can look into or you could use as a follow on.
I realize I'm probably beating a dead horse here, but I'm feeling compelled to contribute my two cents' worth. (Save up the change for a root beer or something.)
You could teach C, C++, Java, Perl, Smalltalk, Fortran, or any number of other programming languages, either structured or object-oriented. But if the students don't get some of the basic concepts of building algorithms and flows, all they're going to come out with is the ability to recognize a given language based on the syntax...three out of five times.
Better to start with giving the students a foundation in the thought processes that go into program development: defining the problem thoroughly, choosing the best framework for a solution, seeing if there's already a solution available, deciding if what's available is better or worse than something "home-brewed", and only then sitting down with pen and paper and starting the actual design. If you want to use C as a foundation language for demonstrating the process, well and good. But, IMO, problem-solving should be stressed over the mechanics of any given language.
As to the selection of language...again, IMO, C or C++ isn't the best first choice, even though they're de facto industry standards at this point. If they can write good, clean, tight Java code, it's a fairly short step up to C++. If they can write good, clean, tight Smalltalk routines, learning a SQL variant will be a comparative snap. Tossing them into the mix at the C or C++ level, especially as neophyte coders, will send at least half of them screaming for the nearest AOL chat room, and give at least a third of the remainder migraines. Teach them to walk first, then to run marathons.
All the world's an analog stage, and digital circuits play only bit parts.
You have the basic experience to continue learning, and pass on the relevant parts to your students. Some resources I would recommend are the MIT Opencourseware and the Berkeley Webcast.
These resources provide two similar but different approaches to learning about computers and programming.
I only look human.
My mother is a halfling and my dad is an ogre, so that makes me an Ogreling
I'm a highschool student, and have been programming in C for many years (around five). My best suggestion is to go for the same as most college students; if you want to learn to program in C, just use the K&R. As all of us know, the things that makes CS texts 1000 pages are trying to teach computer science, not the language. Teaching the two together is hard, but if they're smart, they should be able to figure it out. I know there are tons of people smarter than I out there in highschool, so I'm sure teaching two concepts at the same time will be possible. C's a good language too, you don't have to worry about all the fluff you get in other languages, you understand more how a computer actually works, rather than memorizing the library of a language. If you want to teach them about general CS, keep encouraging the math as well. And best of luck to all of them.
My favorite exercise for learning a bit about computing is implementing the following iterated function system:
.5 .5 <= x < 1 }
f(x) = {2*x , 0 <= x <
2*x -1 ,
choose x_0 (in [0..1) ), find x_1 = f(x_0), x_2 = f(x_1)...x_n = f( x_(n-1) ).
How do different values of x_0 affect the behavior of f_n(x) ?
Is this what you expect to happen?
Hint: if x_0 = 1/3, x_1 should be 2/3, x_2 should be 1/3, x_3 should be 2/3 and so on; why does the computer get this wrong?
I think that teaching kids to program in C is a great idea. I started out by taking C++ in highschool, and I'm now working as a professional developer.
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.
Famous Last Words: "hmm...wikipedia says it's edible"
I did my undergraduate at LSU in Computer Science, where they start off everyone in C. I have enjoyed the language as I have been able to transition to newer, high-level languages easily. Whether this is because of C or the mindset you need to have with C, I think teaching them C is a good way to start. As for materials on learning and working with C, I recommend the following books / websites: 1. C: How To Program by Deitel & Deitel (ISBN: 0-13-226119-7) (http://isbndb.com/d/book/c_a09.html) This is the first book I learned on. The 2nd edition does a real thorough presentation of material with lots of code and visual examples of good techniques. Also, the 2nd edition did a really good job of incorporating library headers and function prototypes, which are harder to find in a book. 2. The C Programming Language by Kernighan & Ritchie (ISBN: 0-13-110362-8) (http://isbndb.com/d/book/the_c_programming_langua ge_a05.html)
This is the holy grail of C books since it was written by the original creators of the language. Despite its slim size, both Kernighan & Ritchie do a really good job with making it concise and relevant. I can guaranty that every C developer has this book on their shelf. It also has some information about interfacing with Unix/Linux OS.
3. Data structures and algorithms book in C
I am sorry, I really meant to give you the actual book title I used but it is on my shelf at home. You want to find some type of data structures and algorithm book to enforce good design techniques.
The biggest problem I have seen when people learn how to program is the fact they learn how to solve a problem only with the tools of the language. This makes them reluctant to move to other languages that don't provide solutions in the same mechanism. By having your students work in a lower-level language like C, they learn how to build the data structures taken care for you in other languages (stacks, queues, trees, graphs, etc) so they develop the mindset rather than a functional dependency.
Hope this helps and keep up the good fight!
With today's freely available (OSS) Free Pascal compiler it would be easy to get started using Pascal. This compiler not only understands the Borland flavour of Pascal, but it also has flags to compile other modes of Pascal, even Mac.
But I digress. Instead of teaching the language, teach the concepts, yes. I agree with that. I'm still teaching myself some basic things as a hobbyist, and this language/compiler have helped me come to understand some comp sci concepts, such as: linked lists, pointer management, etc {yes, pascal has pointers, sigh. yes they can be just as powerful}).
I offer this as an option instead of C. Use C if you want. Use pascal if you want to use something that was designed to HELP teach students, intitially. It's way more powerful than a toy however, Pascal has grown up, it never stopped growing, and now we have a free implementation that works on several platforms.
Guess I'll get modded down with you.
spam, spam, spam, spam, e-mail, news and spam.
I'm going to buck a trend and say that C is actually a GREAT first language to learn:
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.
If it was tough for me, it should be tough for them. Make them kick it old school.
I would recommend Turbo Pascal, instead. That's what was taught in my high school, and it REALLY helped me gain a stronger grasp on programming concepts. It also has a very similar structure to C early on, so it'll be a good stepping stone for learning the logic required of programming.
"Better to be vulgar than non-existent" -Bev Henson
Some people are going to roll their eyes at this suggestion but if you are trying to teach programming to people who have never programmed before, I'd recommend the old standard from 1981 Karel the Robot: A Gentle Introduction to The Art of Programming by Richard E. Pattis. It's not C, but it is a very clever book that provides an excellent introduction to the concept of programming and why programming languages work the way the do. I'd been programming for 15 years before I'd read it and I still learned a couple things from it. All programmers should read it just for it's historical value.
+0 Meh
You have to change the way they think.
I have been a developer for the past ~10 years since dropping out of college, and in that time, I have had to use:
FORTRAN 90
C
C++
Perl
PHP
Javascript
C# (.NET)
Visual Basic / VBScript (.NET)
Picking up the new languages is easy, as they all share fundamental concepts and data structures. Teach your students about scalars and arrays, pointers and sorting/navigating through arrays, conditional statements, iteration (do n, for loops), conditional iteration (while, do while), and some basic math.
The important thing is, once you have taught these basics, you need to make the students learn how to break down a problem's solution into a set of these steps. You need to get them to start THINKING in terms of conditionals, loops, etc. That is the real goal IMHO.
I've built up so much character I have an alter-ego
I've been in this situation. I had a few years experience with C, and the students at my school wanted a C class. I mated it to existing Basic class taught by an experienced professor and mirrored his Basic course exactly... except in C. The professor didn't know C, but he didn't need to because his course was teaching programming using Basic, not Basic. It was trivial to take his course material and port it to C. I just had my C students do most of the same exercises as the Basic students. This was a 'first' programming class for most of these people, so I really didn't get into the more C specific stuff. A problem might have been like: "make a program that takes input of amount/time/rate of a mortage, then generates and prints an amortization table, sortable by column, using only 'for' loops". Same stuff you get in any first programming class, langauge doesn't matter. In all fairness though, I was bad teacher and wouldn't do it again.
First teach them programming concepts using Karel the robot for about half a semester. That will give them an easy intro to the ideas without dealing with any real-world irritations. Then move them over to any decent language like Python, Pascal, a modern BASIC etc. Stay away from C and C++ for beginners unless you want to explain what a segmentation fault is.
- For the complete works of Shakespeare: cat
The industry group Association for Computing Machinery has a model curriculum for integrating computer science into K-12 education. You might find some helpful ideas in there.
First, I'd get them started in an area that will capture their imagination: Games programming. My son is taking a game programming class, and he's having fun learning loop controls, collision detection, etc. He recently wrote a program that converts Doom3 character mesh data to XML file format, and another that renders them on the screen. He also ported the game "Blocks" from the TI-85 calculator to Linux from scratch. As to books, Game Programming All in One, 2nd Edition is a fairly good comprehensive book. It covers most of the basics, and comes with a cd with sample code and development tools.
And, I am certified to teach computer science in high school. And, I am a programmer with over 30 years of experience. I can probably help you quite a bit. You should be able to contact me through slashdot, if not post a reply and we'll figure out how to communicate.
:-)
First off, you are still a very early stage beginner. That means that anything you do will require you to learn *more* than the students learn. I would try very hard to make your classes into more of a guided discussion and collaboration that a traditional lecture course. Get the students to research the areas they are having problems with and teach the class the solutions. Discuss, discuss, discuss.
Second, reach out to the tech community in your town and find experienced people who can help you.
Third, take on projects. DO NOT start out by teaching them and if and a for loop. Pick a project and let the students drive the teaching as you lead them through the problem of figuring out how to do the project. I would suggest a simple game or simulation, something the students are interested in. OTOH, there is a serious problem with expectation management. Cloning pong, asteroids, or tetris is a reasonable goal. Cloning WoW is not.
Pick the right tools. It is important that you pick tools that all the students can have access to. That includes PCs and development tools. Design the course around free tools that will run on cheap PCs. It all depends on what they students have access to. But, you can teach programming on $40 PCs running Ubuntu with completely free tools, or you can teach it on $3000 PCs loaded up with $5000 worth of software. The amount of programming they learn will be the same.
Stonewolf
I'd give them full credit if the license of the code they used permits them to do so. This is pretty fundemental to programming - noone in the real world writes totally from scratch - and much of any program is Knuth + small wrappers. If they took code where there is a license giving them permission to do so, I'd say they're totally OK.
OTOH, if they do something like steal GPL code and don't release their distribution (to their teacher) under a compatable license; they should flunk.
Nah, if you want to teach higher level concepts teach them Lisp. That's something that REALLY changes the way you think about programming, forever.
Patterns are for languages that doesn't support adding higher level constructs based on others.
Meanwhile, C teaches them how the computer really works without the excruciating detail of assembler, so they can evaluate in an intuitive way the performance of a given algorithm.
However, C++ seems a good compromise to me. It is multi-paradigm, so you can use objects if you need them, or generic template programming if you need them, or use stack-instantiated simple objects if you need them (try that with Java!).
Keeping with C++ I second the sugestion of Bruce Eckel. That's the best C++ book I've ever read.
We are Turing O-Machines. The Oracle is out there.
I'm not sure how "serious" your classes will be, but you might consider teaching an AP Computer Science curriculum. The current language used for the AP test is Java, so you would need to get a good understanding of that language before you begin teaching it. If you prepare the students for the AP test, they have the opportunity to earn some college credit (and hopefully they'll take it seriously).
Even if you don't do a full AP curriculum, there are some good text books written to take HS students with no previous programming experience and prepare them for the test. You might also consider some older texts written when C++ was the AP CS language (1998-2003).
Check on the ACM curriculum recommendations. http://www.acm.org/education/curricula.html and http://acm.org/education/k12/k12final1022.pdf
Also the College Board. http://apcentral.collegeboard.com/apc/public/cours es/descriptions/index.html
Due to the fact that the College Board Computer Science AP test is given using Java, I highly recommend that in place of C/C++ as the language framework for teaching the concepts. Any language chauvinism aside, Java tends to be easier for beginners to grasp since it has far few "dark corners" to get into. Those dark corners are invaluable to programmers who need them, but for learning they tend to be counter productive. My son placed out of his first two programming courses due to AP, though that was a few years ago when the test was given in C++. Java is very much derived from C/C++ so you should have relatively little trouble adjusting yourself. You'll also find active online communities of other HS Computer Science teachers so you can find/share resources there, especially for things such as appropriate texts for the earlier courses (the AP courses should use the same texts as nearby colleges) and appropriate programming environments for whatever your computers are running.
Personally, I suggest that you start students in a simple web environment using a plain text editor, then once the programs become non-trivial, move into either Eclipse or Visual Studio, or at least get a good language aware programming editor. It will take about a week or two to get them used to the environment, but it pays off big time for debugging and general productivity.
Hey, I learned C the "real programmer's" way, from K&R version 1 ... but that was more than 20 years ago, and things have moved on :-)
Something I came across recently is Phrogram http://phrogram.com/. It was formerly known as KPL -- Kid's Programming Languague. It's Windows-only and it's not Free (Libre) but the "express" version is free. The premise of Phrogram is that what got many of us into coding all those years ago was stuff like BASIC on the Apple/Commodore/Atari/BBC/whatever that let you do "coo stuff" easily. Of course, the definition of "cool stuff" has moved on so Phrogram aims to make it easy to do stuff like 2D and 3D game development easily (there's a great demo of flying a 3D spaceship in 30 lines of code).
I've got no affiliation with Phrogram -- but if you want to get kids hooked on coding, it may be worth a look
I learned C from K& R (and Turbo C). But... it's written as "you're a programmer, here's a new lanuguage and how to use it", for professionals, and maybe CS students. There should *absolutely* be 75 copies in the library for students.
On the other hand, it has not "moved on". When I started in CIS, I had two terms of assembly, which they don't get now, by default. That, alone, has helped me debug any number of times: I don't need to know the assembly language of the specific machine, but to know *how* code works and is actually executed. Besides, when it comes down to it, it's one instruction at a time, and C is fundamental to so much of all systems and code. (Quick - what language is PHP written in?)
And, yes, all the objectionably-oriented programming is nothing more than an attempt to enforce 25 years of good programming style by compiler.
mark
10 years ago, When I learned C in high school, on the first day, the instructor handed out a photocopy of a very simple program. Our assignment was to type in to the computer EXACTLY as printed. Many of my peers had difficulty getting their versions to run. I even had a few minutes of head scratching until I found my missing semicolon.
You give very little information about your students. Do they have any programming experience at all? Are they writing games on their calculators? Did they overhear that "C is language that all the good programmers use?" IMO, I would only teach C to a teenager who's already written a simple video games that are beyond your abilities. (I wrote a simple video game when I was 13 in GWBasic.)
Now that 10 years have passed, I think there are much better languages that you can teach to teenagers. For beginner programmers, consider teaching them HTML, JavaScript and PHP by having them modify existing web pages. (I learned GWBasic when I was 10 by modifying games that I used to play when I was 5.) For intermediate and expert programmers, use Visual C# or Visual Basic .Net. (Both are very similar.) They're forgiving enough so that casual programmers can get something done; yet powerful enough to allow an expert teenage programmer to create professional-grade games, servers, and multimedia applications. (If only I had C# when I was in high school...)
In addition, if you teach C#, it's very easy for a motivated student to transition to straight C. C# has very similar syntax, (which will help you because you already know some C,) and it allows programmers to play with pointers. (Ick!)
If you do decide to bite the bullet and teach C, don't make the mistake that my high school Pascal teacher did... He taught us structures, pointers, and then how to allocate memory. He didn't even mention returning memory, nor did he intend to until I made a huge stink about it in class.
No, I will not work for your startup
Seriously... start them out on the mostly useless or niche languages so you can seperate the wheat from the chaff. Once they've learned one or many of these languages they'll have no trouble picking up C (plain ole, ++, #).
Also, use Knuth and only Knuth as your text.
There are only two books: The C Programming Language by Kernighan and Ritchie; and Expert C Programming by Peter van der Linden.
Contrary to popular belief, the former is suitable for beginners - they just require guidance. Do them a favour and don't buy any books that pretend to make it easier: more pages; less content. Most of them are named "C Programminig for {Scientists,Engineers}".
Finally, steal lecture slides from your local university's first C course. You might also wish to teach them something of a non-procedural paradigm like a functional language (Haskell is cool).
I if was to teach a programming course of any language, being able to use the debugger effectively is a skill/lesson that is without value. Seeing a program run step by step is a great aid to not only students but "professionals."
May I please have my frontal lobotomy if I bring back the ashtrays?
Just how do you write your Perl? Even one-liners can be translated if you break up the statements into something slightly more understandable... :]
.01% to begin with...
Of course, I know CSS removal code when I see it and I'm not really fazed by a tr/// that changes uppercase to lowercase, so I must be in that
Isnt there a software development class in high school there?? We have one in Australia (NSW) and they taught us the understanding of programming logic, flow charts, data management and all that, but you were required to teach yourself the langauge of your choice. I myself taught myself PHP for the subject and did pretty well. Infact i recommend PHP as a language, because its easy, has C similar syntax, you can make simple GUI's with HTML not hundreds of lines of code, theres lots of good documentation on the web and it very closly resembles C. We had a Major project which we worked on for about a year, and we had to go through the whole structured approch of developing your program, from designs and interviews, flow charts and pseudocode and then to developing a beta doing bug fixes and eventually producing the full project, if your luckly;) the course ran for a lil under 2 years, so i guess thats just how we do it here.
You're probably too young, but back in the 1980's there was a program called 'C Robots'. Essentially your task is to write a program to operate a virtual robot in a virtual world - your robot must search and destroy other robots it comes across.
Start them off with something cheap and easy - Turbo C is a fairly good IDE and the DOS versions are freely downloadable off the Internet. Set the goal of writing the best robot. Offer a prize.
There are other variants (C++ Robots for example) but it might spice things up as you could sell the course as a competition - there is therefore another reason for kids to seek your assistance as you could help them win.
I was gonna recommend King's C Programming: A Modern Approach, but it's apparently a $100 book these days.
It might be worth it anyway; it really is an excellent C text. No C99 yet, he's working on a revision.
My blog: http://www.seebs.net/log/ --- My iPhone/iPad app: http://www.seebs.net/seebsfrac/