Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

CGI/Perl vs. ASP

by nysus (Vicar)
on Mar 24, 2001 at 21:45 UTC ( #66875=perlmeditation: print w/replies, xml ) Need Help??

Ok, I'm probably throwing bloody meat to a pack of pirannahs, but I'm interested to hear thoughts on this debate...I'm a newbie. Please do your best to remain unbiased. :)

Replies are listed 'Best First'.
Re: CGI/Perl vs. ASP
by dws (Chancellor) on Mar 24, 2001 at 23:08 UTC
    A few thoughts...

    In Process vs. Out of Process

    ASP runs "in process" in the web server. It's dynamically bound in (by DLLs). ASP scripts, wether they are Visual Basic, JScript, or PerlScript, don't run as separate processes. Startup can be fairly fast, and session state can be maintained across invocations.

    CGIs, whether they be in Perl or in some other language, run in separate processes. They incur a per-invocation startup cost, and use the file system to cache session information between invocations.

    (Both ASP and CGI can "cache" session information in URLs and in hidden form fields.)

    If you're running Apache and control the web server, mod_perl is also an option. This allows Perl scripts to run in process, and is considerably more flexible than PerlScript on IIS.

    Language Choice

    Which of Visual Basic, JScript, or Perl is more flexible? All provide ready access to OLE components, though if this is how you're going to develop, the documentation is better for VB and JScript.

    If you're going to be doing any type of sophisticated parsing or string manipulation Perl is an obvious choice.

    If you're going to be doing any sophisticated page generation, consider also the facilities each language makes available, either directly or through readily available components. On the VB side there's... uh... On the Perl side there's CGI.pm and the Template Toolkit.

    And consider which language had the best choice of off-the-shelf componentry for reuse. The standard Perl distribution has a lot of useful stuff, and more is available from CPAN or PPM. Reusable stuff is available for VB, but not in the form of reusable objects (unless you consider instances of OLE things to be Objects).

    Development Considerations

    Which are easier to develop, ASP scripts or CGI scripts? Since CGI scripts are stand-alone, they can be developed and debugged in isolation from the web server, with minimal scaffolding. ASP scripts are rather more difficult to develop and debug. Visual Interdev helps somewhat, but judging from the howls of pain from my comrades several cubicles over, I'll stick with CGI as long as possible for development, and migrate into an in-process solution as late in the process as possible.

      Just to add to\clarify some things you said:

      • ActiveState has PerlEx and PerlIIS dlls - these run in-process like ASP, but the scripts you write for them are the same as standard CGI scripts written in Perl. So they are quicker, etc than perl.exe, but other than that - no difference.
      • Regular expressions (based on perlre) are available now for both VBScript and JScript.
      • You can write you own classes in VBScript so you can reuse objects without using OLE.

      I have sometimes used the PerlIIS dll for this because it's free and in-process. If you do this - don't forget to undef\close the objects you create or they'll hang around until you kill the webserver process.

      $ perldoc perldoc
        $code_or_die wrote:
        Regular expressions (based on perlre) are available now for both VBScript and JScript.
        I can't comment about Jscript because I haven't used it, but I have found serious issues with VBScript's regex engine. A regex as simple as "(\d+)(?:\.log)" has repeatedly failed for me because the lookahead keeps generating an "unknown quantifier" error with the lookahead's question mark. Since we're using VBScript 5 in my company, I should be able to use lookaheads.

        Plus, no one at my shop has been able to directly access the data captured by parentheses (i.e. with $1, $2, etc.). We've read through the documentation, but to no avail. I have to set the Regexp object to match globally and then loop through the "matches" property in the Regexp object to get to them. This has been consistent on all of our machines. Either this is poor documentation on Microsoft's part, or their regex engine is fundamentally broken.

        The result of this is that I have avoided regular expressions in VBScript and gone back to old ways of extracting data. Not fun!

        These are clearly bugs, but I'm not expecting MS to figure out what to do anytime soon. Consider the following quote from them where they try to explain what regexes are good for:

        For example, if you need to search an entire web site to remove some outdated material and replace some HTML formatting tags, you can use a regular expression to test each file to see if the material or the HTML formatting tags you are looking for exists in that file.
        As I well know due to my own painful forays into this area, regexes should not be used to parse HTML. It's one of the more common newbie errors with regexes (along with "how do I match an email address"?). Microsoft has - how astonishing! - taken a great idea, broken it, and then given bad advice on what to do with it.

        Cheers,
        Ovid

        Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

Re: CGI/Perl vs. ASP
by $code or die (Deacon) on Mar 24, 2001 at 22:30 UTC
    Ok, So I moved this to meditations because it didn't fit in the "Seekers of Perl Wisdom Category.

    On to your question - I have to say that I hate ASP! At my company, most people are familiar with ASP using VB script. Although people have started to get interested in Perl since I started, my current project is using ASP - and I'm writing it in PerlScript.

    Once I got my head around the difference between PerlScript and Perl, I am faced with the problem that all my code looks ugly. People complain that Perl code looks like line-noise, well PerlScript is terrible - code mixed with raw html, mixed with here docs, mixed with god know what else, it makes it difficult to reuse code and very difficult to document. Also my editor doesn't quite know how to color-code the syntax!

    However, there have been some benefits. In ASP with VBScript there is no built in sleep function. My colleague was going to install a component to do this, but I wrote him a nice bit of Perl that he can include in his scripts. Went something like this:
    <script language=PerlScript> sub wait_for { my $wait_for = shift; sleep $wait_for; } </script>
    The flip side of this is that I can also use functions that my colleagues write in VBScript.

    However, the whole way that ASP works seems backwards to me and makes maintaining and documenting code very difficult. I can't really speak about ASP with VBScript of JScript, but as far as PerlScript goes - it sucks. The only nice thing about ASP is the Session and Application Objects. But these can be implimented in straight Perl if you use the right modules.

    $ perldoc perldoc
Re (tilly) 1: CGI/Perl vs. ASP
by tilly (Archbishop) on Mar 25, 2001 at 02:34 UTC
    This is the wrong comparison, and anyone who is trying to sell you something based on this comparison is playing slimey games and should know it.

    CGI/Apache is comparable to and should be compared to CGI with IIS. Because process startup is so heavy on NT, IIS generally loses this.

    Now if you want to compare IIS running ASP with something, you should compare it with mod_perl. Performancewise if you have reasonable hardware you are limited by your connection to the internet, so performance is not an issue. Apache wins on stability, flexibility, portability, support and price. Which might just have something to do with why Apache is the market leader and IIS - despite having one heck of a marketing budget behind it - is not...

Re: CGI/Perl vs. ASP
by jlawrenc (Scribe) on Mar 25, 2001 at 21:21 UTC
    I have written ASP code in the past. Have also written VB objects that I used in ASP pages. Gotten results using ASP.

    I have write mod_perl code. Write perl modules that I in mod_perl. Get good results using mod_perl.

    For me, one big disticntion between the two is that my mod_perl environment is completely Open Source. My ASP environment was a mix of open and closed source. For some that is no big deal but for me OSS is my salvation and on that basis alone I will go the Perl-mod_perl-Apache route before I will go the ASP-IIS route ever again.

    The biggest disadvange that I see with the Perl-mod_perl-Apache route is that you will need to roll a number of your own pieces and strategies. Whereas the ASP/IIS world has already sorted out a few of the complicated details for you. Sessions come to mind. It is considerably more involved to set up effective session management on the Perl-mod_perl-Apache side than it is on IIS.

    The big plus to counter the implementation complexity is flexibility and the chance to understand EXACTLY what's being done and where it happens in the code. As someone who has to get a job done you have to choose which path is best for your situation.

    The one thing to consider is that going the OSS route may not only be better for you but I feel it is better for our society in general.

Re: CGI/Perl vs. ASP
by $CBAS (Scribe) on Mar 24, 2001 at 21:55 UTC
    Depends on what language you are using in your ASPages. (and what server, OS, hardware, coding skills, ...)
    There's no general answer and it is in fact a stupid question (did you even look at the title of this page?).
      nysus-- Well it isn't really a stupid question, rather, it's just a question that may not have needed to be asked... but that's ok!

      I have had experience with both Perl, and ASP, but judging from my personal experience, I would really shoot for Perl than ASP. My reasons are as follows:
      1. ASP is slower on a regular server generally than mod_perl at least if you are using it for the web.)
      2. ASP is a Microshaft created product ^_^.
      3. Perl has many other modules/functions already created than ASP does to my knowledge...
      4. Last but not least, it is based on visual basic, which is really old, because basic should have died a long time ago (with the commodores basically.) ^_^.


      Well there are some thoughts for ya!! Hope they help ya make a decision...

      Oh yeah, and I have a job in the summer coming up were I have to use ASP so I am very sad... maybe I can somehow have then restructure the system to use CGI/Perl instead!! ^_^

      bladx ~ ímuchas veces tengo preguntas!
        ASP is not a language.

        Saying that ASP is faster than Perl (or vice versa) is plain stupid because you're comparing a full-blown language (Perl) with a fileparser and scripting engine (ASP).
        A saner question would be Perl vs. ASP using VBScript and JScript vs. PHP vs. Java vs. ...
        In fact, you can even use PerlScript as your ASP scripting language of choice if you are running ActivePerl.
        Maybe you should know that ASP is in no way based on Visual Basic. And age has nothing to do with the quality of a language: Perl is largely based on C which was created in the '70s and was based upon B which was based upon BCPL. So saying Perl sucks because it's half a century old doesn't make much sense, Perl kicks ass! ;-)

        nysus: Perl has more attitude and can do a WHOLE lot more than just CGI.
        Microsoft has pulled up IIS's performance to a point where there's hardly any difference between ASP on IIS and Perl on Apache's mod_perl.
        I say go with Perl because it's so much easier to code (Interdev makes me sick) and you know a Perl coder is a good coder because (s)he doesn't need a WYSIWYG-like editor.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (9)
As of 2019-03-22 16:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How do you Carpe diem?





    Results (113 votes). Check out past polls.

    Notices?