Recommendation for a text

J

John Coleman

Greetings,

I teach math and computer science (though mostly math) at a small liberal arts college. Because of our smallness we don't have a huge course offering.To compensate, we have a grab-bag "special topics course" where we cover different topics each semester based on student's and/or professor's interests.

Next fall I will be running a special topics course with the title "Modern C Programming". The motivation for the course is that currently our CS students are exposed to C++, Java and a smattering of other languages (e.g. Lisp in an elective AI course) but no C per se. While in principle they learn some C naturally in the course of learning C++ they really don't learn all that much about things like pointers, malloc, and the safe handling of C-style strings and they definitely don't learn anything about C99. The proposed class is intended to give a serious introduction to C to students who have a working knowledge of either C++ or Java. This will allow me to blow through the basic syntax of expressions, loops, etc. in a couple of weeks and to spend the bulk of the semester on aspects of C which are different from Java and even C++.

My question is - what would a good text be? My first tentative choice was King's "C programming: a modern approach", but I have also been looking at Kochan's book "Programming in C". More recently I have been toying with the idea of using K&R. On the one hand that seems on the face of it like a poorchoice for a course called *Modern* C programming. On the other hand - it *is* a classic and seems to hit the right level of difficulty (a course forstudents who already know at least one programming language). My main question is - does the merits of K&R outweigh the disadvantages of the lack of coverage of C99? I could of course supplement K&R by e.g. O'Reilly's "C Pocket Reference" which covers the C99 material. Where I'm at right now is that my heart says to go with K&R but my head says go with King (or Kochan). The bookstore wants a decision on my part sooner rather than later.

Also - I am open to ideas about projects for the students to work on. One idea that I had was to concentrate on the Mandelbrot Set. Towards the beginning of the semester they could have a program which just prints to the command line e.g. with '*' for points in the set. Later on they could write it to a portable bit map text file. Even later they could write it to a .bmp file in which they have to get the header and the byte-alignment correct. Finally, I could have them rewrite it in C99 with e.g. the complex-number type and variable-length arrays so they don't have to hard-wire in the size of the bitmap. This topic of course reflects my interest as a mathematician.I have less ideas when it comes to straight computer-science applications (although Jacob Navia's idea about a hex-dump utility for pedagogical purposes caught my eye).

Thanks in advance for any suggestions

-John Coleman
 
J

jacob navia

Le 05/03/12 14:21, John Coleman a écrit :You can use my compiler system and its associated text book:
"An introduction to C programming using lcc-win".

It has several advantages:

o It is free of charge (the compiler AND the introduction)
o It starts from the ground up, but covers sophisticated topics
like in-depth floating point analysis, memory allocation strategies
and many others.

o It is geared to lcc-win but all extensions of lcc-win are clearly
marked as extensions.

I am sure many people in this group will start complaining about it
and propose you gcc or some variant. Just ignore them :)

You can judge yourself by downloading it from

http://www.cs.virginia.edu/~lcc-win32

To download the introduction only, click on the "Tutorial" button.

Jacob
 
S

Stefan Ram

John Coleman said:
I will be running a special topics course with the title
"Modern C Programming"

What does »modern« suggest in this context?
pointers, malloc, and the safe handling of C-style strings

This is classic, traditional C.

This is obsolete (canceled and replaced by ISO/IEC 9899:2011).
One idea that I had was to concentrate on the Mandelbrot Set.

That was the height of fashion some decades ago. There is nothing
wrong with that. But why then, of all things, you choose »modern«
to title your class?
 
J

John Coleman

What does »modern« suggest in this context?


This is classic, traditional C.


This is obsolete (canceled and replaced by ISO/IEC 9899:2011).


That was the height of fashion some decades ago. There is nothing
wrong with that. But why then, of all things, you choose »modern«
to title your class?

The choice of the word "modern"

1) The subtitle to King's text.
2) "Advanced" sounded too pretentious
3) I wanted to emphasize to prospective students that C is not some language that was replaced by C++ in the 80s but is rather still heavily used and is furthermore a language which has (incrementally) evolved from the language which was (more-or-less) a subset of C++. Finally, I have as one of my course goals the teaching of methods to prevent buffer overflows, which is more of a concern now than when K&R was written.
4) As I indicated in my post, I was aware that my Mandelbrot set example should either be supplemented or even replaced by other projects which have amore computer-science flavor.
 
S

Stefan Ram

John Coleman said:
I wanted to emphasize to prospective students that
C is not some language that was replaced by C++

You might show them

http://www.tiobe.com/content/paperinfo/tpci/index.html

. C++ now even has been exceeded by C# in popularity.
C++ is dying.

C++ is still taught today, not because students believe it
replaced C, but because teachers and division chairs believe
it replaced C.

Another source

http://lang-index.sourceforge.net/

gives similar results. See also

http://en.wikipedia.org/wiki/Measuring_programming_language_popularity
 
B

Ben Bacarisse

John Coleman said:
Next fall I will be running a special topics course with the title
"Modern C Programming". The motivation for the course is that
currently our CS students are exposed to C++, Java and a smattering of
other languages (e.g. Lisp in an elective AI course) but no C per
se. While in principle they learn some C naturally in the course of
learning C++ they really don't learn all that much about things like
pointers, malloc, and the safe handling of C-style strings and they
definitely don't learn anything about C99. The proposed class is
intended to give a serious introduction to C to students who have a
working knowledge of either C++ or Java. This will allow me to blow
through the basic syntax of expressions, loops, etc. in a couple of
weeks and to spend the bulk of the semester on aspects of C which are
different from Java and even C++.

Be careful to point out why one would use C. Far too often, C is seen
as the "hard stuff" to get hooked on when the C++ high has worn off, but
that does a disservice to the students. C has niche uses: it's small so
there are environments where other languages won't work, and it's a sort
of lowest common denominator that can be useful for writing libraries to
link with almost any other language, but it is rarely the right choice
for a "normal" application. (These are not the only use-cases but the
point should be made that C is hard to use correctly and that must
be justified when choosing it.)
My question is - what would a good text be? My first tentative choice
was King's "C programming: a modern approach", but I have also been
looking at Kochan's book "Programming in C". More recently I have been
toying with the idea of using K&R. On the one hand that seems on the
face of it like a poor choice for a course called *Modern* C
programming. On the other hand - it *is* a classic and seems to hit
the right level of difficulty (a course for students who already know
at least one programming language). My main question is - does the
merits of K&R outweigh the disadvantages of the lack of coverage of
C99? I could of course supplement K&R by e.g. O'Reilly's "C Pocket
Reference" which covers the C99 material. Where I'm at right now is
that my heart says to go with K&R but my head says go with King (or
Kochan). The bookstore wants a decision on my part sooner rather than
later.

I can't help much here, but do you have to pick only one? The bookshop
might be able to stock both on a sale-or-return basis and you can then
explain the merits of each and the students can decide.
Also - I am open to ideas about projects for the students to work
on. One idea that I had was to concentrate on the Mandelbrot
Set. Towards the beginning of the semester they could have a program
which just prints to the command line e.g. with '*' for points in the
set. Later on they could write it to a portable bit map text
file. Even later they could write it to a .bmp file in which they have
to get the header and the byte-alignment correct. Finally, I could
have them rewrite it in C99 with e.g. the complex-number type and
variable-length arrays so they don't have to hard-wire in the size of
the bitmap. This topic of course reflects my interest as a
mathematician. I have less ideas when it comes to straight
computer-science applications (although Jacob Navia's idea about a
hex-dump utility for pedagogical purposes caught my eye).

So many... Regexp matching is fun and can be posed as a simple exercise
with lots of optional extras for those who like to do more. I.e. write
Unix's grep command.

I've had fun with poker hand exercises:

$ choose-winner 2h4s5c7d8d kskh3c3d3s 4h5h6h7h8h
4h5h6h7h8h

You can make it harder by using a "hold 'em" format and/or getting into
probabilities with partial hands.

A small language interpreter can also be good fun. Two very simple ones
are SKI combinators and a cut down lambda calculus (essentially a micro
Lisp). Depending on the student's background you can sometimes get as
far as a very simple compiler for a C subset. You pretty much have to
provide an interpreter for an invented machine to which they must
compile the code, so there's quite a setup cost for you.

Image processing can also be very enjoyable. I like to pick an easy to
read and write format like PPM (at least to start with). You can then
have a whole range of exercises like contrast enhancement, rotation or
even steganography. There a very rich vein there.

One of the key determining factors will be the students. If they are
all art majors, SKI combinators will just bomb!
 
K

Keith Thompson

What does »modern« suggest in this context?


This is classic, traditional C.


This is obsolete (canceled and replaced by ISO/IEC 9899:2011).

Officially, yes, but if you have a C11 compiler lying around I'd like to
know about it.

C99 is as modern as you can get these days -- and even that is *too*
modern if you want to compile your code with Microsoft's compiler.
 
K

Keith Thompson

John Coleman said:
I teach math and computer science (though mostly math) at a small liberal arts college. Because of our smallness we don't have a huge course offering. To compensate, we have a grab-bag "special topics course" where we cover different topics each semester based on student's and/or professor's interests.
[...]

It's helpful to add line breaks so your lines are no longer than
80 columns, preferably 72. Some Usenet clients deal with very long
lines just fine, but others don't. (Mine, for example, wraps long
lines, but not at word boundaries.
 
S

Stefan Ram

Ben Bacarisse said:
link with almost any other language, but it is rarely the right choice
for a "normal" application. (These are not the only use-cases but the
point should be made that C is hard to use correctly and that must
be justified when choosing it.)

But what do you use for a »normal application«?

I would like to say »Java«, but the Java people say that Java is
disappearing from the desktops and has moved on to web servers.

(Also, I am not sure what defines a »normal application«.
To a young student, it's an »app«? So learn Objective-C for iOS?)
 
B

Ben Bacarisse

But what do you use for a »normal application«?

That would depend on the context. A GTK Linux application? I'd use
Vala. A .NET application in Windows? C# probably. Something that must
run on all sorts of systems? C++ would be a starting point worth
considering.
I would like to say »Java«, but the Java people say that Java is
disappearing from the desktops and has moved on to web servers.

(Also, I am not sure what defines a »normal application«.
To a young student, it's an »app«? So learn Objective-C for iOS?)

I agree that definitions are a problem and that I could have been
clearer. Maybe this is better: too many people struggle to write some
program or other in C, simply because of a misconception that C is what
the really advanced people use.
 
N

Nomen Nescio

I've been noticing the English is reprehensible in K&R II. The first edition
wasn't great but the errors in the 2nd edition are indeed egregious and now
I find it difficult to read because of the glaring errors. Has anyone else
noticed this or did somebody butcher the copy I ripped off from the 'net
(serves me right for not paying?) I do have a paid copy of the first
edition, well worn btw. Was just too lazy to go looking for the 2nd so
ripped one off from the comfort of my easy chair.
but it is rarely the right choice for a "normal" application.

This should be at the front of every C textbook but it's far, far too late
for that...
 
K

Kleuske

Le 05/03/12 14:21, John Coleman a écrit :
You can use my compiler system and its associated text book: "An
introduction to C programming using lcc-win".

It has several advantages:

o It is free of charge (the compiler AND the introduction) o It starts
from the ground up, but covers sophisticated topics
like in-depth floating point analysis, memory allocation strategies
and many others.

o It is geared to lcc-win but all extensions of lcc-win are clearly
marked as extensions.

I am sure many people in this group will start complaining about it and
propose you gcc or some variant. Just ignore them :)

You can judge yourself by downloading it from

http://www.cs.virginia.edu/~lcc-win32

To download the introduction only, click on the "Tutorial" button.

Jacob


Shamelessly promoting your own stuff isn't exactly "advice".
 
J

John Coleman

Shamelessly promoting your own stuff isn't exactly "advice".

What is "shameless" about promoting something that you are justly proud of,
especially when it is on-topic? Also - note that I specifically mentioned Jacob
by name in my original post since I thought an idea he had discussed (last fall?) was a promising idea for teaching. That made the mention of his text
quite natural in his reply.
 
J

John Coleman

Le 05/03/12 14:21, John Coleman a écrit :
You can use my compiler system and its associated text book:
"An introduction to C programming using lcc-win".

It has several advantages:

o It is free of charge (the compiler AND the introduction)
o It starts from the ground up, but covers sophisticated topics
like in-depth floating point analysis, memory allocation strategies
and many others.

o It is geared to lcc-win but all extensions of lcc-win are clearly
marked as extensions.

I am sure many people in this group will start complaining about it
and propose you gcc or some variant. Just ignore them :)

You can judge yourself by downloading it from

http://www.cs.virginia.edu/~lcc-win32

To download the introduction only, click on the "Tutorial" button.

Jacob

Thanks for the offer but I tend to use Textpad + gcc (via MinGW) for my
own programming and don't want to spend time learning a different environment
between now and then. Also - the fact that lcc-win32 has an IDE is a bit ofa
drawback from my perspective since as a side-purpose of the class I think that
it is good that the students get more exposure to command-line tools.

-John
 
J

John Coleman

Than

John Coleman said:
I teach math and computer science (though mostly math) at a small liberal arts college. Because of our smallness we don't have a huge course offering. To compensate, we have a grab-bag "special topics course" where we cover different topics each semester based on student's and/or professor's interests.
[...]

It's helpful to add line breaks so your lines are no longer than
80 columns, preferably 72. Some Usenet clients deal with very long
lines just fine, but others don't. (Mine, for example, wraps long
lines, but not at word boundaries.

--
Keith Thompson (The_Other_Keith) (e-mail address removed) <http://www.ghoti.net/~kst>
Will write code for food.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"

Thanks for the tip - I'll try to keep it in mind, though it might be somewhat
hard when posting via an editor that has a small window size and automatic
word wrap. Hard - but not that hard I guess.
 
B

BartC

Thanks for the offer but I tend to use Textpad + gcc (via MinGW) for my
own programming and don't want to spend time learning a different
environment
between now and then. Also - the fact that lcc-win32 has an IDE is a bit
of a
drawback from my perspective since as a side-purpose of the class I think
that
it is good that the students get more exposure to command-line tools.

I've been using lccwin32 for at least ten years, and I've never used it's
IDE. Although I also use mingw/gcc for a 'second opinion' (as my C work is
mostly experimental).
 
I

Ian Collins

But what do you use for a »normal application«?

I would like to say »Java«, but the Java people say that Java is
disappearing from the desktops and has moved on to web servers.

Common sense does prevail sometimes!
(Also, I am not sure what defines a »normal application«.
To a young student, it's an »app«? So learn Objective-C for iOS?)

That really depends on the environment. In the Unix world, Python is
becoming increasingly popular for utilities that used to be written in C.
 
I

ImpalerCore

Greetings,
[snip]

Also - I am open to ideas about projects for the students to work on.
Thanks in advance for any suggestions

One project that could be interesting is to create a spell checker.
Have a dictionary of words, use the levenshtein distance to evaluate
closeness, and present a top 5 list of alternatives. One could
incorporate file I/O to add words to a dictionary file.

Another project would be to create an email spam filter. You could
have a students collect samples of spam email, and devise methods to
remove unwanted email. You could use simple keyword recognition, like
if "meds" is in the subject header, send it to the spam folder. You
could just have a file of email subject headers to evaluate, and they
can calculate a likelihood that the email is spam. You could even
make it a student contest to design the best spam filter that
eliminates the majority of spam. You give them a sample file, while
you run their program on your master file to determine accuracy.

You can create structures that would mimic records in a database.
Then have them be able to search, sort, or filter on given field(s).
Here is a simple example of movie database.

\code
struct movie_record_tag
{
int id;
char title[40];
char rating[10];
int year;
};
typedef struct movie_record_tag movie_record;

movie_record movie_data[] =
{
{ 1, "Avatar", "PG-13", 2009 },
{ 2, "Ratatouille", "G", 2007 },
{ 3, "The Matrix", "R", 1999 },
{ 4, "The Lord of the Rings: The Two Towers", "PG-13", 2002 },
{ 5, "The Dark Knight", "PG-13", 2008 },
{ 6, "Back to the Future", "PG", 1985 },
{ 7, "The Forbidden Planet", "PG", 1956 },
{ 8, "Iron Man", "PG-13", 2008 },
{ 9, "Star Trek II: The Wrath of Khan", "PG", 1982 },
{ 10, "Terminator 2: Judgement Day", "R", 1991 },
{ 11, "Jonah: A VeggieTales Movie", "G", 2002 },
{ 12, "Star Wars V: The Empire Strikes Back", "PG", 1980 },
{ 13, "Sneakers", "PG-13", 1992 },
{ 14, "Finding Nemo", "G", 2003 },
{ 15, "Aliens", "R", 1986 }
};
\endcode

You could have them store it in a container to be able to sort based
on the year, or filter movies appropriate for a person's age (like a 5
yr old would only be able to see G rated movies). If you have a
linked list container API, you could have them insert these records
into a linked list, then use search and sort functions to analyze the
data.

You could incorporate some kind of date processing to categorize
people by age, like say find out who the top 10 oldest or youngest
presidents were. They would need to do the conversions of dates in a
string format like "mm/dd/yyyy" to some kind of day count (you could
use a Gregorian calendar where a day count of 0 is Jan 1, year 1),
maybe adding some error detection to detect invalid dates, and print a
list of those presidents with their birthdate.

There are several things that you could expose them to that while they
are not directly related to C, you can still incorporate them into
"modern C programming". For example, one could incorporate doxygen as
a tool to learn documentation generation in the project. You give
them a partial structure for an API, they have to fill in the gaps in
the guts and documentation. You could do this for a simple container
like a linked list or resizable array.

You could have a refactoring project. You have a monolithic program
that you want your students to split into headers and source files,
maybe adding a makefile to the mix. Instead of using #define to
define input values, have the students convert it to accept user input
from the command line.

You can have them learn how to use a graphing library, like gnuplot.
The assignment could be to put in a simple equation like 2*sin(x),
evaluate the data over a given domain with a certain precision, then
either write a gnuplot file to display the data or use its C API.

You would know better than me how to limit the complexity to a
project, but maybe something here will inspire you.

Best regards,
John D.
 
H

Hans Vlems

Greetings,

I teach math and computer science (though mostly math) at a small liberalarts college. Because of our smallness we don't have a huge course offering. To compensate, we have a grab-bag "special topics course" where we coverdifferent topics each semester based on student's and/or professor's interests.

Next fall I will be running a special topics course with the title "Modern C Programming". The motivation for the course is that currently our CS students are exposed to C++, Java and a smattering of other languages (e.g. Lisp in an elective AI course) but no C per se. While in principle they learn some C naturally in the course of learning C++ they really don't learn all that much about things like pointers, malloc, and the safe handling of C-style strings and they definitely don't learn anything about C99. The proposed class is intended to give a serious introduction to C to students who have a working knowledge of either C++ or Java. This will allow me to blow through the basic syntax of expressions, loops, etc. in a couple of weeks and to spend the bulk of the semester on aspects of C which are different from Java and even C++.

My question is - what would a good text be? My first tentative choice wasKing's "C programming: a modern approach", but I have also been looking atKochan's book "Programming in C". More recently I have been toying with the idea of using K&R. On the one hand that seems on the face of it like a poor choice for a course called *Modern* C programming. On the other hand - it *is* a classic and seems to hit the right level of difficulty (a course for students who already know at least one programming language). My main question is - does the merits of K&R outweigh the disadvantages of the lack of coverage of C99? I could of course supplement K&R by e.g. O'Reilly's "C Pocket Reference" which covers the C99 material. Where I'm at right now is that my heart says to go with K&R but my head says go with King (or Kochan).The bookstore wants a decision on my part sooner rather than later.

Also - I am open to ideas about projects for the students to work on. Oneidea that I had was to concentrate on the Mandelbrot Set. Towards the beginning of the semester they could have a program which just prints to the command line e.g. with '*' for points in the set. Later on they could write it to a portable bit map text file. Even later they could write it to a .bmpfile in which they have to get the header and the byte-alignment correct. Finally, I could have them rewrite it in C99 with e.g. the complex-number type and  variable-length arrays so they don't have to hard-wire in the size of the bitmap. This topic of course reflects my interest as a mathematician. I have less ideas when it comes to straight computer-science applications (although Jacob Navia's idea about a hex-dump utility for pedagogical purposes caught my eye).

Thanks in advance for any suggestions

-John Coleman

Go for C and use King's book. Your heart may tell you to use K&R but
you're teaching a math class not history, right ;-) ?
If you want datastructures that have variable length, well use linked
lists of structures.
Hans
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top