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

Hello fellow monks,

i wondered if the "reinventing-the-wheel" approach (classic example: templates) hasn't a valid point somewhere.

Speaking for myself i grasb new concepts quickest when trying to implement them on my own. It gives me a better understanding on how it works and why certain things are implemented the way the are. I guess i inherited that approach back from school where we first had to write our own sort functions and such before we were allowed to use existing and well tested functions for sorting.

So my point on "reinventing-the-wheel" is that it is useful when used as a learning tool. Use it to get a feel for the class of problems you are trying to solve and then switch to more tested and sophisticated modules to get the actually work done.

I apologize for my english, i think it's a bit rusted and i hope you all understand what i mean ;-)

--
"WHAT CAN THE HARVEST HOPE FOR IF NOT THE CARE OF THE REAPER MAN"
-- Terry Pratchett, "Reaper Man"

  • Comment on Learning methods (valid use for reinventing the wheel?)

Replies are listed 'Best First'.
Re: Learning methods (valid use for reinventing the wheel?)
by liz (Monsignor) on Oct 10, 2003 at 10:00 UTC
    ...then switch to more tested and sophisticated modules...

    As long as you do that: know about more sophisticated modules and use them when appropriate, then I think inventing the wheel again is ok. Always keep in mind that it is a training excercise for yourself.

    It's just that too many people don't know about the existing wheels. And think their wheel is the best. So we get stuck with a lot of different wheels that are more or less round. Mostly less ;-(

    People who don't know history, are doomed to repeat it.

    Liz

Re: Learning methods (valid use for reinventing the wheel?)
by hardburn (Abbot) on Oct 10, 2003 at 14:04 UTC

    Sure, I've done that a lot. When learning some crypto, I used to pick a random algorithm out of "Applied Cryptography" and implement it. There was certainly more efficent versions of the algorithm out there than what I came up with, and some of the algorithms I used were completely broken, but I like to think I learned a little something. Not that any of that code should ever find its way into a real application.

    ----
    I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
    -- Schemer

    Note: All code is untested, unless otherwise stated

Re: Learning methods (valid use for reinventing the wheel?)
by perrin (Chancellor) on Oct 10, 2003 at 18:06 UTC
    Go for it. My appreciation for today's good templating modules is at least partly from my experience trying to maintain my own and seeing how quickly it becomes a nightmare.

    Complaints about reinventing the wheel mostly have to do with people who are wasting time on paid projects by doing unecessary work, and people who are contributing to the clutter on CPAN by uploading more and more nearly identical templating modules. (Incidentally, there have been a slew of new and pointless template modules showing up recently.)

Re: Learning methods (valid use for reinventing the wheel?)
by chromatic (Archbishop) on Oct 10, 2003 at 20:29 UTC

    I wonder how many people who've written their own CGI form parsers (for example) have read the relevant RFCs. I have the impression (rightly or wrongly) that many of the people who try to teach themselves a subject do a very half-hearted job by stumbling along with a very limited solution.

Re: Learning methods (valid use for reinventing the wheel?)
by Anonymous Monk on Oct 10, 2003 at 16:38 UTC

    Yes it does. Rewriting existing code is an excellent way to learn. Just don't use it in production until it's been thoroughly tested and you're sure of its quality.

    Most people's objections to reinventing the wheel are that 1. your code will suck 2. you won't be creating anything new and useful and 3. they're just regurgitating a common misconception because they want to feel smart. As for one, see the above paragraph. As for 2, you have to learn before you can contribute. So definately go for it.

Re: Learning methods (valid use for reinventing the wheel?)
by Abigail-II (Bishop) on Oct 10, 2003 at 10:10 UTC
    Speaking for myself i grasb new concepts quickest when trying to implement them on my own.
    Could you make your implementation of Perl from when you were grasping the language available?

    Abigail

      Different people pick up things differently. Educational research has shown that.
      • Some people learn by doing.
      • Some people learn by reading about it once.
      • Some people learn by reading it over and over again.
      • Some people learn by example.

      Most people use a combination of the above in different situations, depending on how "at home" they are in the material they're trying to grasp. Obviously most people wouldn't even think of re-implementing Perl when they're trying to get to grips with the language in the first place.

      But I guess sometimes, just sometimes a bright person comes along and does just that. Then it's up to the rest of the world to judge whether it is any good or not.

      Liz

        My point is that learning to use something by implementing it yourself only works in a limited amount of cases. Only if reimplementation takes about the same effort as learning it in another way, it's efficient enough to do. So, it works for simple, small things, like most of the CPAN modules. But it's rather inefficient for things like Tk, perl, relational databases, operating systems, driving a car, learning a language or operating a television. And sometimes, it's even impossible. Surgeons don't learn their trade by reinventing the human heart.

        I'd say that when it's efficient to learn something by implementing it yourself is relatively rare.

        Abigail

      You mean trying to write an own version of perl as part of trying to learn it? No i guess not.

      I dont think that the wheel approach is something that worky everywhere and everytime, but it worked for me on several occasions and helped me to understand things more quickly and clearly. It has his limitations as has each learning technique and i guess it mostly depends on the personal learning style of a person.

      --
      "WHAT CAN THE HARVEST HOPE FOR IF NOT THE CARE OF THE REAPER MAN"
      -- Terry Pratchett, "Reaper Man"