On Thu, 30 May 2013 16:27:05 -0700 (PDT), ccc31807 <
cart...@gmail.com> wrote:
> One thing I have learned about learning programming languages -- you
> don't learn a language by reading a book, althought it helps, nor by
> watching someone else do it, nor by talking to people abouty it. You
> learn it by doimg it.
Amen to that! If there was /one/ thing I would add to this it would
/have/ to be this:
: Reading source code in that language helps you assimilate the common
: patterns and practices of the people who use it for real work. So go
: and read a program in that language and try to understand *all* of it.
: Then read a larger one. Then keep doing that as you write your own.
Back in 1994, I had a C instructor at one of the Greek Universities who
diverged from the common practice of assigning "toy tasks" to us in the
new language. His assignment to us before the Christmas break was:
"Find an open source program that's written in C, whose source
code includes at least 10000 lines of code. Your task is to
read all of it, and understand how all the parts fit together,
what it does, and how it goes about it. Be prepared to be shown
a random file, scroll down a random number of lines, and answer
questions like: 'What is this part of code about? How does it
work? Why does it work this way?' and so on."
I naively chose the GNU ed(1) editor, thinking along the lines of "What
the heck... it's a *line* editor. How complicated can it be?". Then I
bumped into the regexp matching and replacement engine that is standard
in ed(1) implementations. You can imagine my initial horror when I
realized I was about to learn not only how to use regular expressions,
but also how they are *implemented*.
I braced myself for long reading sessions, and sat down in front of a
printed copy of the entire source code, in 8pt Courier, two pages per
sheet of A4 paper, and started reading, taking notes on the paper copy,
and filling notebooks with extra stuff that wouldn't fit in the margins.
When I returned from the Christmas break, I had gained an immense amount
of useful knowledge, not only about the C language itself but also about
many other extreely important things. I knew how to read source code; I
knew how to mentally keep track of what the source is supposed to do,
what parts link with other parts of the source; how to structure a
medium-size, working C program in a modular fashion, etc. Quite
importantly, I felt *much* *more* *confident* in my grasp of the
language.
This is still the best project in C I've *ever* done myself, and it is
something I keep doing on my own when I have to learn a new language.