Domain: tt2.org
Stories and comments across the archive that link to tt2.org.
Comments · 8
-
Parsing?
PHP, like all scripting languages, suffers from having to parse all script files each time a page is displayed.
Speak for yourself, PHP weenie. My Perl code is parsed and "compiled" only when I restart the FastCGI handler(s) for my Catalyst web app(s). My templates are (I'm sure) parsed on each invocation though. The situation is probably similar for other real scripting languages e.g Python and Ruby.
-
Re:Code in content, not content in code
I used to use Mason and it is a pretty good framework. But nowadays I've switched to Catalyst, a framework and set of libraries that make MVC pretty easy. It has the added bonus that it supports a number of web engines (e.g mod_perl 1 and 2, CGI, FastCGI, etc) while I've given up on getting my old Mason sites working with Apache 2. I like the use of TT2 as a template engine. It has a simple but powerful mini-language that helps enforce MVC seperation by not being a full-blown programming language. I think Mason almost encourages embedding of logic in content (like PHP) because it doesn't have a seperate templating language, always using Perl code. You have to be really disciplined to break your modules up into a MVC-like arrangement.
I'm not big developer, just a one-man experimenter and network admin for my family. As well as my own projects I've made a few little web apps for the family Linux web server. Catalyst just lays things out so well.
-
Re:Bad examples.
The MVC model simply won't work under mod_perl
Hmmm, you must be smoking something good. Whilst there are some things you can't do under mod_perl (realtime perhaps), MVC is not one of them. In fact, you have an enourmous amount of choice when it comes to mod_perl and MVC - mason, Apache::Template, PageKit, AxKit and so on. There are many other tools to help you with MVC, or you can roll your own if you've sufficient hubris to think that none of the existing stuff does its job.
Please try to research your rants a little better.
-Dom
-
Re:HTML as the starting pointKids like to do things. We don't program to learn how to program - I learnt because I wanted to write a game.
Today is where the web is at. So it's a good place for a kid to learn how to program.
In another post I suggested installing Perl (as simple as double clicking a downloaded file) and then installing the template toolkit from ppm (one command line command) as that gives kids a little tool with a very simple programming language that they can use to make a website....and then they can get onto something complicated as itself Perl later on.
-
Re:Why is PHP so bad?
1. Lack of seperation between content and logic.
This is one of the most common critiques of scripting languages like php and perl and I certainly agree that not seperating content and logic is a major problem for larges apps but I just realized that I don't actually know what the alternative is. Afterall, there are many ways to seperate content and logic in these languages (templating systems for example).
So, what are the alternative languages that natively support this seperation and how do the do it? -
Re:Readability?You don't need a split, or the Perl code. You can do it all in TT2 language:
[% noun = 'World';
See the Template Toolkit website for more information. The TT2 language is simple enough to be taught to semi-non-programmers, yet powerful enough to do some serious damage. And hey, Slashcode uses it!
USE date;
this_hour = date.format(date.now,'%H');
%]
Hello [% noun %],
[% IF this_hour < 12 %]
good morning
[% ELSE %]
good afternoon
[% END %] -
Re:Good point on PHPDomain specific languages are really good. They allow you to think more about the task at hand than the task of getting the language you are using to do the task.
Of course, one such example of a domain language is the Template Toolkit which is a language that's inside out and designed to be used in places like webpages and config scripts. It's used in Slashdot, and written in Perl (and can call perl routines really easily called.) There's a good justification why not to use pure Perl in the template in the manual
Of course, come Perl 6 we'll be able to redefine our own grammers. By using a module (technically a grammer) we'll be able to dynamically switch in anohter rule (er, perl 6 regex able to match grammers) in the current scope to parse the current section - essentially our own little mini langauge.
-
Re:As an alternative to Perl......You might want to look at some of the templating systems that are avalible. davorg mentioned The Template Toolkit in his review; This is a templating system that would allow you to use a very basic set of commands inline inside HTML to do simple looping and SQL stuff - and then to use pure Perl plugins (which you can easily write yourself) to get at the full power of Perl when you need it.
And yes, templating systems do scale. The code that runs this site uses the Template Toolkit - there's even a section in the Slash ORA book on it.