Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Language Recommendations 1

Status
Not open for further replies.

philote

MIS
Oct 2, 2003
861
US
I was wondering what the pros/cons of the various cgi programming languages are? Like what flexibility the various languages allow, ease of coding and design, speed, setup, database accessibility, etc.

I've been using Perl with MySQL on Linux which has worked quite well, but design and maintenance of larger applications is difficult. I thought maybe JSP's would be easier to design and code due to their more object oriented-ness. But is it just as easy to use JSP's to track sessions, access databases, etc. as it is in Perl? And should I even consider ASP's or PHP?

 
I use mod_perl on a variety of fairly large applications (multi-million hits per day) and have been doing so since '98 or so.

Mod_perl is a great system to work with.
 
Look at the CGI::Application module for making your larger projects more maintainable. It's a nice framework built around CGI, CGI::Session, HTML::Template, and DBI. It breaks a project up into "run modes" which are really just use cases (makes design cleaner). Combine it with mod_perl and you should be set.

________________________________________
Andrew - Perl Monkey
 
If we are recommended app environments let me plug HTML::Mason. it runs in mod_perl and CGI mode and I just love it :)
 
Thanks for the advice. I've looked at CGI::Applcation before and it's probably something I'll start using. This is the first time I've heard of HTML::Mason; it looks extremely helpful as well. Now, can the two be used together successfully?

 
Dunno why you would want to, they are redundant. Different ways of skinning the same cat.
 
Ok, thanks. I guess I didn't read enough of the docs. But I went back and read a little more and it looks like I wouldn't need the CGI module either.

What's the best way to handle sessions if I use HTML::Mason? Apache::Session?

 
I used to use Apache::Session

Now I use MasonX::Request::WithApacheSession

Same thing for the most part, MasonX is a bit more tightly integrated and allows for easy configuration via httpd.conf with no special startup scripts
 
I've started on my first app using Mason and have only hit one snag so far. My text editor will color keywords and such for Perl and HTML, but not both at once[sad]. So I have to either choose HTML or Perl, and the other will be colored wrong. Oh well. Mason's seems great though. The online docs are more than enough, plus I found which also has tons of info and walks through a real web site created with Mason.

Siberian, any tips you want to send my way would be appreciated. Like I said, I've just gotten Mason installed and have just written my first couple of components. One question I have so far is should I connect to databases in the autohandler and have the database handle be global so components have access to it? Or should I just have the component that needs the database do the connecting? Or does it really matter with a smaller website and only one or two db queries per page?

And would the Perl forum be best to ask these questions in?
 
Perl forum is probably more approriate.

What I do for db connections is have a module, Utility.pm and a library called Config.pm

Then in my libraries I do things like

use Config.pm ;
use Utility.pm ;
my $Config = Config::get_config();
my $dbh = Utility::get_dbh(Config=>$Config);


NOTE: You should never be doing logic in components, a component should handle display of data only generally speaking. If you start doing logic and db stuff in components you will have severe maintenance issues at a later date.

Many will not agree but I have written at least 8 large mason projects (million+requests a day on some) with tens of thousands of lines of code and have found this to be true. The more abstracted your logic is the better off you are.

Regardless of how you do it, have a single dbh get function, mod_perl will cache that for you. If you are running in CGI mode have the primary CGI handler call the function and pass the dbh to subsequent library calls. This will dramatically reduce maintenance later.

Keep on asking those mason questions, mason is fun :)

 
Great, thanks for the advice!

I can tell mason will be alot of fun, and I'm sure I'll have many many more questions to ask so look for me in the Perl forum. ;-)

Right now I'm going to learn more about creating perl libraries so I can follow your suggestion.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top