perl-advocacy_stas_bekman_answers_the_c_or_perl_argument_with_the_obvious_both_1619

This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.







Newsgroups: perl.advocacy
Date: Sun, 16 Dec 2001 00:25:21 +0800
To: modperl list <modperl[at]apache.org>
Cc: advocacy[at]perl.org
Subject: Re: modperl vs. C
From: stas[at]stason.org (Stas Bekman)


[Crossposting modperl list, since Jeff Yoak sent his question to both
lists, and I'd rather answer once :)]

Ask Bjoern Hansen wrote:

 > jeff@yoak.com (Jeff Yoak) writes:
 >
 > [C vs mod_perl for web applications]
 >
 >>with something I've done, and a client's investor who is blowing a
gasket
 >>because of the opinion that using mod_perl is a completely psychotic
choice
 >>for a website that is going to experience high traffic.  I'm in the
process
 >>of defending my choices right now, and a little extra ammunition
would be
 >>useful.

 > You can probably find more stories like that on the mod_perl
 > mailinglist.  (Stas is reading this list, maybe he can think of more
 > high volume examples).

Think for a minute.

mod_perl itself is mostly written in C. In fact it's a C Apache module.
Tell it to your angry investor. You cannot beat C with another C, if you
know Doug (who wrote mod_perl), he is the performance monster - I doubt
many people can write more performant C than he does. Half of the
problem solved.

Now tackle the second half. You stand before the choice of developing
the project in C or Perl (or another language). Unless you have a
built-in C compiler in the head of every person on your team, each
recompilation adds to the development overhead. But that's peanuts, once
you come to testing/debugging/memory leaking stage, you cannot beat Perl
here. But your investor claims that he is willing to make the project's
development longer in C if the performance will be substantially better
(oops forgot the maintanance part :). So accept his words, but...
prototype and develop in Perl. Finish it fast, get things working, get
lots of tests that pass. Now spend the rest of the time profiling the
code and re-writing the slow parts in C/XS and you are done. You've two
wins here

1. You deliver the first stage early and allow for last minute changes,
and you can even start using the code in production.

2. Nothing stops you from eventually finish up with a system which is
mostly written in C. But I doubt that this will happen. Because the
market realities will not let you the time you will need. And because
Perl doesn't perform bad at all compared to C, unless you handle a lot
of bits of data, where C beats Perl by many times, and that's where you
do XS/C for the data handling.

Look at all Math modules on CPAN. Their cores are written in C and
interface is in Perl.

I guess that gives you an idea of what I mean. Choosing Perl doesn't
bind your hands but does the opposite. If you throw in Inline::*
modules, you can even use many other languages, including Assembly
language :) Hmm, I should try to write some content handler in assembly
language, gotta be very fast, though not portable :(

In any case here are some resources that you can use to make your point:
http://perl.apache.org/perl_myth.html
http://perl.apache.org/stories/
http://perl.apache.org/sites.html

There is one thing that will make all these arguments useless. If you've
got a team of good C programmers which don't know Perl or know it very
bad, you probably want to go with C and try to get them to learn Perl
for the next project. But that's true for any other languages. It's just
that I'm not wearing your hat, so I cannot see what you see.

_____________________________________________________________________
Stas Bekman             JAm_pH      --   Just Another mod_perl Hacker
http://stason.org/      mod_perl Guide   http://perl.apache.org/guide
mailto:stas@stason.org  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/



   Previous | Next
     _________________________________________________________________

   Comments to Ask Bj

the rest of The Pile (a partial mailing list archive)

doom@kzsu.stanford.edu