Originally Posted by randomizer
PHP has critical mass. Everyone uses it because everyone uses it.
Plus it's easy. Anyone can throw together some PHP files and call themselves a web developer.
Originally Posted by poroboszcz
Since most of serious websites use VPSes or dedicated servers I don't think this is much of a deciding factor.
as a sys admin, I should stress how much easier it is to set up a PHP environment in Linux than a secure Python web app (etc). Even Perl is harder to set up (CGI/Perl is easy, but it's also slooooooooooow
. To run any kind of optimised web framework in Perl requires a great deal more effort).
If there's anything other languages and frameworks can learn from PHP, it's the ease of having a working web environment and without the need for a reverse proxy nor handling user / groups.
To explain this last point a little more, on Linux and UNIX, you can't listen on ports less than 1024 unless you're root - so frameworks which open an active listener on port 80 or 443 (SSL) -such as node.js and Go's standard HTTP listener- either need to:
- run as root and manually handle dropping their permissions down to a standard user and group,
- have some 3rd party tool for handling opening of sockets (IIRC authbind can do this),
- or have to listen on a port greater than 1024 (eg 8080) and have a reverse proxy or firewall rules set up on port 80 to forward to your web frameworks listening port.
PHP, despite it's many problems, is much easy to have a n00b friendly and reasonably secure web server as the libphp5.so Apache module make the language plug-n-play (although I should stress that PHP is easy to install if you're pulling from a software repo, but a complete pig to manually compile - as I've sadly often had to).
Originally Posted by biz1
anyways, I maintain the opinion that productivity (writability/readability/maintainability) is king when performance isn't critical
PHP is definitely messed up, but still extremely high on the list despite it's infinite list of flaws
You have things backwards, PHP is less
readable and maintainable than any of the aforementioned languages because
it's messed up.
Originally Posted by biz1
I'd rather evaluate what code practically looks like instead of every messed up thing you can do if you really wanted to.
I can make python look like unreadable mess... that doesn't mean python sucks
Since Python uses it's formatting as part of the syntax (ie it's a whitespace driven language), I'd say it's much harder to make Python look like an unreadable mess than PHP.
But that's almost besides the point as we're not talking purely about code aesthetics here; we're on about language design. There's much more to the readability of a language than whether it uses curly braces or whitespace:
- PHP overloads operators - and given it's loose type system, that means the developer needs to add more boilerplate code to ensure that there's no accidental silent data conversion.
- And because of the above, PHP has had to duplicate similar operators, so now you have ===, !===, and so on. Aside being ugly as sin, it's yet another kludge bolted on to fix a core design problem that should never have existed in the first place.
- PHP has no naming convention for core functions. Some have underscores, some without. Adjectives are randomly plonked in function names depending on the mood of the guy who implemented the function, and on so on.
- PHP has unnecessary similar functions. Such as $_REQUEST - which really shouldn't exist to begin with as it's insecure. There's echo() and print() who's differences are so subtle that there's really no point in having them both. Even Perl, with it's "more than one way to do things" ethos, doesn't duplicate core functions and data tables like that.
- You also have maps and arrays thrown into the same data type - which makes understanding complex data structures harder.
- PHP encourages splicing HTML with server side code instead of proper templating or even having chunks of HTML inside the server side code. This means that PHP formatting is often lost where developers have wrapped their PHP around the HTML structure. This could never happen in Python because of it's strict use of whitespace.
I could go on, but my point is curly braces are such a minor point to the overall readability of a language. And while some of the above can bit mitigated and even avoided if you're an experienced developer (particularly with the last point), the problem is PHP does nothing to enforce good programming practice so more often than not, you end up with developers learning bad practices and releasing ugly code.
The ironic thing is Perl, which is widely joked as looking like line noise, actually does more to enforce good programming practice than PHP does. Perl has clean function names, better test models and -as I'd already said- a greater emphasis on good programming methods.
Ruby is often regarded as having one of the best templating models in any language (Ruby on Rails). Python enforces cleanly structured code with it's use of whitespace. There's so many other languages out there that each excel in the areas where PHP falls apart because they've either started out off the web as tutorial language (eg Python) or have looked at the problems that face existing web frameworks and looked to solve them. PHP's emphasis, however, is about "backwards compatibility and easy for n00bs"
. Which means PHP often misses the point when it comes to writing scalable applications.
Originally Posted by biz1
even for non-web stuff, it works fine where performance doesn't matter too much. the interpreter has nothing to do with the web. the code has nothing to do with the web
Again, PHP was written specifically FOR
the web. Again, PHP was originally named "Personal Home Page
". We've already covered this point so please lets not keep perpetuating this myth that PHP has nothing to do with the web.
I'm also aware that you can write PHP console apps (and that you don't even need the <?PHP
tags wrapped around the code). But to do so would be mental. It's really not well suited for that kind of deployment (PHP ncurses is buggy, default error handling isn't well suited for an application development model, the interpreter is slow, etc). the kind of offline applications that might work in PHP would also work in a Bash shell script - which will be present on every Unix-like (Linux, BSD, OS X, etc) OS already. But it would also work much
better in Perl or Python (which should also be on most Unix-like systems already.
Plus with PHP you don't have SDL, audio libraries, nor even APIs for popular toolkits (Qt, GTK, Win32, Cocoa, etc). Which means you can't even write a basic desktop GUI (which is even possible in a Linux shell script if you were that way inclined!).
I'm inclined to ask if you've ever written anything substantial in any other language? Because Perl, Ruby, Python (and, in fact, every
other language) are so much better suited for desktop and/or server applications. I can't think of any reason to run non-web-based PHP apps aside because the developer doesn't know any other language.Edited by Plan9 - 7/31/13 at 2:16am