
Essential C - ingve
http://cslibrary.stanford.edu/101/
======
CalChris
_Essential C_ doesn't mention a standard but it says _Copyright 1996-2003_.
I'm going guess it hasn't been updated for C11.

 _Modern C_ [1] covers C11 and was mentioned before. However, it weighs in at
300 pages rather than _Essential C_ 's 45.

[1] [http://icube-icps.unistra.fr/img_auth.php/d/db/ModernC.pdf](http://icube-
icps.unistra.fr/img_auth.php/d/db/ModernC.pdf)

Actually, reading through _Essential C_ , it hasn't really been updated for
C99 since it uses C89 declarations:

    
    
      C takes the middle road -- variables may be declared
      within the body of a function, but they must follow a
     '{'. More modern languages like Java and C++ allow you
      to declare variables on any line, which is handy.

~~~
bangonkeyboard
I don't know if I would count any part of C11 as "essential", particularly
given its still-spotty implementation coverage.

~~~
userbinator
A lot of code is still written in C89 for maximum portability, and I regularly
do that. The only thing I really miss from C99 is the mixed declarations and
code, but you can instead use nested scopes or just move the declarations up
to the top.

~~~
pcwalton
What portability do you need, specifically, beyond C99?

~~~
userbinator
A lot of compilers for embedded systems are still C89 (with a few
architecture-specific extensions).

~~~
pcwalton
Which systems, specifically?

------
bstrong
Oh, memories. I took CS107 in 1996, which was apparently the date this handout
was written. Nick was my academic advisor, and his CS108 (which was C++ at the
time) was one of my favorite courses of all time. Bunny World...

Maybe I'm just a grumpy old programmer, but I feel like kids these days are
missing out on something important by learning to program in a language that
doesn't require them to truly grok memory management.

~~~
agnivade
Most often, in general purpose programming, you don't need burden of managing
memory manually. Things just go fine with a good runtime.

And that is what I think beginners should be introduced to - how to write
code, how to frame algorithms in your mind and convert them into lucid code.
Python does all of this wonderfully. It hides all of the internal details and
exposes just the part that is needed for sometime writing a computer program
for the first time in their life - simple statements which do simple things.

There is no need for a beginner to understand memory management at all. Trying
to understand what is code or how algorithms work is more important to build
that mental capacity IMO. Pardon me, but it does seem that just because you
had to undergo the pain of trying to understand pointers, memory layout and
allocations, you want everyone to go through the same experience as well.

------
zeugmasyllepsis
I recently started a graduate course that originally required C++. My only
exposure to C++ basically went through the fundamentals of the C part without
getting to any of the ++.

Is there something similar to this for C++? I understand that C++ is a much
larger language and I'm definitely not looking for something comprehensive,
more of a solid overview of a workable subset of the language. Enough to be
productive, produce reasonably modern idiomatic code that can be improved or
expanded in the future.

In the end, the graduate course ended up using Python, but I'm still somewhat
curious about modern C++.

~~~
smnplk
Word of advice. Don't learn any of the OOP stuff in C++, many learned it, but
later they had to unlearn it. Search for data oriented design.

~~~
clappski
That’s as bad as saying OOP is the cure for all your problems! Learn all the
paradigms and use them where they’re best used, don’t shun any or advise
someone against it just because you’ve had a bad experience.

~~~
smnplk
I am frankly getting sick of the notion "use the right tool for your problem",
when discussing programming paradigms. No, programming paradigm is not a tool.
Programming language is a tool, data structures are tools and algorithms are
tools. I don't believe there exists such and such problem, that can only be
solved/expressed in OO way and the only true way is to do it in OO way or the
best way if you prefer.

------
imwally
Great little resource on C programming and data structures. I had a lot of fun
going through the problems presented in the Linked List and Binary Tree
sections [1].

[1] [https://github.com/imwally/cmuck](https://github.com/imwally/cmuck)

------
reacharavindh
Does anyone have any recommendations for a document like this that describes
how NOT to write C? Like the security issues and tricks to avoid the pitfalls?

~~~
mmjaa
This is _the_ book for this particular subject:

[https://www.amazon.com/Expert-Programming-Peter-van-
Linden/d...](https://www.amazon.com/Expert-Programming-Peter-van-
Linden/dp/0131774298)

Every C programmer should have this on their bookshelf!

------
nwellnhof
First mistakes I found are on page 4.

"the compiler "promotes" the smaller type to be the same size as the larger
type before combining the values." Values smaller than int are always promoted
to int.

"Promotions do not lose information -- they always convert from a type to
compatible, larger type to avoid losing information." This isn't true when a
signed type is promoted to unsigned.

It seems that the author didn't read the C language specification.

------
ateesdalejr
Thanks for this! I've been searching for something like this for a while. So
I'll add it to my bookmarks. As I'm currently using Beej's Guide to C to learn
and this one looks a bit nicer. Also it's by stanford so that's cool.

------
akkartik
The last link to "the great tree-list recursion problem" is an awesome
assignment for thinking about pointers. (Though not really in any way
representative of useful code.) Still fun to do after 20 years of writing C.

------
mountaineer
Any interesting ideas to try C out on for an experienced programmer?

~~~
shakna
If you're looking for something quick, then a Brainfuck interpreter shouldn't
take longer than an afternoon, and a simple one will be a couple hundred
lines. Optimising it though, can be more difficult and is one of those things
you can keep working on for ages.

If you're looking for a challenge, a JSON parser is a more involved project,
especially if you implement your own HashTable structure for storing things.

If you want something to be proud of at the end, then you could always try
your hand at glitch art. Grab an image file, read it, manipulate it, and
output it again.

------
oweiler
There's also a very nice Python intro from the same author.

~~~
oweiler
[https://developers.google.com/edu/python/](https://developers.google.com/edu/python/)

------
thegabez
Any additional recommendations for C tutorials?

~~~
flavio81
When i was about 13 or 14 years old, i read Brian Kerninghan & Dennis
Ritchie's "The C Programming Language". This book (by the language creators)
is a classic and does an excellent job of explaining the C language. I learnt
C by reading that book and experimenting writing code.

It is a very good book and it should be easily available.

~~~
phaus
A lot of people love this book, but I kept getting stuck because it seems like
half the time it assumes prior programming knowledge. I only made it a few
chapters in, but I don't think they do a great job of explaining much of
anything to a beginner.

I'm planning on attempting to read it again after I finish Harvard's CS50.
Maybe I just need a lot of hand-holding, but this course seems to do a much
better job of explaining concepts.

~~~
flavio81
_> but I kept getting stuck because it seems like half the time it assumes
prior programming knowledge_

Yes, to be honest, C is not good as a "first" programming language. If i can
give you a suggestion, it would be: Start learning Python, which is a good
"first language to learn", and then try this book.

You will find that jumping from Python to C there will be two strong
differences:

a) C is a statically typed language, so you will need to declare (specify) the
type of each variable you would like to use.

b) In Python, the language manages your usage of the computer's memory. In C,
you manage the memory... After some CS courses you'll probably be familiar
with concepts like "linked lists", which then you can try implementing in C by
using pointers. Thus, you'll realize that in C you are in control of the
computer's memory; you will be able to request (allocate, with _malloc_ )
blocks of memory and _free_ them afterwards.

c) C syntax can be tricky, compared to Python.

~~~
Koshkin
I have had a great success teaching a kid programming using javascript and
_plain_ HTML. There are numerous advantages to this approach.

