What alternatives are there to CGI?

user-pic

Wiki Extras for this post

Everyone knows that you can write web tools using Perl and CGI. Most folks know that there are web frameworks for Perl such as Catalyst that allow you to create large and complex web applications relatively easily.

Today I have a question for all you Perlers out there. What options does a Perl developer have if they need to develop a small amount of interactive code for a web site and they don't want to go all in for a complete web framework?

So if you are in need of only a handful of interactive responses for your site, or you work in an office with a CPAN hostile admin who balks at the dependency chains on some of the larger frameworks, what choices do you have?

Are there any options that are a bit better than CGI, but not quite as complex as a whole web framework? I know mod_perlite is on the horizon somewhere, but is there anything that you have heard of or are using now?

Sound off in the comments!

No TrackBacks

TrackBack URL: http://www.catalyzed.org/mt/mt-tb.fcgi/35

16 Comments

| Leave a comment

HTTP::Engine is worth a look. It works with a number of “interfaces” to suit your needs (CGI, FastCGI, POE, etc.), it’s quick to get up and running, and you get access to the basics you need — a request object for interrogating parameters, headers, and client data, and a response object for building your reply.

If deployment is the only issue, be aware that it's trivially easy to deploy Catalyst apps as CGI's :-)

Unless the sysadmin is really backwards in procedures, it's very reasonable and easy to ship an app deployed with local::lib and / or PAR. If things are so backwards, perhaps the problem isn't really a Perl one at all.

What about smaller footprint? What are your options for things that might normally get deployed as a CGI? If you want to avoid the fork, spawn perl, parse overhead on every request?

Jay

I'd recommend using FastCGI if you want to avoid the fork/spawn perl/parse loop. Both HTTP::Engine and Catalyst support FastCGI, but I expect HTTP::Engine hs a somewhat smaller module dependency footprint.

Of course this all depends on the experience of the involved people, but if someone just wants the "new way of CGI" I would point them towards CGI-Application. I have done both CGI-App and Catalyst jobs, and have migrated some apps from the former to the latter too.

If you design your application right and keep the actual domain and business implementations out of your web interface application, you should be fine in almost any situation.

For something like this I really do like using Squatting... a micro web framework inspired by Camping (on Ruby) written in less than 4K of code (http://search.cpan.org/dist/Squatting/).

Squatting is ideal for building small agile web apps quickly. It can be deployed on Continuity, CGI, HTTP::Engine, mod_perl & even Catalyst!

Also check out Continuity itself (http://search.cpan.org/dist/Continuity/) which Squatting runs on this by default.

In the recent 140 char web app challenge (http://f055.net/article/the-140-character-webapp-challenge/) I was very impressed with how little was needed to write a webapp.

For eg. Here is a simple adding calculator written in just 117 chars:

use Continuity;Continuity->new->loop;sub main{while(){$m+=$_[0]>print("$m")->next->param(‘m’)}}


Just run above thru perl and you have yourself a self contained web app.

/I3az/

I was using mod_perl even for quick things. Once you get passed the learning curve, it's pretty easy to handle.

But, I'm now engaged to HTTP::Engine.

(BTW, your OpenID login seems to be broken. It started looping between claimID - my provider - and your OpenID callback)

I would recommend Mojo: simple, you can run it as CGI or stanalone and upgrade to FastCGI later if you need to.

The basic install includes a small and practical MVC framework if you need that, Mojolicious.

The git version is more advanced than the current CPAN version, and the documentation is still low-quality, but the author has a TPF grant to improve it.

My experience has been with Mark Stosberg's Titanium framework(CGI::Application repackaged). It works well for small or medium sized apps running on in shared host or otherwise. It is quite simple and has plugins to integrate many common modules. He is currently working to get a 100% pure Perl implementation which makes things very easy for shared hosts.

I'd have to go with mod_perl as the quickest means for prototyping and playing around with concepts. A good understanding of apache is a prerequisite, but this knowledge is always useful anyway and should be a part of one's work experience.

I tend to use "raw" Mason for small things, just because I already have Apache and mod_perl configured, so using Mason as a simple in-line perl-thing is easy. More or less PHP with a sane language.

I also recommend Mojo. It is extremely lightweight (depending only on core modules and no xs or hidden magic, meaning you could just put it on your local lib dir and it should work fine) and can be integrated with FCGI/mod_perl with little effort.

From Mojo's own webpage:
Back in the early days of the web there was this wonderful Perl library called CGI.pm, many people only learned Perl because of it. It was simple enough to get started without knowing much about the language and powerful enough to keep you going, learning by doing was much fun. While most of the techniques used are outdated now, the idea behind it is not. Mojo is a new attempt at implementing this idea using state of the art technology.

Other than that, there's a pretty nice list with descriptions and comparisons over here:
http://mark.stosberg.com/blog/2008/11/startup-benchmarks-for-mojo-catalyst-titanium-httpengine-and-cgiapplication.html

Whatever you choose, have fun :)

Anyone care to do a comparison of Perl/CPAN/Catalyst with Php/Zend for the kinds of web apps both seem to be aimed at?

How about memory consumption of all these different choices? If your app is small/simple, but might end up being used quite heavily, the memory footprint of the framework itself might eat your application servers. Anyone done any comparisons?

don't forget PreFork!

Leave a comment

All comments are moderated. Spammers don't waste your time

Sponsored By


Ionzero: Rescue your dev project.

Following

Not following anyone

Note to spammers: all comments are moderated. Don't waste your time