Op Tue, 6 Mar 2007, schreef Chuck Burkins:
Show quoted text 21 lines
On 3/6/07, Florian Klaempfl 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 has serious defficiencies, one is raw performance, another is the way it deals with libraries, which is just like a C compiler, include all files you need. This means once you get a large PHP library, it starts to suck, even though you only use one procedure in your library.
Another issue is the dealing with databases. The php way is to do text substition, which is a serious risk of SQL injection vulnerabilities. More often than not, PHP does not do database connection pooling, and this because everyone is writing his own database abstraction layers, there exists no good database API in PHP.
Now Pascal has its defficiencies in web programming too. CGI programming tends not to be very scalable, allthough it compensates by raw performance. The trouble is when databases come in, connection pooling is almost impossible to achieve with CGI.
PHP written by skilled programmers can be quite readable and
maintainable. Certainly easier in my eyes that C and miles ahead of
Perl.
Yes, but you know what we mean. In syntax PHP cannot match Pascal. This does not mean Pascal should be used just for its syntax, but its properties of writing readable and self-documenting code have not been matched by much languages. I like to code web pages in TCL. Comparing TCL and PHP, TCL beats it, both in power and readability. Even TCL does not have the same syntax properties as Pascal.
Show quoted text 25 lines
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.
PHP got its social contacts right, causing many people to evangelise it. Further, besdides that it was easy to learn, had good documentation, and due to the work of Linux distributions, easy to set up and get running.
Now on to the I were setting up an online
inventory system, I'd certainly do it in PHP. But then I know PHP.
I won't, PHP is not professionals. If things get big, either in code or in performance, PHP becoems a serious handicap.
Show quoted text 5 lines
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.
... and if you learn a language, you'd better learn a good one :)
Daniël Mantione