January 25, 2019
For today:
1) Read Head First C, Chapter 1 (you can read the first three chapters here).
2) Accept the invitation to Canvas and check your profile (check that the name fields contain your names, not email, and that your time zone is correct).
Today:
1) Class overview.
2) Compiling and running C.
For next time:
1) Order Head First C or another book.
2) Read Think OS, Chapter 1 (make sure you get PDF version 0.8.0) and do the reading quiz
3) Get your Linux partition squared away (see below).
4) Start Homework 01
Also, check out this advice from our friends on Twitter.
Topics include:
1) System-level programming in C, using Head First C (or another book).
2) Topics in operating system design and implementation, using Think OS.
3) Software synchronization, using The Little Book of Semaphores.
At one time, C was a general purpose programming language, often taught as a first language.
Now more often people start with Java, Python, etc, and come to C later.
And C has become more like a niche language. Some of the places it's used:
1) Implementation of operating systems and run time systems.
2) Network programming, clients and servers.
3) High performance / scientific computing
4) Graphics programming / GPU programming
5) Embedded systems
6) Digital signal processing
7) Hardware synthesis
This course has a core that we want everyone to learn, which we'll develop with the homeworks, in-class exercises, and quizzes.
And a number of directions you can take it, primarily through the projects.
Projects
Two projects, about 5 weeks each.
The goal of the projects is to allow you to choose a topic to learn more about, find resources to help you learn, and develop a software product that develops and demonstrates your learning.
Here are some projects from last time
Mostly teams of 2-3. Later I will provide suggestions for choosing projects and finding resources, but it's never too early to start.
This class is also a good place to learn the UNIX command-line interface. You will probably want to install Linux on your laptop, but you could also
1) Use the Mac OS command line interface.
2) Use the Windows Subsystem for Linux
If you decide to install Linux, consider attending the Linux installation party this weekend (announcement soon).
Start with these instructions provided by IT. They are out of date, so if you run into problems, let me know and we can (1) fix the problem, and (2) update the instructions.
When you install Linux, it is a good idea to plug into the wired network. It will go faster.
On the same page, follow the instructions to configure apt, install the NVIDIA driver, configure wireless and set up printing.
You can use any editor you like to write C code. I think Atom is a good choice. Some people like Sublime Text. I suggest you don't start with an IDE like Eclipse.
If you have not used Git before, read my rough draft of a Git book and follow the instructions.
Then get your personal repository set up:
0) Log in to GitHub
1) Go to https://github.com/AllenDowney/ExercisesInC and press the Fork button in the upper right. Now you have a repo on GitHub named YourName/ExercisesInC.
2) On your laptop run
git clone https://github.com/YourName/ExercisesInC
Now you should have a local copy of your repo in a directory called ExercisesInC.
3) cd into the local copy you just created and run
git remote add upstream https://github.com/AllenDowney/ExercisesInC
That adds my repo as an "upstream" repo.
Once this is set up, you will be able to run
git pull upstream master
any time to pull any changes I have made in my repo into your local copy.
You will use this repository to turn in your solutions to the exercises.
Here's what the basic workflow looks like:
The Head First series uses principles from cognitive science to make material memorable, at the cost of conciseness.
In past semesters, some students liked HFC, some didn't.
You'll be able to read the first three chapters electronically, and then decide if it's good for you.
Depending on your background, you might prefer:
Oualline, Practical C Programming
Klemens, 21st Century C
Gustedt, Modern C (free PDF)
You might find this discussion helpful.
If you choose a different book, it's up to you to stay ahead of the HFC Schedule.
Most class sessions, I will review the content of the reading, so you'll know what you should know.
Regardless of which book you use, you might find The GNU C Programming Tutorial helpful.
Parts of a program: comments, statements, functions.
The main() function.
How to compile and run.
Character arrays.
if-else statements, boolean values and logical operators
switch-break statement
loops: while, do-while, for (and break)
Writing functions.
In-class exercise
1) Load this interactive C tutorial at learn-c.org
2) Work through the exercises in "Learn the Basics"
Save "Multidimensional arrays" and "Static" for last.
Make as many mistakes as possible so you start to see what the error messages look like.
1) Without brackets, if and else attach to the next statement only, regardless of indentation.
2) In a switch statement, you need a break statement to avoid fall through.
3) Because C uses break to control flow within a switch statement, you can't break out of a loop from within a switch statement. But you can continue. Ugh.
4) Single equals in a conditional? Anyone?
Anything else from Chapter 1 make you wince?
C programming advice:
1) Expect to be MUCH slower in C than in Python. Breathe.
2) You will make syntax errors at first, and the compiler is not very nice. Ignore all but the first error message. Consider using clang.
3) Write a very small amount of code per edit-compile-debug cycle.
4) IDE? Here's what xkcd has to say on the topic. More seriously, we are taking a bottom-up approach, so I suggest starting with simple tools, doing things "by hand" the first few times.