http://www.perlmonks.org?node_id=7121

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question: (object-oriented programming)

I have allways loved the idea of being able to make my own programs istead of the bug infested ones that other companies make.
I have asked many people and noone will help me.
Radioactivetodd

Originally posted as a Categorized Question.

Replies are listed 'Best First'.
Re: what is the best way to learn to program?
by btrott (Parson) on Apr 07, 2000 at 20:23 UTC
    I agree generally with chromatic's answer, although "just sitting down and programming" could, I think, seem like a relatively daunting task for someone who's never programmed at all. :)

    I came in to Perl already quite familiar with C++, so from that perspective I already learned a lot of the basics of programming; the sort of concepts that can apply to any language. If you're not familiar with those, I suspect it's a bit more difficult to just sit down and learn a new language *and* how to program, in general.

    I think I'd recommend a beginning programmer's book, such as Elements of Programming with Perl. From there you can learn the basics, and once you've learned those, I agree completely with chromatic: learn new things by finding problems you want to solve, and jump right into solving them. Don't be afraid to look at other code (but try to find good code, not code that hasn't been touched since Perl 4 was in its heyday). One source for good code, I think, is Randal Schwartz's Web Techniques column. Practical, applied uses of Perl. Start with the first few, then work up to the later (more complicated) scripts. The Unix Review columns are good too.

Re: what is the best way to learn to program?
by chromatic (Archbishop) on Apr 07, 2000 at 19:01 UTC
    The way I learned to program was by sitting down and programming. Seriously.

    One thing that helped me was typing in a short program from a book or a magazine, and then changing it to add features or do different things. If you start with a well-designed program and keep it up, pretty soon you'll absorb good programming.

    That said, there are a couple of good books from O'Reilly and Manning Press that I would recommend. Learning Perl is one, and Elements of Programming with Perl is another. (The latter is my preference, as it teaches both Perl and programming.)

    Also, Perl comes with a load of good documentation, available by typing 'perldoc perldoc' right at the command line. You can learn most of the language from there (but much of it assumes you're already fairly familiar with programming in general)

Re: what is the best way to learn to program?
by little_mistress (Monk) on Apr 08, 2000 at 04:53 UTC
    I think they both gave very good answers, but there is another thing that you want to think about What do you want to make? Some sort of project. Its onething to have a tool box full of tools, its quite another to have something that you want to make that is within your skill level.

    The first thing i made was a multi-user webpage editing system that was modled conceptually after a newspaper with an "owner", "editors", "sections", "staff-writers", etc. It took me months! now i could probably do it in about 3-5 days.

    Aside from the technical part, think about what you want to make. Have a goal, a project. Maybe you could write some customized commands for your shell, or some nifty little cgi thingy that gets a random line from the unix fortune program and puts a different one into a webpage for each visitor. Think of something fun, interesting, and useful. Then the actual "learning" part will be simple. Otherwise you just have a hammer and nails and nothing to build.

Re: what is the best way to learn to program?
by mstone (Deacon) on Dec 18, 2001 at 06:18 UTC

    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.

    mike
    .

Re: what is the best way to learn to program?
by Studdly (Monk) on Apr 20, 2000 at 07:57 UTC
    Generally, I find that the easiest way of learning a new language, assuming you have at least some programming experience, is to follow these three easy steps:

    1. Find a good website (like this one) with tutorials and examples and such.
    2. Find a few relatively simple programs, and try to duplicate them.
    3. If at all possible, try to find someone (a friend, relative, co-worker, etc.) who can walk you through your first few attempts.

    These things seem to work pretty well for me; I hope they help.

    -SYP

Re: what is the best way to learn to program?
by SoftTerrier (Initiate) on Dec 05, 2002 at 18:51 UTC
    To program, to program and to program... You can wrap into the loop these words.