[fpc-pascal] CGI (with Free Pascal) vs PHP

Chuck Burkins cburkins at gmail.com
Tue Mar 6 13:01:22 CET 2007


On 3/6/07, Florian Klaempfl <florian at freepascal.org> wrote:

>
> (Pascal) compiler based CGI is magnitudes faster than PHP, less resource
> consuming and much easier to maintain. The only advantage of PHP is that
> is easier to use for beginners and that's probably the only reason why
> PHP is so popular: you can hack quickly something together but
> maintainance, performance etc. are nightmares.

With all due respect (and that *is* a lot of respect), I disagree. I
leave out the relative speed of PHP vs. compiled pascal, as I've never
use Pascal in CGI. I have got over 100,000 lines of PHP code in
service, so I think I can safely comment on that.

PHP does not in any way burden a modern web server, at least when used
as an apache module. My test server at work has 128MB of RAM and only
occasionally does it slow down noticably, typically when MySQL is
working on a particularly ugly join. In my experience, the speed of
well written  PHP is indistinguishable from the speed of the same
static HTML, as long as you leave out any database interaction (and
Pascal of course would have database interaction as well).

PHP written by  skilled programmers can be quite readable and
maintainable. Certainly easier in my eyes that C and miles ahead of
Perl. It is true that PHP is easy for beginners to pick up, but Pascal
is actually easier for beginners in my opinion,  after all it was used
as a teaching language for years and you don't need to know HTML. I've
always found the claim that languages are bad BECAUSE they are easier
for beginners to learn to be condescending and elitist ( and I don't
think that's what you are saying -- after all you develop in Pascal, a
language that is often tarred with that same brush). It is true that
languages that are easy to learn pick up a lot of beginners who never
seem to progress beyond beginners, but I think the same thing happens
with Pascal.

Now, you can certainly knock some programmers, and if you were to say
you find PHP inelegant, I certainly agree with you. There are some
pitfalls that you run into in PHP that you'd never hit in Pascal
because one is loosely typed and the other strictly typed. On the
other hand, the scoping rules in PHP, when used intelligently, work
better than any other language I've programmed in, once you get used
to them.

I think PHP is popular largely because the web is popular. PHP is
quite good for programming web pages. It's easy to install, well
supported, has a rational syntax, quite feature rich, generally
readable, and very easy to change quickly. It's an agile language in
the sense that you can prototype a solution, tweak, refine and come to
a solution that makes the customer happy very easily.

Now on to the question at hand.  If I were setting up an online
inventory system, I'd certainly do it in PHP. But then I know PHP. The
original poster does not, and I'm not going to say that he should
learn it to complete a project. It certainly is a problem domain where
PHP shines, but the Graeme's time would probably better spent solving
the problem in a language he's facile in than learning a new one,
regardless of how trendy and popular it is.

With high regard,
Chuck Burkins
cburkins at gmail.com



More information about the fpc-pascal mailing list