Skip to main content
Welcome guest. | Register | Login | Post

Free C Programming Lessons

13 replies [Last post]
Offline
Joined: 2007-12-17

In a few weeks, Crispy, a member of Cluenet (a community dedicated to providing free high-quality services), will be giving free lessons, from scratch, in learning how to program in C. These lessons will be given over icecast (for audio) as well as a shared VNC session (for video). At this point, we are not yet sure if these lessons will contain anything linux-specific. If you are interested in this and would like to learn more about these lessons, or you would like to sign up, please visit #clueirc on irc.cluenet.org. You may also contact me directly for more information, if you prefer. The sign-up page is located at http://wiki.cluenet.org/index.php/ClueSchool_C_Signup_List (make a wiki account before putting youself on this list), but it is definitely a good idea to drop by our IRC network first, so you can ask any questions you may have, and so you can get to know us a little. Our general website is located at http://www.cluenet.org

tbuitenh's picture
Offline
Joined: 2005-12-21
IMHO anyone who wants to

IMHO anyone who wants to understand how computers work should at least learn C . It's a low level enough language to give a good idea of how things really work, yet just high level enough to be understandable.

Also, it's a much better first language than for example C++ or Java (the most commonly taught languages in schools and universities nowadays) because it contains absolutely no confusing nonsense.

Thumbs up!

libervisco's picture
Offline
Joined: 2006-05-04
I think this is an

I think this is an excellent project and I'm definitely curious. I never get around to materializing an occasionally popping up desire to learn some programming and this might be a way to spark something up (who knows). But we'll see if I'll have time. :s

+1

Offline
Joined: 2007-09-10
One suggestion for a

One suggestion for a lesson/activity is to take advantage of an interesting C project and analyze/rewrite a portion of it. This way there is something interesting to show. Otherwise, all the examples will be simple.

I like simple and complex. With simple you know there are no tricks, and you can visualize almost everything going on. With complex you get to peek at where C can take you and the impact that a small number of lines can have.

Another thing to consider would be to have a pre-lesson to make sure that the students have all the requirements (the build environment and any libraries that may be needed).

Although this may be advanced and it will probably involve C++, tackling a game allows the results to be seen visually. There are 4 games being played in the gamefest that may make good candidates. Even just using any library that does some sort of drawing would be interesting for those that like to see code that draws.

Another interesting advanced project would be the Linux kernel. Even without building it, I found it interesting to know how some item or other worked. This gives some insight into the PC. One example would be how scheduling is handled. Another would be to peek inside some device driver. Yet another would be to follow a part of the booting process (before init takes over). Basically, I think the student would gain twice, once in understanding C and the other in understanding Linux. The latter providing motivation for the former.

It may also be useful to experiment using libraries (eg, XML and/or zip libs) to get information or change information in things like ODF files or maybe even PDF files. This helps show the value in open standards and how you don't actually need an official office suite to gain access to your files.

But there are many interesting and more manageable projects.

By the way, python is used to script various apps (I think blender for one). Python is supposed to be easy. Learning some of it hands-on would give the student a way to achieve something beyond what an IDE might normally allow (eg, to animate something in a strange way).

I can probably help out in coming up with examples if enough are interested in the idea.

PS: A lot of these experiments I also mention because I have not had the time to experiment much with them and am curious.

PS2: A lot of languages have syntax like C (C++, Java, Javascript, even PHP I think). I mention this so that the students at least pay attention to the basics even if they forget the details.

tbuitenh's picture
Offline
Joined: 2005-12-21
I'll have some of that too
Jose wrote:

Another thing to consider would be to have a pre-lesson to make sure that the students have all the requirements (the build environment and any libraries that may be needed).

Preventing nasty surprises ("I can't install library FOO") halfway the course is a good idea.

Quote:

Although this may be advanced and it will probably involve C++, tackling a game allows the results to be seen visually. There are 4 games being played in the gamefest that may make good candidates. Even just using any library that does some sort of drawing would be interesting for those that like to see code that draws.

3D games as examples in newbie C programming lessons? What have you been smoking? I've seen some 3D programming tutorials, these things go on for pages and pages, and then at the end of the lesson the result is that you can draw ... a cube!

Quote:

Another interesting advanced project would be the Linux kernel. Even without building it, I found it interesting to know how some item or other worked. This gives some insight into the PC. One example would be how scheduling is handled. Another would be to peek inside some device driver. Yet another would be to follow a part of the booting process (before init takes over). Basically, I think the student would gain twice, once in understanding C and the other in understanding Linux. The latter providing motivation for the former.

I think the kernel is better for students who already have at least the knowledge gained in the lessons offered here (if I understood the purpose of these lessons). That said, the kernel actually isn't a very good program for beginners to work on, since it is difficult to debug.

Quote:

It may also be useful to experiment using libraries (eg, XML and/or zip libs) to get information or change information in things like ODF files or maybe even PDF files. This helps show the value in open standards and how you don't actually need an official office suite to gain access to your files.

I think those subjects would fit scripting lessons better. C is not the right tool to take apart complex files for educational purposes, unless your intention is to bore and confuse your students. Maybe Python would be a nice choice.

Quote:

Python is supposed to be easy.

Python isn't much easier than most other programming languages, and some sides of it (such as how the namespaces work) are actually very confusing (or so I'm told by people who feel confused Sticking out tongue ). What makes Python "easy" is that you're less likely to make typos (like misplaced {}'s in C). Also Python code tends to be rather short, keeping projects manageable.

BTW, have you ever looked into how to link C and Python code together? That's not something you would put in C programming lessons for beginners.

Quote:

PS2: A lot of languages have syntax like C (C++, Java, Javascript, even PHP I think). I mention this so that the students at least pay attention to the basics even if they forget the details.

Yes, and perl, ruby, lua (to some extent), PAWN and lots of others I don't remember immediately have C-like syntax too. The thing is, the semantics are all different, you won't be able to reuse much more knowledge than the meaning of the symbols {, }, [, ], if, else and for.

Offline
Joined: 2007-09-10
First, let me say that I

First, let me say that I know these are not beginner topics. One, I didn't say it had to be for lesson 1 or 2 or 3. Two, no matter how advanced an application is, it always has parts that are important and that are not that difficult to understand. My suggestion was to use a large project so that small changes in key places could produce interesting results. I was not suggesting that the entire app be explained to the students.

The kernel is tough to debug, but that is why I specifically mentioned that studying some part of the kernel could be interesting (studying not rewriting). It would be an interesting application of learned concepts. It doesn't take that many advanced things to understand a portion of the kernel. In this way, the student would get bang for buck (beyond knowing how to print "hello world"). Knowing about the kernel would also give insight into a running system. And all of this would further motivate a student to go a little further (or pay better attention to key parts of C).

If people do look at the kernel (or other large projects), they should understand that there are cases of taking advantage of gcc features. Also, there is a lot of use of macros. This means that studying the kernel is a bit like learning a new language where a lot of vocabulary has to be learned to understand the thing.. the idea would be to give a taste without overwhelming.

>> C is not the right tool to take apart complex files for educational purposes, unless your intention is to bore and confuse your students. Maybe Python would be a nice choice.

I agree that in some cases an easier (less detail oriented) scripting langauge would be better. But if you are doing C anyway, the point of my post was to suggest some ways to put powerful libraries to use so that students get bang for buck. This way, they see that learning C means power beyond "hello world." [See later coment about students being new to C only vs. to programming in general.]

>> Yes, and perl, ruby, lua (to some extent), PAWN and lots of others I don't remember immediately have C-like syntax too. The thing is, the semantics are all different, you won't be able to reuse much more knowledge than the meaning of the symbols {, }, [, ], if, else and for.

I didn't mention perl because perl is not "that" similar. In fact, I think I stayed with languages that were quite similar in syntax (I haven't seen that much ruby, but I think it is close to java in syntax).

The point was to draw attention to the main items in some of these languages that are in common use. You can teach a part of a newbie class by looking at samples of code in the languages I picked such that the code would almost be identical and generally do almost the same things. You don't want to confuse a student by going into details and then not following through, but seeing some simple cases of code in these languages may alert the person to the fact that they are dealing with some common themes and common ways to build programs. I was assuming the students might be new to programming just as they are new to C. Naturally, if that is not the case and they have experience in other languages, then showing these patterns wouldn't be as useful (in this case, you would want to contrast *differences* not obvious similarities between C and the other languages they know; more importantly, you would want to highlight where one language excels as compared to the other).

tbuitenh's picture
Offline
Joined: 2005-12-21
long reply, short reply
Jose wrote:

First, let me say that I know these are not beginner topics. One, I didn't say it had to be for lesson 1 or 2 or 3.

Or 4, 5, 6 and 7, for that matter. Kernel and 3D programming belong in second level courses (or even higher maybe). Of course one can show examples from the kernel and from 3D stuff, but personally I wouldn't do that because it's encouraging students to try things that are only going to get them frustrated - they might give up because it seems they still have much more to learn than they actually do.

Quote:

Two, no matter how advanced an application is, it always has parts that are important and that are not that difficult to understand.

Usually, important and difficult to understand go together like conjoined twins.

Quote:

My suggestion was to use a large project so that small changes in key places could produce interesting results.

The "things that go boom" variety of interesting? Eye

Quote:

The kernel is tough to debug, but that is why I specifically mentioned that studying some part of the kernel could be interesting (studying not rewriting).

But once you understand how something works, you want to modify it, don't you? A ticket to frustration if you haven't had a lesson about kernel debugging first.

Quote:

I agree that in some cases an easier (less detail oriented) scripting langauge would be better. But if you are doing C anyway, the point of my post was to suggest some ways to put powerful libraries to use so that students get bang for buck.
This way, they see that learning C means power beyond "hello world." [See later coment about students being new to C only vs. to programming in general.]

To do more exciting stuff than "hello world", it's a good idea to look at GUI libraries. Not GTK though, that thing is awful. I've recently had a look at the documentation of the enlightenment libraries, looks like impressive things can be done with those with very little code. Making ones own primitive file manager or image viewer should be fun for beginners, I think?

Quote:

I didn't mention perl because perl is not "that" similar. In fact, I think I stayed with languages that were quite similar in syntax (I haven't seen that much ruby, but I think it is close to java in syntax).

The similarity between JavaScript and C (or even Java) is only skin deep. Java is a bit like C (not very much so), but it discards the features that make C attractive: pointers and manual memory management. And if you ever had to switch back and forth between C++ and Java, you'll know these have some syntax differences that are there for no good reason and will trip you again and again. Even the syntax for defining arrays is different.
So, really, the similarities don't go much further than the meaning of a few symbols.

I don't really see the point of showing such similarities, not even to beginners. A good programmer knows *what* he wants to do and where he can look up how to do that in whatever language he's using. A poor programmer only half understands what he's doing, but has memorized exactly how to write it (syntax) in one particular language.

It is most important to understand what data structures exist in memory and what is happening to them. The programming language syntax should matter as much as whether the comments are written in English or another language the programmer understands. This is why I think C is a good first language: it is reasonably easy to see through the syntax and see the data structures, and the average simple C program doesn't have very complicated data structures.

To be honest I think it's best to show some very different programming languages to students from the very beginning. It may seem confusing, but not being able to switch to a different syntax and associated different way of thinking - or indeed being stuck in one way of thinking even within one programming language - is one of the main problems I've seen students have.

Offline
Joined: 2007-09-10
Unless I am

Unless I am misunderstanding the first part of your comment, you seem very pessimistic.

Many courses provide examples that are part of a larger whole. Were you planning on not teaching "hello world" since the printf function relies on library and kernel calls that have many complex parts? Of course not. The concept of printf is simple. Similarly, the concept behind changes to a loop or section of code to get an AI opponent to behave differently or gravity to work differently or a bullet to speed up after deflection are simple. The actual code *may* not be too complex (we'd have to mine for suitable examples) and the effects would be more interesting and show the power of lines of code better than "hello world" perhaps.

Having said this, I am not suggesting that the course be put on hold until suitable examples be found. I am brainstorming. Perhaps a follow up course, a more advanced course, or even some other noob course would incorporate some of these elements.

>> But once you understand how something works, you want to modify it, don't you? A ticket to frustration if you haven't had a lesson about kernel debugging first.

Sure this is a possiblity. But for a fact, I have looked over different sections of kernel and learned interesting things and I have not till this day compiled my own kernel.

For example, I know some about PCI and it was interesting to look at how that bus and others were searched and pried open (kernel 2.0 I am talking about). I learned how the nice value (among other things) worked its way into scheduling (a 2.4 kernel). I have followed along with booting as well as looked into various device drivers. Certainly not all of this is advanced. I would say that it would be a treat or even material for a test to show the code for some portion of the kernel late in the course.

>> To do more exciting stuff than "hello world", it's a good idea to look at GUI libraries.

Now you are talking!

>> Making ones own primitive file manager or image viewer should be fun for beginners, I think?

I'd have to see the details first. Actually, you'd have to ask them (both to see if it would be fun and to see if it would be at a level they could follow).

Library abstractions can show off power, but they can be boring depending on how done. Ex of boring and useless: "startProgram(); doTheMiddleSectionWithFireworks(); finishProgram();" Smiling.

There is not much harm in seeking out various examples and seeing what sticks with the students. Not all pupils would be on the same level anyway since some may know many programming languages while others might have learned to use a computer last year.

>> The similarity between JavaScript and C (or even Java) is only skin deep.

The basics of what is going on with loops and the general flow of statements and use of variables and operators are very similar. With these basics, they can at least start to follow what is going on in code they may see in these languages. Anyway, originally this multi-language comparison suggestion was the "PS" of the comment.

The more interesting stuff are things like 3D games and you poo-poo'd these ideas. DOA without a second thought. How shameful.

>> To be honest I think it's best to show some very different programming languages to students from the very beginning. It may seem confusing, but not being able to switch to a different syntax and associated different way of thinking - or indeed being stuck in one way of thinking even within one programming language - is one of the main problems I've seen students have.

I agree. I think showing similar and different languages have their use.

tbuitenh's picture
Offline
Joined: 2005-12-21
I'm not pessimistic, but I

I'm not pessimistic, but I guess I am assuming a much lower level of experience than you are. I do know the reason of my assumption: "write a book teaching programming to anyone who can read and who has a little patience" is somewhere on my to do list. Actually I already started it once, but that damn combination of disk crash and unreadable backup dvds had to kill all my side projects (which is for the better I guess, cause now I'm more focussed on studying). So, without thinking about it, I assumed programming lessons should be accessible to anyone who can manage to install ubuntu (in other words, anyone who can read and has some patience Smiling ).

You do seem to have a preference for showing interesting examples where students can make only small changes using what they have learned. For example they could change the way a bullet bounces, but they couldn't create flowing lava. While I agree changing bullet behavior is interesting, what I really want to do when modifying a game is adding lava to it. Cause lava is cool. Well not really, but for the sake of the example I think lava is cool.

Offline
Joined: 2007-09-10
For example they could

>> ...For example they could change the way a bullet bounces, but they couldn't create flowing lava. While I agree changing bullet behavior is interesting, what I really want to do when modifying a game is adding lava to it. Cause lava is cool. Well not really, but for the sake of the example I think lava is cool.

Maybe we can manage most of the lava ourselves. Show them the code and have them tweak it to perfection Smiling

Plus, you are definitely talking about involving the creation of graphics and/or 3d models which are many more steps and not related to C.

Anyway, this test idea won't go anywhere beyond our arguing in this thread until someone comes up with a specific example.

tbuitenh's picture
Offline
Joined: 2005-12-21
Of course we could provide

Of course we could provide half-finished lava to students, but then they are still modifying a system in which their lack of knowledge prevents them from implementing any interesting idea they might come up with, because we are not telepathic and can't see the future either, so we can't possibly know what ideas they will have.

Offline
Joined: 2007-09-10
Honestly, I don't know how

Honestly, I don't know how things could work out with someone just learning the language. Instead of guessing, hopefully I'll find something interesting at some point (probably not in time to let people in this class know about it). The price for the effort is me having a better idea of what may not work and getting experience doing something I want to do anyway.

Smiling

Offline
Joined: 2006-01-10
Re: Free C Programming Lessons

I just went back and checked on this site. Apparently, the topic of C programming was brought up and I never checked it out before. I have been working on learning some C programming. What I found to be most helpful was to take the programs of other newbies, copy paste them, and then try to make the compile, run and do what they are supposed to do. There are a lot of posts titled things such as "Help, hello world won't compile" out there.
The other thing I was thinking of doing is writing a free-as in freedom C primer. My lack of qualifications probably makes this a better task for me rather than for a person who can't remember a time when they didn't know how to code. Something that just covers the basics of coding in C in linux (such as the infamous libm.a library), basic gcc use, as well as simplistic examples in programming. As neat as I think modifying code is, when the program is really complex, it hard to understand what everything does, so I think it is better to try to modify simple programs first rather than complex ones. I still haven't figured out what is in all the source files for the project I am working on.
If someone actually wants to read about the difficulties of learning to program in C, the blog is http://wogralddev.blogspot.org

libervisco's picture
Offline
Joined: 2006-05-04
Re: Free C Programming Lessons

Hey Jastiv, your link is broken. Here's the working one: http://wogralddev.blogspot.org/ (.com instead of .org).

Comment viewing options