|There's more than one way to do things|
Answer: what is the best way to learn to program?by mstone (Deacon)
|on Dec 18, 2001 at 06:18 UTC||Need Help??|
Start by learning to read code.
One of my cynical canned rants deals with the idea that programmers are people who know how to write, but don't know how to read. When I'm especially grumpy, I say that most programmers don't even know how to write code.. they just engage in partially-directed genetic algorithm development, with the compiler and test code telling them whether the latest random twiddle will work.
You can actually get a lot of value out of retyping a program that somebody else wrote. Just the act of pounding those statements into the keyboard in the correct order gives you space to think about what's going on, and what the original programmer was thinking.
If you keep at it, you'll learn to recognize various concepts, which will give you the basis you need to discover even more. Eventually, you start to recognize personality traits of the programmer who wrote the code.. this one's an optimist, that one's a pessimist, this one builds structure by the numbers, that one lets it evolve like jazz. And as you expose yourself to acres of code written by people who've already developed a style, your own will evolve, almost by osmosis.
Existing code also gives you a starting point where everything works. There are few things more frustrating than slogging through umpty-seven permutations of code because the documentation was written for somebody who already knows how to make everything work. Start with what works, so you can go back and get that little fix of success when you need it. Swear to God, when I'm deep in the guts of some problem that isn't ready to get up and limp yet, I'll write "hello, world." programs to keep myself from going nuts.
And as it happens, Perl comes with a whole library of code that you can read, copy, and play with. Want to understand namespaces? Read Exporter.pm. Want to understand data structures? Read Symbol.pm. Want to test the limits of your sanity? Read CGI.pm. ;-)
Seriously, read the libaries. I try to go through the whole batch at least once every year. And I learn something new every time.