tags:

views:

139

answers:

7

Has anyone had any experience in teaching programming in C to undergraduate students, who can be presumed never to have seen an editor before in their lives?

I might soon face that predicament, and was thinking of basing myself on the K&R "The C Programming Language" book. Has anyone had a similar experience? What are your ideas/recommendations? Is C the right language to teach undergraduate engineers as a first language?

A: 

If you're teaching under Windows, this kinda fails. I suggest using a good beginners book, for C and then move on to K&R.

If you're teaching under Linux, I would advice a beginners book as well, there's plenty good books out there, take O'Reilly for instance.

And don't force them into IDEs or editors with a steep learning curve like Vim.

I'll add some good learning books later.

polemon
Note that Express Edition of Visual C++ gives you a command-line compiler, `cl`, which IMO is easier and faster to use than the IDE.
Paul Nathan
A: 

Is C the right language to teach undergraduate engineers as a first language?

A Brief language comparison.

Basic

DIM A As String = "Hello"
DIM B As String = "World"
DIM C As String = A + " " + B + "!"

C++

string a = "Hello";
string b = "World";
string c = a + " " + b + "!";

C

char a[] = "Hello";
char b[] = "World";
char* c = malloc(strlen(a)+strlen(b) + 3);
strcpy(c,a);
strcat(c, " ");
strcat(c,b);
strcat(c,"!");
/* don't forget to call free(c);  */

Now, which do you think you should be teach to folks who've never seen a text editor?

James Curran
C, because engineering students get to learn the dirty little details.
Paul Nathan
-1 because you mentioned basic: "...whereas the teaching of BASIC should be rated as a criminal offence: it mutilates the mind beyond recovery."http://en.wikiquote.org/wiki/Edsger_Wybe_Dijkstra
Johannes Rudolph
@Paul: They need to learn the dirty details about engineering, not Programming. Here the computer is merely a tool, and using it should be as simple as possible. Actually, the best choice for them is probably Excel.
James Curran
All the engineers I know (including some in their sixties) are basically competent programmers. Not sophisticated, not deeply educated, maybe a little weak on process; but able to express problem in little pieces and translate them into working code. All of them.
dmckee
@James: If people want to keep training engineers to program weakly, being ignorant of the internals of the computer programming model, being untaught to design high-quality software, and generally semi-competent with their primary tools and reduced to using Excel - be my guest. But in my experience dealing with engineers, they could use a year of good serious programming experience in college. It would make their *tool using* much better. Asking MechEs and EEs with minimal levels of coding to code like comp sci people (which is frequent) is quite silly.
Paul Nathan
@Paul: Huh? In your first three sentences, you sound like we're talking about software engineers insted of MechE. Then, your last sentence is *exactly* my point!
James Curran
@James: No, my point is that full-time engineers are being asked to code like computer science people, *which means* that their training needs to incorporate more computer science.
Paul Nathan
@Paul: All the more reason why the tools they use should be as simple as possible. This argument is getting foolish. How much Electrical enginnering should I know to turn on a light bulb? How much metalurgy, to wear a gold ring? You are telling them to get bogged down in triviality *completely* irrelevant to *their* task at hand. Knowing the details is *our* job, not theirs.
James Curran
@dmckee: Which is exactly why they shouldn't be required to deal with a lot of irrelevant details to get their jobs done. They should be given a language which excuses being "a little weak on the process"
James Curran
+2  A: 

I've taught rank beginners to program in c using K&R. But as a tutor, rather than in a classroom setting.

I love K&R, but it is very tightly written: you often have to read (and think about) each and every word to get the point. That's OK for experienced programmers (who were the audience for the book as far as I can tell), but in the wider population there are many people who won't sit still for that.

In a tutoring setting you can overcome that. You know where the critical details are hiding and can take the time to make sure the student "gets it" before moving on. That's harder to do in a lecture.

I'd suggest another book.

dmckee
+4  A: 
Gilles
dmckee
+4  A: 

I've TA'd before.

Generally the less magic you give the students, the better. "It just works" is not an acceptable answer for engineering students. It's comforting, but there's no lasting value in it.

Most of them won't know what a shell or a compiler is, however. C is good in that it doesn't have much magic. I've not found a good intro to programming book yet, K&R can't be worse than the usual drek.

If given the choice, I would teach either Assembly or Scheme as a programming language to comp sci majors(software engineers, computer engineers, etc) in an intro course. For a more general audience, I would teach R.

Paul Nathan
A: 

I have experience as a beginner in programming, studying independently (while working full time as a public school teacher). Last year I bought the book "Principles and Practice Using C++". With my PowerBook, it wasn't too difficult at the beginning, but then after a couple of chapters it started getting really hard, and I just dropped it. I have come to realize that book isn't easy to follow as a beginner (working independently).

Then in the fall I bought a netbook and began using Linux for the first time. Early this spring I started going through "The C Programming Language" within a Linux environment. A lot of things (emacs, gcc, gdb ... even how to execute a file, how to change permissions to make it executable, how to navigate simple bash commands), I had to work through trial and error, it was very slow.

I think that if you as an instructor can make those things easy to work through and fill the gaps that Kernighan & Ritchie assume the students have, then it should work. Once yoiu get past that other stuff, as a beginning student it's really nice to have something explained in a very clear and understandable manner. For me, it combines a well-written text with exercises. Definitely though, some of the students will require more support with the problems. Sometimes I spent a week just working on one problem and it was very frustrating.

Alex
+2  A: 

I, too believe that C should be taught as an Intro course to programming, because it's something in the middle, it doesn't have that much 'magic' in it which is associated with newer high level languages plus it has the low level stuff. Syntax wise too, it will prepare them with Java or C# in the future. But I'll suggest that before teaching them programming, train their logic first during the first 1/4 of the semester by teaching them some problem solving and basic algorithm. Even if they master the syntax, if they don't have good problem solving skills, then they'll have a hard time whatever language they use.

arscariosus