Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: Embeding Perl in HTML the PHP way

by davido (Archbishop)
on Sep 11, 2012 at 19:58 UTC ( #993052=note: print w/ replies, xml ) Need Help??


in reply to Re: Embeding Perl in HTML the PHP way
in thread Embeding Perl in HTML the PHP way

Separation of concerns (the Model, View, Controller) approach is, of course, the primary goal of all of the modern frameworks (including Catalyst, Dancer, and Mojolicious, as well as those popular in other languages). And I agree that the notion of embedding the bulk of an application in the HTML (ie, in the template) is the wrong way to go. But I think you're taking it a little far when you say:

If you are still "embedding programming_language into HTML," then I cordially advise you that you should re-consider that approach.

Surely you must mean that the application's business logic should reside in "model" code, the web application's minimal wiring should exist in "controller" code, and the view should reside in the templates, wherein embedded logic is kept to the minimum required, no more, and no less (which is different from reconsidering the concept of embedding altogether).

Maybe it would help me to understand the line you're drawing if it were accompanied with an example.


Dave


Comment on Re^2: Embeding Perl in HTML the PHP way
Re^3: Embeding Perl in HTML the PHP way
by sundialsvc4 (Monsignor) on Sep 12, 2012 at 00:05 UTC

    Sure, Dave.   What I am referring to is the original concept that a PHP file would consist of HTML code with <?..php code here..?> tags stuck all through it.   For instance, if you wanted to generate an HTML table, you literally enclosed the <tr> tags and so-forth inside of an inline PHP loop.   The idea was that the output would consist of the un-bracketed (HTML) content interspersed with the output that may be produced by any PHP code wherever it appeared.   There was (by design, actually), no separation between the two.

    That turned out to be a really bad idea, and the PHP community quickly moved away from it to adopt MVC strategies that are in many ways quite similar to what one now sees being done in Perl, et al.   The language itself also sprouted many new features, including many similarities to Perl and an openly-acknowledged copy of its regex technology.   I guess good word spreads fast... ;-)   Plus, the Zend folks include some really crackerjack coders.   PHP now does MVC along with the best of them, but the language emphatically didn’t start out that way.   (But hey, it sure seemed like a perfectly good idea at the time ...)

      I think you're being awfully generous in suggesting that "the PHP community" has moved away from the everything-in-one-file method. Outside of some big projects like Drupal and work being done by some elite coders, I think most PHP scripts still mash it all together. From what I see, although there are still plenty of CGI/HTML scripts out there, Perl is way ahead in that regard.

      That ability to toss a little code into an HTML file is what made PHP popular, after all. You didn't have to deal with file permissions or any of the stuff that made CGIs tricky at times; just stick your code in the page. That method makes large projects nearly impossible -- systems like Drupal and Wordpress are a mess, even with separation of code and layout -- but it makes the quick-and-dirty stuff quick. Take that away, and you're left with what, about a thousand inconsistently named functions?

      Aaron B.
      Available for small or large Perl jobs; see my home node.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://993052]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2014-08-02 03:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (54 votes), past polls