Tuesday, September 23, 2003

PHP

Curtis:

Actually PHP just kills me anyway…why they had to invent a new language, I’ll never know.

Why is it that so many Web hosts support PHP instead of embedded Perl or Python?

7 Comments RSS · Twitter

Because PHP doesn't suck as much as Perl? Nah, seriously, it's just widely used as a web scripting language and really easy to install. It has some really great features that sets it apart from other languages for web use, and it's easy to learn.

Let's face it, Perl is great for those who know it, but it's quite confusing and "non-standard" (read: not C-like) for those just starting to use it (or trying to). And Python just isn't widely used right now.

Yeah, but I think the reason it's widely used is that so many hosts have it pre-configured. Is it that much easier for them to set it up than, say, mod_perl? Most hosts won't even allow that.

I appreciate the niche that PHP is trying to fill, but it seems remarkably clunky for such a small language. And I don't see anything special about the features compared to other scripting languages.

I agree that PHP isn't as much "designed" as it is "grown". There's no real concept, it seems that people just keep on adding functions left and right, without caring about even the most basic things (nomenclature, argument order, etc).

With "great features", I meant stuff like functions. It has tons of functions for stuff you'd have to write yourself in other languages, like getmxrr (http://ch.php.net/getmxrr). Support for forms is great. it's easy to get information about the client. It has reasonable object support. And it has a great, helpful community, which isn't the least important thing for a programming language. php.net is simply invaluable.

The grown vs. designed point is exactly what I was getting at, but didn't quite make explicit. I think php.net is great. I have trouble believing that the functions you refer to aren't in CPAN or the like. Certainly they would be if Perl were widely depoyed in the arenas that PHP is.

What I'm really interested in is not why PHP is popular and has a good community *now*, but rather how it got that way. It didn't start out with a wide deployment, or all these useful functions, or even a database abstraction layer.

Yes, there's certainly a way to get this kind of functionality in Perl, but in PHP, it's there right away. No need to install any modules.

>What I'm really interested in is not why PHP is popular and
>has a good community *now*, but rather how it got that way.

That's a good question, and I certainly don't know the answer - it was already pretty popular when I started using it some years ago. I started using it because at that time it was the only language my provider had installed - so I guess ease of installation made a big difference.

You could use Perl, but only if they resided in a specific directory. You can use PHP wherever you want, mix it with HTML and do really cool stuff. I believe that back then, it either wasn't possible to do that with Perl or you had to install some additional stuff. And most people didn't bother.

It was easy to quickly hack something together and get the hang of the language. And if you try, it's also pretty easy to write readable code (as in: readable by *other* people) in PHP. The second part is a bit harder in Perl, if you ask me ;-)

And I think both Python and Perl have some features that can confuse beginners - Perl's function arguments and Python's use of whitespace comes to mind.

So basically, PHP seems to be easier to install and easier to get the hang of, so that might explain the difference in usage.

What kills me in PHP is that installing extensions requires recompiling PHP. It's a big problem because unless you have dedicated or virtual dedicated hosting, you cannot recompile PHP on your hosting provider's server. You have to ask them to do it and it can take some time, when they do it at all.

Unfortunately, extensions like iconv (mandatory when your website is not US-ASCII) or XSLT are often missing.

I am relatively new to Perl and see a frustrating trend. As my programs group in size, I tend to 'clean up' my code by creating functions, loops, etc. This is all basic stuff that worked great in C and other languages. The problem is that things just seem to randomly quit working when I hit just the right combination of loops and functions. I get no errors, just messed up data. For example, I can iterate through 232 records, but by adding one more record, a number of fields suddenly get set to 1. This is on a 4 way multi-processor with plenty of memory. Its like it just rolls over and dies. I am very suspicious.

Leave a Comment