Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Answer: what is the best way to learn to program?

by mstone (Deacon)
on Dec 18, 2001 at 06:18 UTC ( #132765=categorized answer: print w/replies, xml ) Need Help??

Q&A > object-oriented programming > what is the best way to learn to program? - Answer contributed by mstone

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 Want to understand data structures? Read Want to test the limits of your sanity? Read ;-)

Seriously, read the libaries. I try to go through the whole batch at least once every year. And I learn something new every time.


  • Comment on Answer: what is the best way to learn to program?
Log In?

What's my password?
Create A New User
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2018-06-18 02:15 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (107 votes). Check out past polls.