
Why learn C? - Garbage
http://radar.oreilly.com/2012/06/why-learn-c.html
======
tjr
If you're interested only in learning about lower levels of the computer, and
don't need to actually write at lower levels, it may be better to learn, say,
MMIX.

But lots of people do need to learn C. They might not be working on hip new
social web services, but they're out there.

In my work, I have observed recent computer science graduates filter in and
get assigned to program embedded systems using C. Their knowledge of C was
minimal. Their code tended to be suboptimal, or even bizarre to the point of,
I wasn't sure why it compiled. I recommended they get a copy of K&R. They did.
I don't think they got much out of it.

I don't blame them personally. They simply had not been taught C in school,
and had never had a reason to learn it before. Trying to learn it on the job
with antiquated books didn't seem to work very well. (Though some did
eventually come to learn C well. Others migrated to different assignments not
involving C.)

Whatever your reason for wanting to learn C, be it purely academic, or if you
actually need to program with it, fresh, modern educational resources are a
good thing.

------
noonespecial
Yes, C is just another arbitrary abstraction layer among many others, but it
occupies a special position in modern computing.

C is the lowest abstraction layer that compiles on the most hardware. "Where
the falling angel meets the rising ape", as it were.

------
quesera
Because if you don't know C, you don't know what's actually happening when you
write software.

Because if you don't know C, you've only seen the map, not the territory.

Because if you don't know C, you're looking at the finger, not the moon.

Because if you don't know C, everything you think about computers is a leaky
abstraction.

The counterpoint is that flawed models are often good enough. Newton's theory
of gravitation comes to mind.

But if you like knowing what's going on, either for personal satisfaction, or
because what you're working on is not fully encapsulated by a different
language (inevitably, originally, written in C), then C is both interesting
and useful.

~~~
zxcdw
Comments like these seem to have the underlying idea that C somehow explains
how things work. It doesn't. It doesn't explain at all. It's only an
abstraction among the others - granted, it's a lower level abstraction.

To understand how a computer works when it executes a program, accesses some
data, writes to a disk, spawns a process and forks it, then kills the child
after a certain interrupt can pretty much only be learned by learning assembly
and some hardware and OS-related literature. Of course, for most
programmers(let alone people in general) this is nearly useless information
today. It's obsolete. And that's good.

But what C teaches you about how "things are under the hood", is just a leaky
abstraction. C doesn't care about such low-level things because they are
implementation details. Standard C could be ran by pen and paper just as well
as on a computer. It's a "black box". Takes input and produces output
according to the standard.

Frankly, the only "low-level" thing C has over e.g. Java is that most domains
in which C is used are working close to the hardware and it runs on "the real
hard machine". With C, in it's modern domains, you are exposed to these "low-
level" details, not because of C, but because of the domain. With many other
languages the user doesn't have to deal with such problems because of the
problem domain is different.

~~~
eliben
Of course C doesn't "explain" how things work. C is a language, it doesn't
explain anything. However, when you write and read real-life C code, you have
a chance to learn how software works under the hood much better than with
higher-level languages. The low-level rigid type system makes you see how data
structures are really laid out. Pointers and direct memory addressing makes
you realize how memory is really managed, the real meaning of passing things
by value and by reference, and many more things.

~~~
stonemetal
_However, when you write and read real-life C code, you have a chance to learn
how software works under the hood much better than with higher-level
languages._

getchar(); //C STDIN.getc //Ruby getChar //Haskell System.in.read(); //java
How do any of those show me how software works under the hood? In none of them
do I have any clue how a character makes it from my terminal to my program.

int* a; Teaches me nothing about caches, memory latency, NUMA etc. Hell,
dereferences are even guarantied to read the same physical location in
memory(just the same logical location.)

struct stuff{ int a; int b; };

Doesn't teach me anything about memory layout. C assumes you are running on
some hardware from the 70s, it doesn't know about virtual memory, address
spaces, memory pages, NUMA, ram with multiple channels, the no execute bit,
GPGPU programming. The only thing C has going for it is simplicity.

~~~
kabdib
> The only thing C has going for it is simplicity.

But it's an interesting /kind/ of simplicity.

FORTRAN is simple, for instance. Yet we don't use it much any more.

C is simple enough to not make you go bananas trying to learn the language
[C++], but rich enough that you don't go bananas solving large, interesting
problems [assembly]. It pretty much nailed the uncanny valley of just complex
enough.

It's a bit creaky. It desperately needs namespaces. I'm on the fence about
memory models (this is a platform thing, in my mind), and definitely Do Not
Want threads jammed into the language. I would love a decent macro language,
but that's probably a decade-long debate (if what happened in the Scheme
community is any indication). I would love a compilation system that didn't
suck [yes, macros and a Go-like build system probably don't mix well].

I've been writing C for over 30 years. I plan to keep writing it for another
20. The unscientific, neat thing about C is that it's /fun/. I know this
doesn't go over well with standards types and cow-orkers who feel the urge to
override operator = and take dependencies on Koenig lookup all the time, but C
has a charm that other, similar languages have been unable to capture.

~~~
gaius
_FORTRAN is simple, for instance. Yet we don't use it much any more._

Computing is like an iceberg, with the web being the bit above the surface.

 _rich enough that you don't go bananas solving large, interesting problems
[assembly]_

Two words: macro assembler. It may surprise you to know that not that long
ago, sophisticated GUI apps were written in assembly language (in fact the IDE
I use on my ST, Devpac, was written in assembly, and it's everything you would
expect of a modern IDE - editor, compiler, debugger, etc - running under GEM).
Many games were written in pure ASM.

~~~
johnm
Indeed and even more... The entire GEOS operating system, gui/windowing
system, application suite, and the vast majority of the rest of the apps were
written in 8086 assembly language and ran on an original IBM PC.

~~~
gaius
Even business apps on mainframes were written in assembler... In fact a quick
Google shows they still are!
[http://www-01.ibm.com/software/awdtools/hlasm/library.html?S...](http://www-01.ibm.com/software/awdtools/hlasm/library.html?S_CMP=rnav)

~~~
Someone
There are a few niches where new code is written in assembler (numerical code,
parts of standard libraries), but in general, I think 'maintained' is a better
word to use.

------
jetsnoc
I think learning many different kinds of languages is important. The breadth
of experience makes you a better programmer as a whole. During the trial and
sampling of many languages you will fall in love with one. Stick with that
one! Your job should be fun. Each person has different learning modalities and
concepts they just "get" that are congruent with how they think so no one
language is perfect for everyone.

But, why learn C? Learn C to broaden your experience and gain a marketable
skill in the most popular programming language[1]. You don't have to become an
expert in it but I think everyone should dabble in it a little bit!

1: TIOBE index, June 2012

~~~
primitur
>I think learning many different kinds of languages is important.

I agree with you, 100%. There are no ultimate languages. You have a broad
field, as a developer, of words to use - choose the one you a) get along with,
b) can comfortably use, c) and are interested in actually using for something.

What I have observed is that good developers learn other languages faster, the
more they do it, i.e. if you set your goal higher, you get better at it each
time you iterate. I tend to think, as a generality, that eventually there is a
point for each individual developer where the effort to learn some new
language/codebase/taxonomy gets flatter and flatter, to the point that there
are no 'easier nor harder' levels of it any more.

C is still very, very useful. $35 worth of pocketable computing power and a
built-in C compiler can still deliver kick-ass results.

------
dsirijus
I've recently started relearning my C skill, since I've had not touch it in
almost a decade. I'm combining LCTHW, K&R and Sedgewick's Algorithms in C
series in the process.

I have not had so much fun programming since high school. The general feeling
of increased brainpower lurks with me these days mostly because of it.

------
tosseraccount
Well. Think about it. Probably 95% of the instructions executed on your
computer were generated by a C compiler or inlined withing a C program. Check
out how many of your programs are linked to a standard or special C library.
Perl, bash, Python etc. are written in C. Most libraries are written in
C.Throw in what's basically C programming in Objective C and C++ and we're
closer to 99%

~~~
Apocryphon
If C++ counts, does Java/C# count as well? If so then we'd definitely hit
around 99%

~~~
tosseraccount
No. C++ is a superset of C. You can write C and jam it into a C++ program.
This happens often enough in C++ programs. Java absolutely does count. The Sun
JVM was written in C !!! So, yes, every java program is executing instructions
generated by a C program.

~~~
kqr2
Some JVMs are actually self-hosting:

<http://jikesrvm.org/>

    
    
      A distinguishing characteristic of Jikes RVM is that it is 
      implemented in the Java™ programming language and is 
      self-hosted i.e., its Java code runs on itself without 
      requiring a second virtual machine. Most other virtual 
      machines for the Java platform are written in native code 
      (typically, C or C++). A Java implementation provides ease 
      of portability, and a seamless integration of virtual 
      machine and application resources such as objects, threads, 
      and operating-system interfaces.

------
ginko
C is the lingua franca of computing.

Pretty much every programming language in existence has bindings to C.

~~~
Shivetya
except all those written before it?

I program on a mid range system. If I want to write in C for it I could but I
have no reason too. I use two languages that appeared well before C and
produce very effective and near bullet proof code because of it.

There are some big names in the language world that were here before C and
some probably had influence on that language.

While I would not mind refreshing my C, having not had any use for it since
85, I am not even sure where to start.

~~~
gms7777
> except all those written before it?

Out of curiosity, what do you use? My history is not too great, but I can't
think of many languages that came before C that are still in use today. I
actually use fortran at work (along with C), and I'll give a pass to Lisp (it
seems like c predates the dialects that are still in common use, ie common
lisp and scheme), but it seems like most others (Pascal, COBOL, Basic) are
more curiosities in the modern world. Please correct me if I'm wrong.

~~~
batista
Actually Cobol is pretty much everywhere in the substrate, but not in visible
places... banks, insurance companies, and the like have tons of cobol code in
use.

~~~
RodgerTheGreat
And if we count VBA, VB6 and VB.net as spiritual successors to BASIC there's
an absolutely ungodly amount of new BASIC code in use and being written every
day anywhere people use Excel. It's ugly, but it's a large part of how
business is done.

------
swa14
Because when programming in any language, you can't rise above your own
proficiency in C.

That is my observation anyway. I think it has something to do with the deeper
understanding of references and dereferencing, and the inner workings of
languages in general.

~~~
kd0amg
I think that may only hold when working with sufficiently C-like languages.

~~~
dllthomas
In particular, I think that Lisp hackers of old put a solid lie to the claim.

------
mike-cardwell
I've been programming Perl for going on ten years, I know a bit of Java as
well, and have spent the last 4 or 5 years learning a lot about web
development. I even recently learned nodejs and coffeescript to a pretty
decent level and released <https://emailprivacytester.com/> using it.

I just started to learn C and C++ about a week ago. I did a module of it at
University many years ago, but I never kept it up afterwards and forgot nearly
all of it. Anyway, I am completely _loving_ learning it at the moment. It just
feels like I have so much more control of what I'm doing, and I can't wait to
build and release my first non-trivial application using it.

I want to know C well. Mostly, I just want to be able to confidently hack on
the massive amount of software that has been written in C over the years.

[edit] I've always had this feeling in the back of my mind, that no matter how
good I am at Perl or JavaScript or HTML or Java, I will never feel like an
"expert" until I am good at C.

~~~
eric_bullington
Coming from a web development and Python background, and starting to really
learn C about a year ago, I know the exact feeling you're talking about. As
many cool Python programs I had written, I just didn't feel like it was a
"real" program until I programmed and compiled an application in C. And I love
how C has made my Python so much more powerful, both through ctypes and
Cython. Finally, C was the gateway to Lua, which I'm now enthralled with: a
tiny, extraordinarily fast and flexible scripting language that is easily
compiled into a C program, thus giving me that single-file binary executable I
cherish so much. I know I could do the same with Python, but LuaJIT is just so
easy to embed, and yet so incredibly fast. Learning C has opened a lot of
doors.

~~~
luxpir
I first dipped my toe into C waters at 12 (years old) and very soon felt out
of my depth enough to leave it alone. Cut to much later and I think I'm ready
to try again.

I've no project in mind yet, but, Eric, your libtm plan caught my eye a few
months back and if you've anything on github I'd be interested to follow
along. I'm a translator myself and often find myself optimising how MemoQ
could be matching segments.

~~~
eric_bullington
Hey, I just e-mailed you. I've ended up starting to prototype libtm in Python
-- getting started in C just wasn't working. I still "think" in Python. Python
works out well because all the libraries I'm using (leveldb and ICU, mainly)
also have very nice Python bindings. Once I've got the prototype in Python,
I'll port it to C.

I'll see if I can put what I've got in Python up on github after I finish this
big project at work this week and next. I'd be really interested in your
input. Did you read the Tim Baldwin presentation on translation retrieval I
referenced in my post on libtm? He's done some really cool research that has
had a real impact on the way I keep my TMs (e.g., trying not to go over 20,000
segments).

------
andrewgu
This quote is the most important out of the whole bunch: "It's an important,
foundational language that requires you to understand the full stack of the
technology. If you learn C, you'll understand computers at a much more
profound level than if you don't."

We should be careful about the word "learn." I read it as "understand C and
master C," not simply being able to write C code.

Why read Shakespeare when you're learning to write? Why study Bach when you're
playing jazz? You can definitely skip Shakespeare and Bach, but I think it's
universally acknowledged that studying their work gives you important
foundational knowledge even if they don't apply directly to your work at hand.
Same with C.

------
fraughtwith
There's so much C code in so many critical environments that this language is
going to be around for much longer than anyone would like...

It'll be the Latin of computing. There will be some poor soul studying and
using C in a thousand years.

~~~
unimpressive
> There will be some poor soul studying and using C in a thousand years.

I would hope that by that time there will be powerful algorithms you can use
to transcompile old C code into $LANGUAGE code.

EDIT: Well actually I would hope by that time strong A.I has been invented and
asking flesh and blood humans to write code will elicit some _really_ strange
looks.

~~~
powerslave12r
That made me sadder than it should have.

------
zxcdw
I think C++ has greatly made C obsolete in many fields, I'd rather see people
embracing C++ than C when it comes to learning and using either. For example
almost everything C teaches about "low-level" and "how things work" is learned
by C++ too, while giving possibility to remain at higher level of abstraction
most of the time - if so desired.

~~~
raverbashing
Agree but kinda Disagree

C++ is built on C. You _need_ to know C (but maybe not the C library) to know
C++. Like pointers

~~~
16s
"Built on C" seems like the wrong phrase to me. "Extension of C" is a better
fit.

------
groovy2shoes

        > Kernighan and Richie's The C Programming Language is one
        > of most popular, if not the most popular, programming books,
        > and it defined the ANSI standard.
    

Wait, what? ANSI defined the ANSI standard, which had quite a few additions
from K&R C. It'd be more proper to say that the book defined C itself before
the publication of the standard.

------
deadwait
the subtitles on the interview are just amazing

------
primitur
I've been a professional C developer for 30 years. I've written C in
practically all spheres of application - in embedded firmware, drivers/OS
stack, userspace, web, &etc.

These days, I'm not writing so much C, but more heavily depending on the deep
understanding I have of how various layers of the whole stack of a computer,
running an application, work. How C works, what a compiler is doing with C
code, how to write good (and bad) C code .. all of this is a deep skill, still
applicable to understanding and debugging at the OS _and_ Application level.

The reason to learn C is this: there are a _lot_ of components of the modern
stack that are still composed of it. If you learn C, and know C, and can
comfortably produce reliable, rock-solid, working systems around a C
framework, then you will have exercised an ability that is, naturally, broadly
applicable throughout the computer world.

That is not to say that you should not make C your main language; moreso, use
other more advanced, more tailored languages as you see fit. But if you're
going to exercise the ability to freely shift over the whole stack, C is going
to be a mightier tool than most.

Re: giving K&R to newbies: it should be, give K&R plus "Expert C Programming -
Deep C Secrets" to newbies, and professionals alike. Together, those two easy
to read books will help you gain a fast grasp of how to write C programs, why
to write them in certain ways, and so on. I find K&R a great reference, but
Deep C Secrets a rather fun read; only have the latter on the crapper shelf in
the bathroom, for example. Plus, I _never_ get DeepCSecrets back when I loan
it to fellow coders (ever), so I have a few extra copies, too, to give to
newbies I work with. See:
([http://books.google.at/books/about/Expert_C_Programming.html...](http://books.google.at/books/about/Expert_C_Programming.html?id=4vm2xK3yn34C&redir_esc=y))

If you are learning C, and haven't heard of cscope, you can do no better than
get it set up, do the tutorial, learn how to use it as a tool. cscope is a
very capable text-based navigation/browsing tool, for large C code bases.
Unpack your favourite F/OSS application, fire up cscope on the root dir,
search for main, build a key word list, navigate freely. Bonus points: it has
superlative vim integration.

See: (<http://cscope.sourceforge.net/>) &
(<http://cscope.sourceforge.net/cscope_vim_tutorial.html>)

C will not fail you when most other languages might. There are times you may
realize, in fact, you are doing things that would be _easier_ in C, off in
Java and Haskell and Ruby land, ad&infinitum..

One last really, really good reason to learn C: Lua.

Lua kicks ass. Why? Because you can glom Lua into _any_ C code base, and give
yourself a much comfier language to do business/game/architecture code in,
while still having a fairly large degree of raw control over the C runtime
power, to boot. Master putting Lua into a small C lib collection, and you'll
see what I mean.

Learning to add Lua to a big code-base is like .. somehow .. a final
'delivery' of the whole 'write code once, run it everywhere' promise, albeit
its a developer mantra, not some CorporateOS-decides-to-bundle-your-
interpreter/runtime issue.

Anyway, just my two cents worth. Hope I still see new C coders being made in a
few more decades, eh ..

