On Saturday, December 29, 2012 4:47:36 PM UTC-5, Peter J. Holzer wrote:
> > I don't like that at all. If you use CGI, you shouldn't have any HTML
> > files -- all your HTML content should be generated by your CGI
> > scripts.
>
> Why?
There are probably more than four approaches to creating HTML, but I'll only mention four.
First, you can write HTML by hand using a text editor (vim, Notepad, and others). The advantage is that it gives you exact control over your code. Thedisadvantages include the requirement of being fairly proficient at HTML, CSS, JavaScript, etc., and that you only get static pages.
As a sub-category, this is where i would put PHP, ColdFusion, ASP, JSP, andsimilar. To me the key to these is that the author embeds scriptlets in his HTML code, the intention being to free the author from knowing anything about programming. To me, embedding scriptlets in HTML is pretty close to hand writing HTML in the first place, which is why I put it here.
Second, you can use something like Dreamweaver, or even (horrors!!!) Word, to create your pages. The advantage is that you don't need to know a lot about the languages. The disadvantages include giving up control over your code and only creating static pages.
Third, you can use a CMS or templating system or a framework. I've never done this so I don't know the advantages or disadvantages.
Fourth, you can create your HTML pages dynamically, with Perl, Python, Ruby, Java, all the way up to using C, Common Lisp, or something else. The mindset of this is that the author (programmer) writes code that outputs HTML. You still need to know HTML and in addition you need to know a programming language. The great (overwhelming) advantage is that you have all the powerof the programming language at your disposal. The difference between this and the first three is the difference between building your products one piece at a time, and building a factory that can automate the building of your products.
I started by writing HTML by hand. Then, I learned that you could use Perl to automate the tasks. I try my best to write in the functional style and write some pretty crude DSLs to help (e.g., a SQL.pm, an HTML.pm, a CONSOLE.pm, etc.) so my 'main' functions is just a series of function calls based on the query parameters passed on in the HTTP request.
It's actually quite easy in that you can build a very large website with not much code, and it turns out easy to maintain. This is how I imaging Amazon, eBay, and others do it. They OBVIOUSLY don't have a large team of authors hand coding each individual page that any user could conceivably request.
In short, I like the idea of building a factory to spit out HTML rather than handcrafting each HTML page individually.
CC.
----------rough example-----------
#! perl
use warnings;
use strict;
use CGI;
use HTML; #custom pm
my @query_params = param('query_params');
print "Content-type: text/html\n\n";
HTML

rint_header(@query_params);
HTML

rint_menu(@query_params); #top nav bar
HTML;print_content(@query_params);
HTML

rint_menu(@query_params); #bottom nav bar
HTML

rint_footer(@query_params);
exit(0);