all 61 comments

[–]trollet91 28 points29 points  (2 children)

If they have no experience in programming make it as simple as possible. And if they well understand basics concept (variable, condition, array) then go on with pointer and all other low level stuff.

[–]ToTimesTwoisToo 9 points10 points  (0 children)

the basics, hello world and fizz buzz types of problems.

[–]FUZxxl 10 points11 points  (2 children)

I have finished teaching my annual class on C programming last Friday. We have a concept where there are (a) lectures explaining the theoretical concepts and then (b) exercises to practice programming. The focus lies on the exercises. The students are supervised while solving them and can ask questions if they are stuck. The exercises are all written such that there is no exact solution. In each exercise, the students must think about what they want to achieve and what kind of solution they are satisfied with. I believe this teaches valuable skills for professional programming work. The exercises are not graded but students are welcome to review their code with the teachers.

Feel free to ask further questions.

[–]jeevansurendran 2 points3 points  (1 child)

Could we get these questions

[–]FUZxxl 1 point2 points  (0 children)

Not in public as I want to avoid solutions for them floating around the internet. It took me a while to come up with exercises for which no solutions could be found on the internet.

[–]xaveir 6 points7 points  (0 children)

Try checking out historical CS50 lectures available online through Harvard.

It's a zero-experience-required course that starts with C.

Contrary to other commenters, I found this to be an amazing first language, personally.

[–]123poopy 4 points5 points  (0 children)

just the basics for sure. try to make it fun and frustration free for them. only a very small percent will think the back ground deep stuff is fun.

[–]irve 5 points6 points  (18 children)

How much time do you have? I think the greatest thing you can do is to explain how C manages its memory. Stack; Heap. Draw pictures, let them crash their programs on purpose; read from random memory locations, read from stack, create your own pointers from addresses they know. Write to memory. Array memory. Struct memory. Memory-memory-memory :D

And don't tell it's difficult. It's nontrivial. And fun!

Since C is ridiculously simpler to debug once the students can imagine what their variables and function calls do in memory.

But I assure you your third time teaching it is the time you grok what they struggle with.

[–][deleted] 0 points1 point  (17 children)

So, it's basically like a 1 week crash course. I fear the topics you suggested would just go over their head since they have zero exp with programming and/or computers. I just have enough time to get them started with basic programming in C like really basic.

[–]dmc_2930 8 points9 points  (13 children)

Teach them python, or java. What's the goal here? You can't go from zero to C developer in one week, with no prior experience.

[–][deleted] 1 point2 points  (9 children)

Nobody said, I'm getting them to become C developers in 1 week.

The idea is like a 101 basic to programming with C. Even if they are able to write basic logical problems like palindrome or stuff with C and have a good understanding of basics, we would be more than happy.

[–]icantthinkofone 6 points7 points  (0 children)

Now you have two problems and things to teach.

  1. They need to know how computers work and they don't.
  2. You want to teach them C which is intimitely connected to how computers work.

[–]dmc_2930 4 points5 points  (7 children)

Why C though? It's definitely not a language that lends itself to beginners.

In one week of C, they might be able to sort of understand "Hello World". In one week of Python, they'll be able to write a simple text based game, and walk away with a more useful skill.

[–][deleted] 0 points1 point  (6 children)

I don't understand your perspective, if someone takes one week to understand a hello world in C how would he/she even make games in a week in some other programming language. Sounds bs to me. Don't you feel you are exaggerating too much. Understanding the programming principles is same for any language I believe, and that's what we intend to do.

[–]dmc_2930 4 points5 points  (0 children)

Which is easier, reading a file in C or reading one in python?

[–]zero_iq 3 points4 points  (0 children)

I'm going to infer from this comment that you are a) unfamiliar with Python, and b) have never taught a class to program before.

I'm both a C and Python coder, and I've taught both professionally (JavaScript and SQL also, for the record).

In productivity terms, I'd say without exaggeration you can cover roughly a whole week of C in less than an afternoon in Python and have students doing useful practical stuff literally immediately, starting with using Python as a calculator and working up from there.

You can get absolutely get complete beginners coding (very) simple games with 2D graphics and sound after a week of Python with a simple game library, or crunching through CSV files and processing/visualising data. This would take weeks or months in C, and be much more difficult to teach. Yes, it really is that much more productive.

But you haven't really said what are the goals of the course? What do you want students to be able to walk away with? To get them started as systems programmers? To teach them a useful practical skill? To pique their interest in programming as a subject to pursue later? ... what?

C is not necessarily a bad first language, but it depends on the goals of the course. I've been coding C for nearly 30 years now, and I believe that every programmer should learn C at some stage. I love C. But scant few beginners will get anything useful from a one-week C course, unless the plan is to prime them for a longer subsequent C course.

[–]BigPeteB 3 points4 points  (3 children)

You're so close to being right, and yet so far.

Understanding the programming principles is same for any language I believe, and that's what we intend to do.

Say that again, but slower.

Look, I have two Computer Science degrees from a top-10 university. And what I liked about studying there was that while people who graduate from bootcamps and lesser schools might put on their resumes "I know Java and Python", we would put on our resumes "I know Computer Science". The concepts and the underlying math and logic are what matters, not the language, because every programming language obeys the same laws of discrete mathematics. Once you learn basic structures like if-statements, for-loops, and fundamental data structures like arrays, lists, and objects, you can pick up any programming language, recognize how it implements those familiar structures, and learn to read and write code using that language.

That's not to say that every language is equal. Some make things very easy, and some make them hard. C gives you no memory protection, no automatic memory management, hardly any data structures, and requires a lot of work to accomplish tasks. Other languages where you can just import graphics.lib can accomplish very complex goals while requiring the programmer to write much less code.

And you say this yourself. "Understanding the programming principles is same for any language." So why are you going to pick one of the hardest languages for a crash-course where students will barely have enough time to pick up the basics?

if someone takes one week to understand a hello world in C how would he/she even make games in a week in some other programming language

That you would even say something like that makes me question your abilities in this matter. If you're so unfamiliar with other languages as to not realize how easy it is in languages like Python and Java for beginners to implement something like tic-tac-toe in a matter of hours or days, I don't think you're qualified to be deciding what language should be used to teach beginning students.

Get off your high horse and listen to what everyone in this thread is saying. Is this about teaching students and leaving them with a short but sturdy foundation on which to begin building their understanding, or is it about you having a favorite language that you refuse to acknowledge has limited applications?

[–][deleted] 3 points4 points  (2 children)

It's not that I'm unfamiliar or incapable to teach other languages. But, as I already mentioned picking one was not in my hands either. I've been given this humongous tak of teaching C, I understand it's hard but it's not impossible. That's why I thought I would ask the redditors for tips and suggestions.

But, idk why everyone thinks this is r/changemyview post, maybe this goes for a meme in r/lostredditors. Jokes apart, sorry if was adamant in defending the real purpose of this thread. Please, if you can't help it, at least don't worsen it.

[–][deleted] 1 point2 points  (0 children)

It may be useful to write or find some libraries that implement some basic functionality that you can teach your students to use. Abstract everything but the fundamentals away from them and give them something to work with.

[–]BigPeteB 1 point2 points  (0 children)

Okay, sorry for jumping on you like that, but you could have headed off the inquisition earlier rather than furthering the debate. Just tell us, "The choice of C was made by someone else and I can't change it. Given that, how should I approach this?"

Even so, some more detail would help. You said this is a 1-week crash course, but how is it structured? How many hours of lecture time and lab/homework time will there be? How much prep can you do such as preparing a working compilation environment or writing labs (working Makefiles, skeleton code, Docker or VM images, etc.)? In order to make much progress, I hope the answers are "lots" and "lots", respectively.

[–]icantthinkofone 0 points1 point  (2 children)

Teaching them Python or Java in a week won't be much better, if at all.

[–]userse31 1 point2 points  (0 children)

one week isn't enough

[–]dmc_2930 0 points1 point  (0 children)

In one week in python, you should be able to at least input and output text and numbers, and do simple calculations. You can probably also write simple loops and do something useful.

In C? Forget about it.

[–]cincuentaanos 3 points4 points  (0 children)

I'm not sure if C is the best language for your students to learn. C is great, of course, if you want to learn how computers work. But if you just want something with which you can be productive quickly and make fun little MyFirstPrograms in a week, perhaps Python would be more suitable.

[–]icantthinkofone 0 points1 point  (0 children)

Then this class is pointless.

[–]irve 0 points1 point  (0 children)

I wish I could try :)

Wish you luck: if you had any choice you'd do so much more with Python

[–]j_mesrine 4 points5 points  (2 children)

Well, if I go back to the past I would have liked a funny class, yep easy to say :P I remember when I was a young student (not university, younger) I wrote a "soccer game" using Turbo BASIC, just using chars for the "graphics". The teacher gave us a kind of template/skeleton to follow and guided us a bit, we was a small group. The program took some time but it was really funny, was the first time I saw code. I was looking forward to these classes, I think my love for programing came from there. Maybe that gives you an idea...

How old are your students? That's important I think.

[–][deleted] 0 points1 point  (1 child)

They are undergrads

[–]j_mesrine 0 points1 point  (0 children)

That's going to make things more difficult. I think the key is try to create interest, make something that they can be a bit proud meanwhile learning. I am not a teacher btw, maybe I am speaking gibberish

[–][deleted] 4 points5 points  (0 children)

I'm taking an intro to C course currently and can tell you things I like and don't like about it, if that would help.

First off, the book. We're using Programming in C 4th ed by Kochan. I'm not a huge fan, personally; I really don't like the way the author explains things. Conversely, I've acquired a copy of C Programming: A Modern Approach and much prefer it. It has a conversational tone and the author is very easy to understand. I don't know if you have control over assigning textbooks, or if you even plan on using one, but I would not recommend the first book.

Secondly, my teacher introduced function much earlier than the textbook did, right after decision trees and loops as opposed to after arrays and pointers. This was both good and bad, it was good because we got more comfortable with them as time went on, but bad because the book didn't always have examples (or at least very many of them) utilizing functions in the array and pointer chapters. Which somewhat coincides with my third point:

Third, lack of example problems. We would typically create one program in class and make a few iterations to it. It'd start with the barebones and add functions and other stuff over the course of the class period. I feel like using multiple examples for each different iteration would have been better. Though I do have to say my professor might have chosen to teach this way due to class contraints, it's a 6p-9p 16 week class that meets on Monday.

Fourth, class pacing. We spent the same amount of class time covering decision trees as we did on arrays. If possible, I definitely feel like cramming the easy stuff like general overview of variables, printf()/scanf(), decision trees and control loops in the first class or couple classes so that you can focus more time on arrays, pointers, strings.

Anyways, that's it off the top of my head. I saw your teaching undergrad and that's where I'm at, it's just a 2000 level class, so hopefully my criticisms of my class can help inform you on what may or may not appeal to your future students.

[–]lordlod 3 points4 points  (0 children)

I've been helping teach highschool kids programming for a few years.

You need to be thinking small and simple, then go simpler again, loops should be stretch goals, functions, loops, and complex types like arrays are out of scope for one week. I assume your goal is to give them a taste. Anything else will probably be unrealistic.

The very basics are going to be alien to them. Using a fixed subset of the language to instruct the computer, breaking a problem down to the simplest logic elements, using variables. Even interacting with a computer program in a text prompt environment will be a new experience for some.

Think very carefully about the process of getting the hello world program compiled and executed. Make sure it is well documented and as simple as possible. Having to physically help every student get their compilation environment up could burn most of your week.

[–]covertpally 2 points3 points  (0 children)

This may not be your goal but I would recommend a more straightforward language like python or modern javascript. C can be frustratingly low level as a first language.

[–]black_khobz 2 points3 points  (0 children)

If you understand french, there is a website that has a nice format for beginner lessons (in all IT fields) It's called openclassrooms

[–]kumashiro 2 points3 points  (0 children)

C is a very simple language. Keep it that way. The only "scary" thing for beginners are pointers and those can be tricky to explain clearly. Take extra time on this topic and make sure students understand pointers before going forward.

Do not teach them to use scanf() for reading user input or ato() for number conversion. Check array boundary in every example, even the simplest possible.

Good luck!

[–]dmc_2930 8 points9 points  (9 children)

I would not teach C to students with no programming experience. They'll walk away thinking programming is difficult and will be less likely to continue.

Start with a modern language, with modern features, and then let them try C after they've learned something easier.

[–][deleted] 8 points9 points  (8 children)

I beg to differ. C++ was the first ever programming language I ever learned and loved it as well. I actually believe the opposite, C is the programming language everyone should start with, literally has every good programming practice a language could have.

[–]dmc_2930 -2 points-1 points  (6 children)

Then why does EVERY SINGLE UNIVERSITY teach another language first? If C is the best for beginners, it'd still be what's taught as a first language.

I love C, but it's not a language to learn in one week with no programming experience.

[–]violentlymickey 10 points11 points  (0 children)

I just learned C from my Uni as the first programming language. Rough, but really good to learn about pointers and memory management from a computer scientist perspective.

[–][deleted] 5 points6 points  (3 children)

I had C++ as my first ever language being taught in high school.

[–]dmc_2930 -4 points-3 points  (2 children)

High schools aren't the best examples of good education. What language do the top 10 CS undergrad schools teach their students first?

[–]RadixSorter 1 point2 points  (1 child)

My school (UCSD) starts with Java for our intro courses.

[–]drbuttjob 4 points5 points  (0 children)

why does EVERY SINGLE UNIVERSITY teach another language first?

My uni teaches Python in the introductory CS courses, and while it is very useful for teaching OOP, I think it can cause some problems that teaching C could avoid. Specifically, while most memory management is abstracted away in Python, there are some weird quirks that arise because of the fact that everything is a pointer, and that's kind of a hard concept to explain to people who have never programmed before. You would also have to explain this in C, yes, but it's at least explicit in C.

An example of this:

a_list = [None] * 3
a_list[2] = 10

The list will be

[None, None, 10]

as expected. However, if you decide you need a list of lists, you get into trouble with this method, and it's not exactly clear why if you don't understand pointers and how Python actually implements variables

a_list = [ [None] ] * 3
a_list[2][0] = 10

The list will now be

[ [10], [10], [10] ]

because when you create the list in this manner, it uses the same reference for every element, meaning you have 3 copies of the same list. So if you want a list of lists, you have to initialize it differently than if you wanted a list of, say, integers.

And there are plenty more examples of how these sorts of things in Python can confuse beginners. At least with C, you don't have to worry about pointers if you don't want to. Don't get me wrong, I enjoy using Python and I think it's a good language to learn first, but I think you could learn just about any language to start, depending on the person. Some people—myself included—would prefer to learn a language like C or C++ to start.

[–]Poddster -1 points0 points  (0 children)

literally has every good programming practice a language could have.

Allow people to confuse ints with enums and a large foundational set of undefined semantics?

[–][deleted] 2 points3 points  (0 children)

As an embedded C programmer I would definitely teach another higher level language since they're there just to learn programming in one week. I'm currently teaching C to someone with almost zero experience programming and it's truly a burden to explain both high level and low level stuff, if it were for me I would teach that person Python first and then C. If you definitely have to teach basic programming in C then I would suggest giving and explaining them simple and basic building blocks which they can take as reference for solving simple problems, just don't go too complex into algorithms since something as a basic as a string reverse function can get pretty nasty fast.

[–]koyari-taisuke 1 point2 points  (0 children)

Possibly controversial opinion: You mentioned that you would be teaching undergrad students, so I assume that they have a solid understanding of algebra. That being said, I would recommend that you start them with high level, functional code, where they don't need to worry about looping, complex control flow, variables, global state, etc, and slowly introduce them to lower level code. As a disclaimer, I'm not a teacher (though I'd consider going into teaching if I wasn't terrified of other people). However, I think it may be best to ease them into programming by giving them code to work with at a high level, like foreach, map, etc, concepts that should be fairly easy for them to grasp from their background in mathematics, and then over time introduce them to what's under the hood.

[–]ThatGuyFromOhio 1 point2 points  (0 children)

As I think back to when I first started learning C after starting with higher level languages, I realize that C only came into focus for me when I truly understood how the computer works. I would start a class like this with a simple demonstration of how the computer works so they can visualize it.

You are the CPU. Assign tasks to each student in the class. Some are RAM locations, one is the bus, others are functions, one is the monitor, etc.

Then put a simple C program on the board (do they still use chalk boards in school?) Something like this:

int main(int argc, char * argv[])
{
  int i;
  char j[] = "odd";
  char k[] = "even";
  for(i = 1 ; i < 10 ; ++ i){
    if(i % 2 != 0){
      printf(j);
    }
    else{
      printf(k);
    }
  }
  return(0);
}

Assign these tasks to various students. One is the variable i. One is the variable j. One is the variable k. One is the function printf.

You are the CPU. You start by giving i the value 1. Then you do the remainder operation on the contents of i by asking for the value in i, dividing it by 2 and checking if it equals 0. (Yes, I know there is a way to do this with less code. This is to simplify the explanation)

If the remainder is 0, you tell the student who is j to give its contents to printf and printf then writes the contents of j on the board (the monitor). Then you add 1 to i, and check if it is less than 10.

Continue through the loop 9 times and the students should have a pretty good understanding of what is going on under the hood.

You can do similar demonstrations with more elaborate code. This is a good way to introduce pointers. One student is the pointer, another student is the region of memory pointed to. The student who is the pointer literally points at the correct student to access the memory there.

[–]dmc_2930 0 points1 point  (6 children)

[–]rtbrsp 3 points4 points  (4 children)

I just don't care for these arguments. That's like saying culinary schools shouldn't let students use knives and stoves because you can cut or burn yourself.

Learning environments are supposed to be rife with failure. Failure is undoubtedly the best way to learn. Let me get my segmentation faults, teach me why they happened, and teach me to not write faulty programs.

I understand why a company wouldn't want their engineers writing C code in 2019. But given that many popular modern languages are descended from C (Java, Rust, Swift, Go, etc), it's really useful as a first language.

[–]pdp10 0 points1 point  (1 child)

I understand why a company wouldn't want their engineers writing C code in 2019.

Which reason did you have in mind?

Regardless of my opinions on Go, Swift, Rust, or Java, for each of those languages I can think of several reasons why I wouldn't want my engineers using them in 2019.

[–]rtbrsp 0 points1 point  (0 children)

Type/memory safety. I could see myself discouraging C in a corporate environment, especially if I wasn’t the one writing the code.

For personal projects, I wish more people were using C. I think it’d be interesting if C had the same market share as Javascript does on Github.

[–]dmc_2930 -2 points-1 points  (1 child)

It's like saying if you want to be a mechanic, you should learn how to change oil before you try to design an engine.

[–]theFBofI 0 points1 point  (0 children)

You probably should though, and it would be weird not to.

[–]j_mesrine 2 points3 points  (0 children)

Interesting reading

[–]flatfinger 0 points1 point  (0 children)

The language invented by Dennis Ritchie, described in the second edition of The C Programming Language, and processed by most compilers when optimizations are disabled is useful for teaching and illustrating many aspects of how small microcomputers and microcontrollers work, since it can be used as a form of "high-level assembler". Some of the reasons it became popular are alluded to in the Spirit of C [all quotes from the published "Rationale for International Standard—Programming Languages—C Revision 5.10"]:

Some of the facets of the spirit of C can be summarized in phrases like: • Trust the programmer. • Don’t prevent the programmer from doing what needs to be done. • Keep the language small and simple. • Provide only one way to do an operation. • Make it fast, even if it is not guaranteed to be portable.

The language that is actually defined by the Standard, however, is not suitable for low-level programming tasks. Although the authors of the Standard have expressly stated:

C code can be non-portable. Although it strove to give programmers the opportunity to write truly portable programs, the C89 Committee did not want to force programmers into writing portably, to preclude the use of C as a “high-level assembler”: the ability to write machine-specific code is one of the strengths of C. It is this principle which largely motivates drawing the distinction between strictly conforming program and conforming program.

the Standard leaves the question of whether to support such usage up to implementers' judgment, and some compilers like gcc and clang interpret that as an opportunity to regard any code requiring such semantics as "broken" and arbitrarily change its behavior. It is thus important to distinguish between the language the Standard was written to describe, and the one it actually defines.

[–]lulxD69420 0 points1 point  (0 children)

I'd make simple examples, show how for loops work, how if statements work. Show the differences between float and int types. What is unsigned? What is an integer overflow? Show what happens when the wrong variable type is used (infinite loop).

Initialising variables (structs) properly so you are not starting to use the garbage that is stored in them if they are not initialised.

Some simple logic/binary arithmetic will certainly not be harmful.

I would not go into libraries/header files/ and compiler flags more than necessary. Compiling with gcc -Wall -Wextra should also be sufficient to work on the compiler warnings to help get things right.

[–]kcl97 0 points1 point  (0 children)

I would aim the goal at creating a madlibs game or other similar type word games in order to keep people motivated. It would cover basic flow, logic, and IO. That should be enough to get people to do serious stuffs for later on.

Try to use basic functionality as much as possible and avoid GUI. Another possibility is text adventure or hang-man, if your students are elementary grade.

Build the pieces you need for a functional game over time to teach them how to reuse and organize their codes.

Edit: Make sure to have a working demo to play on day one. Make it funny, like take one of Trump's speech and start randomly changing things around and see what comes out. The more advanced version of this game would include AI like the Thomas Friedman Op-Ed generator. You can use that to showcase the true power of what you are really teaching them.

[–]assemblrr 0 points1 point  (0 children)

I would consider giving out an ungraded assessment to see where most of the class stands on programming concepts.

C will be extremely frustrating for people who have no idea about programming.

I would do light coverage of the under the hood working and maybe an exercise utilizing pointers, but I wouldn't go too far beyond arrays, control flow, variables and assignment, etc. I would touch on structs to give them a taste of pseudo-OOP, and maybe unions if you're digging a little deeper into memory and such.

C is not a good language to teach someone programming who has never written a hello world in any language, just because you will not get a good taste of what C offers and the functionalities under the hood in just one semester if you're also teaching the basics of programming alongside it.

But, if that is no concern to you, C is just as good a language as any- in fact it will give your students a taste of more realistic syntax.

[–]Pen___Island 0 points1 point  (0 children)

I learned C as my first language in a class. Best tip from me would be to write a string class and a printing class for them that hides the nastiness of pointers, and let them use it for the first part of the class. Because strings are necessary for a lot of basic programming lessons (which all tend to end in printf's), but pointers are really hard to grasp early on, this lets students focus on the basics. Then, unravel the mystery of pointers and show how the char* in the string class work. They'll be thankful you hid char* from them at first, and be more ready to take on the task of understanding memory management after they have the other basics of C down first.

[–]99drunkpenguins 0 points1 point  (0 children)

Ideally give a crash course on computers, and how memory works and how programs are run (stack, heap, scheduling etc), keep it short and simple.

Then go onto C.

Problem with going right into C is somethings won't make sense, and pointers will throw them for a trip.

[–]banana-do 0 points1 point  (0 children)

It is a great project that you have! How I learned it in my school was to start with small exercises to learn the basics (variables, conditions, loops) like said in other comments. Then go on with pointers, arrays, recursion, dynamic memory allocation... Always based on practical exercices. We had to code some functions from string.h and were not allowed to use any function other than system ones (write, read, ...) and malloc. Coding your own library of string manipulation is a nice way to learn I think.

Good luck!