J
John Bode
I'm learning C right now as my first language(I've done functions, loops,
data types, if/else), and I'm wondering if I'm going the right path. I've
heard alot of good stuff about C, like how it's super fast and simple to
learn. I've also heard alot of bad stuff about how it's old, busted, and
non-object oriented. I'm a linux user(Arch/Gentoo), and I want to get started
on a project after I'm done learning. I want to join an operating system
project and help in it and stuff(I really like the whole idea of operating
systems and how many layers it has), but I want to make sure I'm getting the
right stuff so I could learn what I need.
What do you guys think is the benifit of learning C first? What would be a
drawback?(BTW: I'm totally fine with the manual memory thing(it turns me on
(I know that's a bit weird, but I'm a linux geek)) and I'm willing to learn
it). What would be some good sources of learning? What practices should I
avoid? What OS projects would be good for a beginner?
Normally, C makes a *lousy* teaching language because it assumes you know what
you are doing at all times. That's a bad assumption to make for experienced
programmers, much less for people just starting out. Ed Post described
TECO as a "you asked for it, you got it" editor (as opposed to "what you see is
what you get"). C follows a similar philosophy, and won't necessarily warn
you when you're doing something stupid. Think of C as a power tool with no
blade guards, and just be aware that it *will* cut you at some point.
However, since you're interested in systems-level programming, C is a good
language to learn, since it exposes a lot of low-level concepts. It makes
you aware of how your data maps to memory (at least at the conceptual level).
It also makes you aware of memory as a limited resource.
The main drawback of learning C first is that it wires you into thinking in
low-level terms (not like assembler, but still...); this can be a hinderance
when learning languages like Haskell, or even Java. A secondary drawback is
that most C references are *crap*. A lot of bad practice and misinformation
has metastasized in most books and tutorials.
C provides no standard containers beyond arrays. For anything more complicated
(queues, stacks, trees, dictionaries, etc.), you'll have to roll your own or
find a third-party library. The benefit of rolling your own is that you learn
how such containers work, and how different implementation strategies have
different performance. The drawback is that you have to write, test, and debug
all that code along with the code that works the actual problem.
As for resources, my go-to desktop reference is Harbison & Steele's "C: A Reference Manual", currently 5th edition. Kernighan & Ritchie's "The C
Programming Language", 2nd ed., is somewhat long in the tooth (doesn't
cover C99), but is still a good introduction. Although I haven't used it
myself, King's "C Programming: A Modern Approach" is recommended by people
I trust.
An online draft of the latest C standard (C 2011), is available at
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf
On its own it's not a great *learning* resource, but as you become more familiar
with the language it will be invaluable.
For my part, I don't do systems programming; I'm a dumb applications programmer who makes maybe one or two systems calls per project, usually to create a
thread or something. I've never worked an OS kernel, so I can't give any
guidance in that area.