Recommendation for a text

G

Gene

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.

This is nice. You have the right idea. The projects that will
inspire the best efforts are never the ones that can be done as well
or better with everyday tools. Other possibilities
* A* search to solve a tough puzzle. A favorite of mine is the
8-bishops problem from 7th Guest.
* Sudoku solver and/or generator
* Crossword puzzle generator
* Big integer arithmetic good enough to implement RSA encryption
* Queueing or Monte Carlo simulation of a local business or process
 
J

JohnF

John Coleman said:
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 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.
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

Not really sure about what book might be better. Where are
these students going next? I take it they're cs students
learning (if you have your way:) a little math, rather than
math students learning cs. Of course, real cs requires lots
of math, but lots of cs curricula teach future programmers
how to program, not cs per se. I think real cs students
might gravitate more towards k&r; otherwise, maybe not.
But you're the one who's there and knows them and knows
the curriculum and available books. So you're the best
(if not only) one to make the right call.

As for Mandelbrot, that's a nice idea. But have them
construct a memory-resident raster structure, nrowsxncols,
along with a layer of output routines, the first being
your printf, and later maybe bmp, etc. That way the underlying
raster bitmap (or 3 bytemaps if you want color) structure is
flexible for any future purpose. Plus, it teaches them
a little more about structs. A straight printf program
is a dead end vis-a-vis future output option enhancements.
During a little recent downtime between contracts,
I wrote http://www.forkosh.com/lineart.html based on that idea
(see example=6 and =7 when they happen to scroll by for fractals),
and also based on earlier http://www.forkosh.com/onedwaveeq.html
which is an exercise trying to use gif animation as a visual
teaching aid (I still haven't figured out how to use it
really well, but am convinced there's a way, if I can find it).
These programs use existing libraries to drive gif creation from
the bytemap raster, and animated gifs using ImageMagick's convert
via a system() call. So once they have a memory-resident raster,
there's really lots of "cute" places they can go from there (e.g.,
besides the gifs, note the postscript output option on lineart).
Plus, using library routines to get to some of those places helps
teach them how to interface their own stuff with canned code,
an important skill.
 
L

Luca Forlizzi

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.

Hello, I teach C programming at University of L'Aquila (in Italy), in
the first year of our BS program since 2004. I changed several times
the "official textbook" for the course. Our students, on the average,
do not have any programming background and are not used to spend much
time with books. So learning C, for them is rather hard. (I have to
point out that to teach C in the first year s not a decision of mine).
I have tried to use K&R but results were not good. K&R it's a superb
introduction to the language but it is not, in my opinion, an
introductory text to programming in general, at least not for students
with rather week scientific and cultural background.
K&R assumes the reader already manages many concepts.
Then I switched to Deitel&Deitel, at the time the italian edition was
based on the 5th USA edition. Results were better in terms of general
programming ability, but C's peculiarities were not well understood.
Since 2009 I switched to King, and I am very happy with such choice.
It succeed rather well in explaing at the same time general
programming concepts and C's peculiarities. Students perform
statistically much better.
 
J

Joe keane

More recently I have been toying with the idea of using K&R.

I'd make that the first book.

The weakness is that it's not great for someone who does not know
programming at all [confer someone who is fluent in BASIC and wants to
learn C].

IIRC, i learned programming from the book with the TI-57.
 
J

jgharston

Ian said:
C and C++ still dominate the embedded and non-windows system programming
space, neither is dying and one hasn't replaced the other.

Just wait, I'm sure Vista will be shipping on washing machines
soon. ;)

JGH
 
K

Kaz Kylheku

Next fall I will be running a special topics course with the title "Modern C
Programming".

This course title is a gaping oxymoron. But titles are just labels
of no consquence. Or are they?
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.

Oops! Now you're constraining what books to use because of a weasel word in the
course title.
 
C

Charles Richmond

John Coleman said:
[... what textbook should I use for C++ students to learn plain C
programming ...]

K&R explains the basics of C programming. C++ people should be familiar
with the basics already. So choose a book that skips over all the
explanations of looping constructs and such... and goes right to using the
"advanced" features of C.

Also, just for fun, think about adding _Expert C Programming: Deep C
Secrets", by Peter van der Linden (ISBN: 978-0131774292). It goes into
several topics in C *not* usually covered, and has some funny anecdotes
thrown in to hold a student's interest.
[... what projects should the students work on ...]

Anything that produces some sort of computer graphic display is always
interesting to students. But I like projects that emphasize some advanced
data structures, like AVL or red-black trees. Learning to build AVL trees
and maintain the AVL property while adding and deleting nodes... can be
challenging. For me, just creating code in C is a thrill! I just enjoy
programming.
 
J

Joe keane

Also - I am open to ideas about projects for the students to work on.

The first 'major' programs i wrote for both BASIC and Pascal were
adventure games. This is how i learned that Pascal sucks.
 
P

Patrick Scheible

The first 'major' programs i wrote for both BASIC and Pascal were
adventure games. This is how i learned that Pascal sucks.

Pascal sucks for major programs because it was designed for teaching,
not for major programs.

-- Patrick
 
I

Ian Collins

Pascal sucks for major programs because it was designed for teaching,
not for major programs.

The first "major program" I worked on was written in DEC
MicroPower/Pascal on a PDP11. A surprisingly good environment for its
day. So with the right support, Pascal isn't too bad.

I'm somewhat surprised how little google has on it..
 
F

Fritz Wuehler

The Wirth Pascal sucks because it's from Wirth, it's a teaching language,
it's a one pass compiler, and it is unsuited for doing any serious work
because of critical, built-in limitations. Kernighan (or was it Ritchie?)
wrote a paper that nails the coffin shut on the original without much effort.
The first "major program" I worked on was written in DEC
MicroPower/Pascal on a PDP11. A surprisingly good environment for its
day. So with the right support, Pascal isn't too bad.

Extensions to Pascal have made it perfectly usable, depending on which
version you use. You can't say "Pascal is" or "Pascal isn't" anything until
you specify which implementation of Pascal you are talking about.
 
A

ArifulHossain tuhin

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


Right now i'm trying to install his lcc-win through wine. and i've downloaded the pdf already. It seems logical to promote it because both of the guysare interested in "using c" in

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

the tools jacob mentioned seems built for using c in educational environment. original author of the post also has the same motive. so mentioning it seems quite logical. it may hurt hard core programmers who despise source level debuggers does hex arithmetic by hand.

although jacob's compiler has a commercial license which is not making it easy for me to make the point for jacob. :)
 
M

Malcolm McLean

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++.
I wrote a book called Basic Algorithms. It's in ANSI C. It;s not a C
primer, it's the book to read after ypu've worked through the C
primer. It might be what you're looking for. It's available
electroncially or in printed form.
 
J

Jorgen Grahn

....
If you want datastructures that have variable length, well use linked
lists of structures.

Yes, as long as he shows the drawbacks of that and the shortcomings of
C in that area. (It's not as if the students won't notice; they have
experience with other languages.)

I'm mostly a C++ person, and in my current C project at work, the
worst aspect related to the language is all those malloced linked
lists. In C++ I would have chosen to use a std::vector<T> for
seriously better performance and reliability.

/Jorgen
 
J

JohnF

Jorgen Grahn said:
I'm mostly a C++ person, and in my current C project at work, the
worst aspect related to the language is all those malloced linked
lists. In C++ I would have chosen to use a std::vector<T> for
seriously better performance and reliability.
/Jorgen

I'm mostly a C person, and I agree you have a point.
Whenever I have a nontrivial data structure, let's
call it struct bigmess, it's always accompanied by
"methods" struct bigmess *new_bigmess(), and
int delete_bigmess(), that I write myself and that
do all the ugly mallocing and freeing necessary,
hiding all that housekeeping from the rest of the
application. Lots of useful C++ ideas can be
incorporated into C design (but I don't want to
get into the naive argument, "then why use C?").
 
F

Fritz Wuehler

JohnF said:
I'm mostly a C person, and I agree you have a point.
Whenever I have a nontrivial data structure, let's
call it struct bigmess, it's always accompanied by
"methods" struct bigmess *new_bigmess(), and
int delete_bigmess(), that I write myself and that
do all the ugly mallocing and freeing necessary,
hiding all that housekeeping from the rest of the
application. Lots of useful C++ ideas can be
incorporated into C design (but I don't want to
get into the naive argument, "then why use C?").

We do that (and more) in assembler and have been doing those things since
way before there ever was a language called C++. Those ideas aren't from
C++...
 

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,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top