by jrockway · 16y ago · 0 comments
It's certainly an accomplishment to create popular software, but this popular software is not necessarily something that should be used. The popularity is a function of choices made by uneducated users.
(IE 6 is very popular, after all, but it's definitely not the best web browser around.)
PHP was invented so that designers could add a <p>Hello <b>Martin</b></p> and think it was cool that their homepage showed different names based on who you were. For most people basic functionality and the ability to connect to a database is more than enough. You can probably write up more than 90% of all webpages without using closuers, lambdas, recursive functions, object oriented programming and what have you. And the people who write these webpages don't care about programming at all, they just want the job done. These quotes from Rasmus shows where he's coming from.
You can of course argue that people shouldn't launch webpages if they don't know what they're doing, the terrible safety concerns of letting idiots code stuff for the web, etc. but it would be like scoffing at people who don't drive an extra souped up Ferrari Enzo - very arrogant. Some pople just want to get from A to B. These are the people who use PHP. And incidentally they are also the people down in the trenches actually building all the little sites that make the world go round.
Oh, come on. Give me an instance where PHP is the right tool.
This argument is so overused that I don't even know what it means anymore.
And no, shared hosting doesn't count. My personal hosting plan costs something like $10 a month and I can choose between PHP, Python, Perl and Ruby (with Ruby it is more difficult, since I have to ask the sysadmin to add a couple of Mongrel instances for me). But mod_perl and mod_wsgi are there by default.
> <p>Hello <b>Martin</b></p>
Dude, that doesn't have any PHP code in it. To make this dynamic, you still have to have some way of authenticating and storing info about users. And you'll also want some way to edit those users.
Do you know how easy it is to create a simple CMS in Django, with authentication, and a functional admin? ... it takes only a couple of hours to a beginner that never worked with Python or Django before (yes, I saw one in action).
When PHP appeared, it made sense since Perl was the only game in town, and it was a bitch. But things have evolved a lot since then (even for Perl). For me, PHP doesn't make any sense.
Dude, that doesn't have any PHP code in it. To make this dynamic, you still have to have some way of authenticating and storing info about users. And you'll also want some way to edit those users.
Dude, he was saying they could add personalization to the page.
Frameworks have their place. PHP has a number of frameworks that can also make this claim. I would say raw PHP fits nicely where frameworks don't.
And <p>Hello <b><?php echo $_SESSION['first_name']; ?></b>!</p>. Populate SESSION however you like, whether it's from a database or a simple form submission.
Even today, if you have a lot of HTML, and you want to add just a little bit of dynamic functionality to it, PHP is easy and fast.
Could you give some examples of this?
I'm not a huge fan of PHP, but it generally works, as folks like FaceBook have proven.
The only thing that saves them is that most php users have no clue of what they are doing, have not training of any sorts, and no nothing but php and maybe perl, vb or whatever.
[1] Okay, I'm exaggerating and the latest iteration is no longer the menace it once used to be.
* PHP is considered extremely weak performance-wise
* There is poor to no support of multithreading
* There is no eventing system
* As a web framework, it sins in mixing code & design (opposed to e.g. Django-Python or Ruby on Rails)
(If the term "framework" seems unfit, think of "web-targeted toolkits")
I don't know, it seems a lot of the very high trafficked sites (Facebook, Yahoo) run PHP. Yes benchmarks do show PHP doing poorly, but when was the last time anyone used PHP to crunch numbers? It's apparently fast at what it needs to be fast for.
> There is poor to no support of multithreading
That is not a flaw. PHP is a share nothing architecture; each request is completely independent. This is a good match for the stateless nature of HTTP. Multithreading isn't at all appropriate for PHP and I can't think of a scenario where it would be needed.
> There is no eventing system
PHP is a programming language not a framework. I'd make more of a comment about the various PHP frameworks but "eventing system" seems kind of vague. Maybe you can clarify this a bit and then I'll comment.
> As a web framework, it sins in mixing code & design (opposed to e.g. Django-Python or Ruby on Rails)
Nobody mixes in code & design in PHP anymore -- you won't find it terribly common among the various PHP frameworks. I do use it from time to time as a debugging aid and my compiling template engine uses it as the compilation target.
I'm completely for PHP as a simple and accessible language. The previous author wanted to hear about the shortcomings of PHP and I tried to provide some. PHP sites such as Wikipedia probably need more servers (since every request is a separate process). They might be saving a lot of manpower by using PHP, so it might be an OK tradeoff.
By the way, Facebook uses Erlang for its performance-critical parts (such as chat).
> PHP is a share nothing architecture; each request is completely independent.
You could still use an agent-like messaging system for shared-nothing multithreaded/multiprocessed environment.
> I'd make more of a comment about the various PHP frameworks but "eventing system" seems kind of vague. Maybe you can clarify this a bit and then I'll comment.
e.g. When using cURL you must poll the handler until the request is complete. Obviously you'd need multithreading to achieve a better control flow in such a scenario.
> Nobody mixes in code & design in PHP anymore
I've written and debugged some wordpress plugins, and I can't say I came to the same conclusion as you...
Not blocking the entire PHP process while waiting for database results, waiting for a file to download, waiting for memcached to respond, etc.
I would (and do) use an event loop for this sort of things, but lightweight threads are technically a better abstraction. Web apps would use a lot less memory (and hardware) if people were not so afraid of threads.
(This happens a lot; a bad implementation of something taints the whole category. pthreads, Java threads, Perl ithreads, etc., are broken, so all threading is bad. C++'s object model is bad, so all object oriented programming is bad. It's sad.)
BTW: some good thread implementations include Haskell's and Perl's Coro.
I'd like to see your source for the performance claim. To my own I can bring e.g.
http://xodian.net/serendipity/index.php?/archives/27-Benchma...
http://blog.dhananjaynene.com/2008/07/performance-comparison...
I found threading a great shortcoming of PHP. I had web services that required data from several sources and was in need of querying in parallel. there are about 370,000 results for +php +multithreading on Google so I assume it's more than just myself.
Compared to what? Assembler?
There are valid criticisms to be made of PHP, but poor performance is not one of them.
I come from 4+ years of using it professionally and most of the higher level frameworks I'm talking about (Kohana, Zend, CodeIgniter, etc...) really only exist to overcome a lot of PHP's more abstract weaknesses (even though they can't really do much about the interpreter implementation).
I can easily say that something written in Python, Scheme, or whatever-you-choose will run a lot better, take less time to build, and be easier to manage down the road.
The primary problem in this industry is that the majority of web application programmers grew upon PHP and are running their own IP Consulting shops or startups by now and have zero experience with other languages, therefore making them much less interested in trying to adopt a different web development paradigm when an aspiring web developer with Python/Erlang/Scheme/Ruby skills under their belt try to build something with that tool chain in their employ.
The less knowledge and/or experience with other languages you have, the more rooted in what you are comfortable with you are. Education is a good thing, that is what I love about Hacker News; the people here experiment with new languages and trying out new technologies for their projects/products - which is much more progressive than the enterprise situation.
In a way php is a framework.
This has been described in detail thousands of times. Google it.
So why are there so many crappy PHP developers? Because anyone can make it do something approximating what they are envisioning it doing, no matter the skill level. That seems pretty powerful to me. And, in the end, it's really about the results instead of how one necessarily got to those results. You can't make money if you don't deliver a product. And if history is any indication, only a tiny fraction of the masses care about quality. The dominance of Wal-mart and MySpace are proof of this. My guess about your guess is those millions of lost man-hours have been made up with the millions of hours beating competing products to market due to the rapid nature of PHP development. I mean if we are throwing around unverifiable assumptions, let's do it, let's get crazy with it.
"A determined soul will do more with a rusty monkey wrench than a loafer will accomplish with all the tools in a machine shop." - Robert Hughes
* CGI (mostly done with Perl).
* mod_perl (a huge ungainly mess)
* ASP (no thanks, not a Microsoft guy)
* Various proprietary things
* Various niche players (my own mod_dtcl [later Apache Rivet] was faster and IMO, nicer than PHP, but never got more than a modest amount of traction).
By the time I even started writing mod_dtcl, PHP was already pretty widely used, and we were using it in production at the company I worked for, and it was certainly better/faster than doing things in Perl CGI's.
These days, I really, really, really don't like having anything to do with PHP after having dealt with too many unholy messes, but I can't deny that it got some critical things right at the right time.
Speed in a shared hosting environment. I've read about developers running multiple commercial sites from a single Dreamhost account e.g. http://www.pseudocoder.com/archives/2009/01/04/how-much-mone... . That's not realistic with Java, RoR, or Perl.
So I assume PHP no longer has the performance advantage of integrating closely with Apache.
In fact, since Dreamhost now offers Passenger (AKA mod_rails) as a solution for running Rails and Django) PHP might be at a disadvantage. Especially when paired with a large framework (zend,codeigniter,cake, etc.)
Defining good is always tricky, but being chosen by many people when other good choices are available is not a bad test for certain definitions of good.
Choices may not always be %100 rational. They are usually not random.
Most people seem to miss the role that time plays in language choice. PHP's very far from the best choice for webapps now, but it was the best choice when it was invented in 1995, and even for a while afterwards (such as when FaceBook was created in 2004).
Nobody purposely downloads IE6. That isn't the point though. If they buy a computer (maybe this isn't true anymore) and go to Google using it they don't go "something's wrong." They just keep using it.