in reply to A quick and dirty template system

Please, do.

True, it is a common rite of passage. True, there are dozens available on CPAN, true, you should study those. Odds are you're not going to beat something like Text::Template

But false, writing your own is not a waste of time. It's a great way to focus on the issues involved in what a template system should do and on what you really want it to do.

I don't think there is any substitute for learning by doing. Studying the derivation of Fermi's Golden Rule #2* is, speaking from direct experience, far less enlightening than closing the book and deriving it starting from a blank sheet of paper.

All, IMHO, of course.

scott

* Roughly, Fermi's Golden Rule #2 is a general expression for the transition rate of a quantum system, per unit time, from some initial state to some final state, where the situation is complicated enough to require being modeled as a perturbation of some more simple situation. Got all that? Pop quiz tomorrow. :)

Replies are listed 'Best First'.
Re: Re: A quick and dirty template system
by merlyn (Sage) on Sep 20, 2001 at 00:36 UTC
    I don't think there is any substitute for learning by doing. Studying the derivation of Fermi's Golden Rule #2* is, speaking from direct experience, far less enlightening than closing the book and deriving it starting from a blank sheet of paper.
    And part of learning is studying prior art, which is apparently lacking in practically all of the "templating systems" I've seen.

    Listen, I really wouldn't mind someone saying "I've studied Template, and Text::Template and HTML::Template and Text::MetaText and the PerlFAQ entries and ..., and now I want to write my own, because this feature is lacking and that feature is broken". But nobody has ever done that that posts "here's my templating system, and it's simple for now, but I'm adding $FEATURE_X later". They just go off and start implementing. You think Perl would have been where it is had Larry not carefully studied Awk and Sed and other tools before he started?

    This is why I grumble about reinvention, and templating systems in particular. Do not attempt to reinvent the wheel without studying the fallacies of those who have gone ahead, or else you are wasting human potential in a larger sense. This isn't just about you. It's about humanity.

    -- Randal L. Schwartz, Perl hacker

      Do not attempt to reinvent the wheel without studying the fallacies of those who have gone ahead,

      or, as i like to say, "Don't reinvent the wheel unless you're going to make it round."

      .

      And part of learning is studying prior art ...

      Sure. I think that was implicit in my example.

      ... "here's my templating system, and it's simple for now, but I'm adding $FEATURE_X later". They just go off and start implementing. ... Do not attempt to reinvent the wheel without studying the fallacies of those who have gone ahead, or else you are wasting human potential in a larger sense. This isn't just about you. It's about humanity.

      I think we're talking about multiple issues while treating them as one. Writing your own first-order templating system and then posting it madly across the world is certainly a waste of time for everyone. If you thought 36 to choose from was bad, consider if all the templating systems ever designed were enshrined in CPAN. There'd be 360,000 of them. This is obviously not good. It's the treating of what is essentially a learning script as something of value to the community that's a bad idea. Putting anything that doesn't deserve it on CPAN, etc. is bad and does indeed 'waste human potential'.

      This does not mean that the effort that went into the creation of templating system #361,054 was in any way wasted. Reinventing the wheel is good for the understanding of the reinventor and far from a waste of anything, assuming the job was done as a learning experience.

      So I agree and disagree with you. Yes, don't post your templating system please (unless it's better than the competitors)! We've got enough. But no, don't not write your own. By all means, write it ... if you write it as a learning experience, as a way to understand what a templating system is like, as a way to experiment with code that runs code (like TT2), as a way to experiment with an easily understood problem that can be implemented in varying degrees of depth and sophistication.

      On a more philosophical note, since you started talking about all humanity, excessive study of that which has gone before can diminish creativity as well as increase it. Certainly, one learns many hard wrought lessons much easier that the original learners. But one also comes to be infected with their world views. It is not always possible to know what is good practise and what is thought to be good practise, especially when one isn't very practised oneself.

      One should strike a balance between paying attention to the vast body of collected knowledge and generating one's own. A great deal of the collected wisdom of the ages is wrong - for the obligatory example I give you the Great Fluxion/Infinitessimal Debate, which was thought to be settled by Bishop Berkeley in the 16th(?) century. Turns out he was wrong and it took until 1960-something to demonstrate. Up until that time 'those in the know' were quite convinced he was right.

      scott
      -----------------------------------------------------
      Do not depend on Eternal Mathematical Verities for your foundations. They change.

      P.S. Wow! My first negative-point post! Cool!