Fellow Monks...

    I find it nessecary now to write this; I know how when someone knows more about something, his advice is very precise, and because he has been into that road before, he knows what's the easiest and righteous way to do things.

    It seems that every Monk here with a high enough rank advices all the beginners of using pre-made modules, and everyone is against manual coding when there is already a module that solves all the problem.

    If you are like me, I never use anything without knowing how it works.. and whenever some beginner asks for wisdom about a way for doing something, he is directly (often) advised to use that certain module... If someone wants a script that does a very simple task that could go with 10 to 20 lines of code, why load a module??

    for what I do... I prefer to learn how to do stuff... before I use a pre-made module.. if not.. how could I ever learn to maybe one day make a module of my own...

    my question here is : Is everybody against manual coding for small tasks??? or does at least someone agree with me that it's a good way to learn?


Chady | http://chady.net/

Replies are listed 'Best First'.
Re: Modules Vs. Manual Coding
by lemming (Priest) on Jan 15, 2001 at 20:33 UTC

      Not a whole thread, but this sums up my feelings on the matter fairly well: (tye)Re2: 'Tailing' a File?

      There is no black and white. Using modules is very often a good idea. Reading the source code for modules can be a faster way to learn than trying to reinvent them. Installing modules can be a huge pain. But asking for a solution that uses no modules raises a red flag to me as many modules are as easy to install as whatever you might rewrite the module as.

              - tye (but my friends call me "Tye")
Re: Modules Vs. Manual Coding
by Fastolfe (Vicar) on Jan 15, 2001 at 20:27 UTC
    Generally what makes a small task is the use of a pre-written module to do it. Consider LWP::Simple and get as a fine example.

    If you're interested in figuring out how to do a certain task for which a module already exists, I still recommend the module, because with the module you can always look at the code and see how it's done. :)

    But I agree that in some cases the robustness of a module to do the job of parsing out one little tidbit of text might not be necessary, in cases where you can guarantee the input and a one-line index or regex would do the job. In that case, go for it. But if your input ever strays in the future, and you find yourself trying for hours to nail down the bug in your script, you may wish you had used the module in the first place when you finally do discover the problem.

Re: Modules Vs. Manual Coding
by chipmunk (Parson) on Jan 15, 2001 at 20:30 UTC
    If you are like me, I never use anything without knowing how it works..

    Then I have a simple question for you. Do you know how Perl works?

    ;)

Re: Modules Vs. Manual Coding
by extremely (Priest) on Jan 15, 2001 at 20:47 UTC
    If someone wants a script that does a very simple task that could go with 10 to 20 lines of code, why load a module??

    Because, in general, they aren't asking for a 10 or 20 line script. They are STARTING with a 10 or 20 line script. The 2-4 line script with a module generally puts them on the road to doing what they really want, shorter, safer, and already working.

    And no, I don't think that stumbling around in the dark is a good way to get the feel for the layout of a house, turn the lights on and look around. You will learn more seeing how it is done right than you will stabbing about.

    --
    $you = new YOU;
    honk() if $you->love(perl)

Re: Modules Vs. Manual Coding
by ichimunki (Priest) on Jan 15, 2001 at 21:54 UTC

    66% or more of the module recommendations on PM seem to be for modules that are INCLUDED with a perl distribution. Not using core modules is as silly as not using the built-in operators and functions. Sure, eventually you may want/need to overload them or subclass, or even plain rewrite them, but we usually learn to color inside the lines before we get to color theory.

    Good programming results from good habits. One important good habit in most scientific disciplines is to know and understand the current state of the art. Most Seekers at PM who are given "use the module" advice have not demonstrated that they are up to speed on the state of the art (not their fault! they are good people going through the learning process!). If they were completely up to speed, they would ask questions like: "I've been using the CGI module, but it completely lacks sensible validation procedures for HTML4, so I wrote the following mods. Now why does line XX generate an error?".

Re: Modules Vs. Manual Coding
by chromatic (Archbishop) on Jan 15, 2001 at 23:14 UTC
    The problem is, what is a "small task"? Retrieving a web page? Parsing CGI input?

    For certain domains (and here I speak mostly of interacting with Internet services and protocols like HTTP and SMTP), the sheer amount of information you need to know to start writing your own module is staggering.

    On the other hand, there are a lot of modules on the CPAN that a decent coder could reimplement by reading the documentation.

    The trick is telling the difference. There's nothing wrong with taking things apart to figure out how they work or trying to reimplement something. But for certain classes of tasks, the odds of any of us getting things Right on the first few tries is staggeringly low. (That's part of the reasoning behind the CPAN testers, and CPANTS, if it's still around.)

Re: Modules Vs. Manual Coding
by mrmick (Curate) on Jan 15, 2001 at 20:33 UTC
    I don't think anyone is against writing code at all.

    More to the point, we (big assumption) advocate laziness for the sake of efficiency and speed.

    If one asks "How do I do this?" , then the reply will include directing the one who asked to a module if it seems to be a solution. Modules were written to make our lives easier. Nobody discourages one from making their own solution to understand how things work.

    Remember though, you don't have to know the inner workings of an interface / module in order to use it. Just read the documentation and look at some examples to see if it's what you need.

    Mick
Re: Modules Vs. Manual Coding
by coreolyn (Parson) on Jan 15, 2001 at 21:43 UTC
    I agree with what everyone has said here, and after taking the road less followed (i.e., not using modules) I can confirm this is an ugly dead end in a dark alley.

    In other languages I would tend to agree that it's a good way to learn, but the deeper I get into Perl the more I realize it is the nuance and subtleties of Perl that make it viable. Without this knowlege Perl is just a bulky advanced shell. I'm beginning to see that the modules hold as much to learning Perl as the books.

    It will take you twice as long to learn Perl discovering it through your own code then it will understanding CPAN modules. Furthermore you will end up throwing out all of your code and starting over just a short way down the Perl road from where you are now. Besides, coding in a way that you and others can reuse it is where the real future of coding in any language is now.

    Learning to code some silly 20 line script in a way that it could be reused is learning Perl. Unlike other languages Perl is constant discovery. If you were to venture into a wilderness and there was a map from a previous explorer would you learn more by adventuring without that map?

    coreolyn

Re: Modules Vs. Manual Coding
by clemburg (Curate) on Jan 15, 2001 at 23:02 UTC

    If you are like me, I never use anything without knowing how it works.

    ROTFL ... wow, that one was good.

    You use cars, phones, microwaves, computers, etc.? You understand all that?

    Wow. Hey Mom, I found a genius today! Yes, it was on perlmonks ...

    Sorry if I sound too sarcastic here but this stuff always gets me ... those people do not have any idea on how many shoulders they stand ... I hope that I have a faint idea of how little I know.

    Christian Lemburg
    Brainbench MVP for Perl
    http://www.brainbench.com

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Modules Vs. Manual Coding
by el-moe (Scribe) on Jan 18, 2001 at 00:31 UTC
    To relate this to another language...

    Question: How many C programmers rewrite functions available in the standard libraries?
    Answer: None.

    Just thought I could add a different perspective.

    Prost,
    Moe

Re: Modules Vs. Manual Coding
by jdgamache (Novice) on Jan 17, 2001 at 02:12 UTC
    ahhh... dont forget the 3 perl virtues... one of them is laziness ;) A perl script doesnt need to be fast, just do the job. You can always open a module before using it.... ah open source ;)
Re: Modules Vs. Manual Coding
by Anonymous Monk on Jan 17, 2001 at 04:07 UTC
    One of Perl's biggest strengths is the reach and depth of the modules that come with Perl/available on CPAN.

    I prefer to use modules as much as possible for several reasons:

    • I don't have time to reinvent the wheel
    • I don't know as much about the problem as the module author
    • I am not as good a programmer as the module author
    • I'd rather work in an engineering mindset than an artisan mindset

    Even in small tasks I try to make use of modules as much as possible.

    For example, you can use a regex to break a filename out of a *nix path. But if you use File::Basename, your code now can handle Win32, MacOS, VMS, and AmigaOS pathnames.

    That's a good thing when need to run a Perl based utility on several OSes.

Re: Modules Vs. Manual Coding
by Chady (Priest) on Jan 16, 2001 at 01:13 UTC
    Guys I'm not against using Modules, as a matter of fact, I use them all the time... but doesn't it give you a certain joy when you code something right.. and it's all your coding?

    I would love to reply to all of you, but I got most of the attitudes I needed...
    P.S. nice one chipmunk


    Chady | http://chady.net/
      You know, if you needed attitude you should have said. =) If there is one thing we have here in greater abundance than opinion and fact, it must be attitude!

      I guess that most of us love the feel of writing something all our own. It is just that we feel that using modules doesn't impact that. I'd rather write something truly new than rewrite a shallow copy of something already done.

      --
      $you = new YOU;
      honk() if $you->love(perl)