81 points · by guillaumepotier · 13y ago · 132 comments
This just won't ever happen. The people that wanted to drop PHP for something else (Ruby, etc) largely did so years ago. The hosting/running situation for PHP is just too basic and easy for people to get in to vs having to 'run a server' (Rails, etc).
PHP is still the only language that assumes HTML output by default. Put a file on a web server, hit it via a URL, and get HTML output. It's that simple. You can start at 'simple' then graduate up to complex stuff like Symfony if/when you want to. Every other language or platform forces a lot of extraneous concepts on you on day one, which is always going to be a turn-off for a not-insignificant portion of the people coming in to the field.
I did play around a bit with Flask a while ago and it does feel a lot cleaner and more efficient. But once you actually try to deploy your app you realize that hardly any web hoster actually supports the required Apache extensions and suddenly you end up having to set up your own server and fiddle with config files to get it to work.
For me, that's not a feature, it's an oddity that I have to work around. I guess it's a feature if you're using PHP as the HTML template language it was designed to be, but I suspect that's a minority use case these days.
Why layer an additional templating language (Smarty, etc) on top of PHP - incurring extra processing and parsing - when PHP is a perfectly capable templating language itself?
There are cases where you may need to do this (if you can't "trust" the templates for example and you need to enforce some kind of validations or restrictions on them) but otherwise you just need to follow/enforce business rules about what can go in your views, and just use plain ol' PHP..
From past experience: to stop shittier developers at your company putting controller logic in the templates. Using something that does nothing but templating ensures that your templates do nothing but present data.
Edit: By which I mean, Symfony improves things by working around PHP's suboptimal default.
Well, I would venture a guess that you should have looked up the language's name and its meaning, then the entire focus of PHP might not come as much of a surprise.
It takes you about 3-4 seconds to change it for your entire project.
I was referring to the fact that the first thing pretty much all PHP apps do is say "Wait! Don't output anything yet! I have code to run!". I believe modern PHP frameworks generally borrow the controller/template pattern from other languages, because it generally makes more sense than PHP's default of outputting HTML unless told otherwise.
But you're right, PHP assuming HTML output by default is a huge boon. With node you have to set up your own server and routes, and more... That's a lot more work than installing WAMP, running it, and putting your php files in the right folder.
> The days when programmers opened up a blank file, named it index.php, and said, "time to start coding!" are over.
That is actually the only thing better about php than... well, pretty much any other option.
As for the rest of it... "lipstick on a pig"
$ git push heroku master
...done.
"git push heroku master" comes at a steep price. PHP hosting is, in general, ubiquitous, cheap, and incredibly easy. You can get comparable pricing for ruby hosting, but you'll be doing some server setup yourself.
Um... what? 1 dyno is free on heroku. You host it for nothing. Am I missing something?
Might I ask where?
Their is money in syntax now.
I still have serious doubts about PHP, and always insist to new developers should learn a (ruby/python/... clojure/...) too.
The main problem with PHP is the language itself. There is no paradigm it does well. If you're into class-ical OO, then the language's type system is a joke (esp. with the lack of co/contra-variance in type hinting).
If you're into dynamic OO, PHP's java leg-humping perpetually gets in the way. There is no meta-classes, monkey patching, etc. everything that should be dynamic is static.
If you wanting functional programming... you have nothing. Literally. The best they've been able to do is a half-baked closure system. Half the library uses references (rather than returning meaningful data) so you cannot compose functions and there is no hope for any kind of collections system (lists, arrays, etc.) that support a typical functional manipulation.
All you're left with is a "dynamic C".
Add to this that PHP is designed to terminate immediately... and you're modern "daemonic" web requirements (concurrency, queuing, etc.) are completely out of the window.
From the point-of-view of "web-scale" application development PHP is a broken toy: both in the sense that talented developers are hampered by it, and in the sense that its execution model is ill suited to the problem.
[1]: https://github.com/laravel/framework/blob/master/src/Illumin... [2]: https://github.com/reddit/reddit/blob/master/r2/r2/controlle...
The PHP code you linked to is basically a class with a bunch of getters and setters.
The Python code, on the other hand, handles numerous real-world HTTP requests that do actual work.
So it's not unexpected that the PHP code is lighter; it doesn't really do anything useful!
Although it helps implement a wiki system, the Python code is still very readable and comprehensible with minimal effort.
I think I know the point that you're trying to make, but those examples surely don't back it up in any way.
The Python code, while a little heavy on decorators for my personal taste, spends the same number of lines of code implementing a whole swathe of useful application functionality.
I'm not saying your particular example proves anything about PHP vs Python, I just think you chose an apples-to-oranges comparison to illustrate your point. It would be much more interesting to see some PHP code that implements business logic similar to that Python.
Simply put, ruby is ugly as sin. I much prefer php's syntax. Granted, I also much prefer other C style languages, even objective-c. I mean, that probably says it all. Objective-c is probably on the opposite end of the syntax tree compared to ruby.
Simply put, ruby is ugly as sin. I much prefer php's
syntax. Granted, I also much prefer other C style
languages, even objective-c.
*I mean, that probably says it all.*
Yes. If only you knew how true this was :PThe language remains as bad as it was 7 years ago, and they seem to be woefully unwilling to actually fix it.
The author makes a good point that people like me who ditched PHP in the mid-2000s should probably stop complaining about it since we don't really know the current state of affairs.
The problem is when we have languages like Ruby, Clojure, Scala, Haskell, or even plain old Javascript ala Node, why would I waste another thought on PHP? PHP was created to make very simple dynamic web pages, and I would still use it for that in the way that I still write bash scripts for simple shell operations to avoid a higher level dependency like Ruby or Perl. I'll use PHP for small stuff, but I see no benefit towards putting any real engineering effort into a PHP project.
I'd argue that PHP came out of the gate with some pretty powerful properties, too.
They hit a sweet spot of
* Being there at the right time (none of the "good" languages in your book was around or usable for web dev at the time of PHP4 and PHP5 came out)
* Being easy to learn - giving beginners quick rewards.
* Being powerful enough to do quite a bit more than "simple web pages", as you say. This enabled people to "graduate" from "simple web pages" to "web apps". In fact, most of the web was built in PHP (Wikipedia, Facebook, Wordpress runs on 50% of all webpages or so, Drupal is incredibly popular, Magento runs loads of webshops, and on and on). This has not happened merely by accident. I feel it's a bit wrongheaded to suggest otherwise.
* Being dead easy to deploy on almost any webhost (Drop files, hit them with their url, be done - almost no other language delivers this even today)
In all i feel PHP has moved the web forward tremendously. In time, itself has evolved as well. It may not have evolved as fast as one would want.
It's the C++ of the web era, really.
"Easy to learn" is not the same as giving beginners quick rewards. Being easy to learn, in reality, would probably result in things like Wordpress not having more holes than a swiss cheese.
"Powerful enough" -- most web frameworks are. Saying that it didn't happen by accident of course depends on how you define accident. Personally I think the only thing PHP has got going for it is the timing and next point:
"Dead easy to deploy" again isn't a property of the language. Saying that "almost no language delivers this" about something that's really up to the service you're using to host your website isn't fair, in that it actually has nothing to do with the language.
I must say that I wholeheartedly agree with your closing statements, though.
Agreed, wholeheartedly. I truly dislike PHP as a language, but one cannot deny the massive impact it had in making web applications commonplace.
Javascript wasn't made for large applications. It was made for form checking and rollover menues (some of the earliest examples back in the day) ;)
It can be argued that Javascript has many unfixable design bugs, too. Just sayin.
The only real option is to give up backward compatibility, to then throw out every broken language feature, and to then reimplement them properly. Unfortunately for those two languages, that would involve an awful lot of stuff getting thrown out and reimplemented, which is very likely why it hasn't happened yet.
Given how much core functionality needs to be reworked in both cases, I don't think they can really be saved. There are numerous other better languages out there, and it's easier just to use them instead of trying to salvage PHP or JavaScript.
For example they have now deprecated the dreaded mysql_, pgsql_ interfaces (including mysql_now_escape_the_string_for_real() and the like ;) for accessing the database in favor of PDO.
They will be removed in the future. Lots of projects still use those.
Just 1 example of PHP dropping backwards compatibility. It's not quite so bad as you make it out to be.
Another thing to consider is that PHP developers have a track record of deprecating certain functionality, then a few releases later changing their minds and no longer deprecating it. Some examples of this include is_a, and var in property declarations.
Given how it's still relatively common to see PHP 4.x installations in use today, 10 or more years after they were first released in some cases, merely deprecating some of the broken functionality now won't help much. We'll still see deprecated features in use in 2020, if not well beyond then.
The broken functionality needs to be stripped out completely within a reasonable time frame (well under a year), not merely deprecated and left around for years, if it even stays deprecated. But this involves the PHP community acting responsibly, and going along with these changes for their own good. I don't think we can expect that level of responsibility out of them, unfortunately.
I'm a big fan of python and I think that very intelligent people are behind its architecture, but honestly most of the money I made through the past years came from php websites that I can build really fast.
I have eventually used python (fabric) to automate creating php websites.
It does, however, have some bad behaviours of out the box that promote bad app development. I was startled at the default error handling when I had to start using it again recently. It was a fight to get it to display errors - and stop executing - whenever something was wrong in the code. This is madness. If your code is broken, it should notify you. I tried doing the same thing to existing well known php apps. They wouldn't even load. That, for me, is the core issue. You have an ecosystem devoloped by people who seemingly don't even care if there are bugs in their code.
If you want all errors displayed, you should tell PHP about it. In fact, it is recommended you display everything possible and code to strict standard while in dev. Doesn't sound like you were doing that.
Symfony2, my framework of choice, has a very mature and solid architecture and offers anything you could imagine from other frameworks. The code is clean and maintainable if done right and still its extremely flexible and extensible. It also depends on PHP 5.3 which has Namespaces, closures, lambdas etc. So id argue its up there with any of the other top Frameworks, it might even be the best. While its true that there are languages that are more beautiful to work in, i dont think its all that bad. For me, the biggest flaws of PHP are present in any dynamic-typing language. The syntax is just stuff to get used to once and be done with it.
I have been using symfony1 since january 1st, 2008 and then migrated across to 2 for other projects.
symfony2 is a solid framework for php, and very quick to get started and maintain. With composer it is even easier, and git repositories are pretty small as well.
Maybe php stock is not that cool, but using a good framework (and now there are many) it becomes really awesome.
You don't see much fresh innovation in the PHP community these days - instead, you see developers who work with PHP having to recreate libraries and techniques developed by other languages.
Meanwhile, the Node.js, Python, Rails etc communities are overflowing with talented developers who used to work with PHP and are now busily inventing the future on top of different languages.
It might not be the best language for every application (I find myself using it less and less these days), but there have been a whole ton of recent developments that have made it much nicer to work with.
PHP 5.4 made some pretty significant improvements, and Laravel is one of the nicest full-stack frameworks I've ever worked with. PHP now has good/sane dependency management via Composer, and many of Laravel and Symfony's components can now be used outside of the main framework. Microframeworks are a pleasure to work with in PHP, which is especially nice for smaller one-off webapps.
Many of the recent improvements have been (very) late to the game, but they're nevertheless welcome. I could do without the Java-esque levels of verbosity that PSR-0 encourages, but it does seem to result in highly-maintainable code.
"New PHP" projects (written from scratch, targeting 5.3 and above) tend to be of surprisingly high quality. As I've mentioned before, Laravel emerged from nowhere as a lightweight and very high-quality framework, long after the PHP community had been declared moribund.
And contrary to your beliefs, what they say does have an impact. We wouldn't see so much emphasis on web development using languages other than PHP and JavaScript if what you were saying is true.
Or why should it take 15 years to adopt [...] as an array constructor in a language where arrays are one of the central data structures?
Here is opinion No. 823,664,783 about PHP from a long time PHP developer: it sucks (for me) because somehow I don't have a sense that the language itself is in good hands. I'm not sure if, say, they introduce a new basic operator in expressions and that it will not take another 15 years until it makes full programming sense.
Rather, he just covered parts of JavaScript that shouldn't be used, and whatever wasn't completely broken was considered to be "good". It isn't truly good, however. It's just not "severely bad" like the rest of JavaScript is.
Now a days I use rails and prior to that I used node/express for a year or so. I think working with php made me a better developer because you need to learn from your mistakes and using bare bones php is the best way to ensure you make mistakes.
You don't really understand why things are done a certain way until you've experienced first hand at how horrible it is to maintain a 6,500 line php file that's mixed with sql, php, html and a ton of inline css in a project that has about 500kb of mixed php/html/css files and like 30 different dynamic pages.
It's quite possible to write PHP applications which aren't that terrible, tightly coupled or unmaintainable. Perhaps you can blame PHP's low bar for entry for making those kind of bad practices possible, but it's not as if the language requires you to work that way.
Although I do see that kind of thing a lot in Wordpress, still.
At least that's how it was back in 2006ish when I started. Its low barrier of entry is exactly why it's easy to make mistakes. You are given 5000 functions and no guidelines other than the ones you make yourself.
I don't know if it's even as common as it was to start in PHP without at least touching some kind of framework... although that's just an assumption on my part. At the very least there's a lot more good PHP code out there and better practices to be found, even if education seems like a dauntless task.
When you're talking about any project that's less than a thousand lines of code or so, PHP's weaknesses don't really present a major problem and its strengths (ease of deployment, ease and ubiquity of hosting, having a bunch of necessary features for websites from DB access to email built into the language) are ideal for smaller organizations, particularly those without a full-time technical staff.
Think about how many small businesses out there (restaurants, real estate agents, a simple online store) just need 1 or 2 basic dynamic elements (simple DB access, a contact form, some validation on an order form, maybe sending a confirmation email on a sale) on their website to work to enhance their business. PHP is a great choice for these types of projects - a good portion of non-technical small businesses don't need anything more elaborate than this.
I wouldn't recommend PHP for large or ambitious projects, as other alternatives like Node and Rails are likely better fits. But when you have a very simple small business project, PHP is by far the best choice for a lot of these types of projects.
Unlike other popular language which has language designer around it, PHP 'copy' other language feature without even serious consideration around it. Even more, there are no language guru who want to research the Good parts of it, like Javascript who has Douglas Crockford who tels us the good parts...
I personally recommend Python over Php to newcomers because I think it's an easier language to understand and get going with.
Sure you have better, more streamlined tools in your shed, but sometimes you just need a little elbow grease and your old pal the screwdriver.
"I can’t even say what’s wrong with PHP, because— okay. Imagine you have uh, a toolbox. A set of tools. Looks okay, standard stuff in there.
You pull out a screwdriver, and you see it’s one of those weird tri-headed things. Okay, well, that’s not very useful to you, but you guess it comes in handy sometimes.
You pull out the hammer, but to your dismay, it has the claw part on both sides. Still serviceable though, I mean, you can hit nails with the middle of the head holding it sideways.
You pull out the pliers, but they don’t have those serrated surfaces; it’s flat and smooth. That’s less useful, but it still turns bolts well enough, so whatever.
And on you go. Everything in the box is kind of weird and quirky, but maybe not enough to make it completely worthless. And there’s no clear problem with the set as a whole; it still has all the tools.
Now imagine you meet millions of carpenters using this toolbox who tell you “well hey what’s the problem with these tools? They’re all I’ve ever used and they work fine!” And the carpenters show you the houses they’ve built, where every room is a pentagon and the roof is upside-down. And you knock on the front door and it just collapses inwards and they all yell at you for breaking their door.
That’s what’s wrong with PHP."
I've been there too, and I must say I agree with Jeff on this matter - if I was forced to use Ruby instead of PHP when starting my career, I'd be a better developer today. But I'm catching up :)
In 1997, people moved from perl to PHP in the same way that in 2004+ people moved from PHP to Ruby.
At the time, the hard part of web programming was deployment, easy access to libraries of functions relevant for web programming, digesting forms, and emitting HTML. PHP suddenly made that trivial. PHP was basically a new language with a stdlib for web programming. It was enjoyable to work with, and it took off.
Circa 2004, the hardest part of web programming was managing the DB from the app code (migrations,ORM), quickly accessing the prolific output of the OSS community (RubyGems), and having some sane organizing principles around building apps (opinionated MVC).
In 2004 I had the same problems in my PHP apps. I had just come off of 2 years of Cocoa development and couldn't stand doing PHP the "old" way. It was too painful. I ended up porting the Cocoa framework to PHP so that I'd have a sane way of building apps. I later discovered ruby/rails, but frankly at that time it was less mature than my framework so I didn't jump.
As someone stuck in PHP land, I was frustrated by the relative lack of progress in the PHP community vs Ruby, but I was never really enamored with Ruby the language. It's powerful, and easy to read, but frankly I felt that power would eventually work against it. As the less-savvy developers moved to it, the quality of the code would greatly diminish. I feel that this has happened.
I do use a lot of Ruby projects as well, and it's rare that I don't run into critical bugs almost immediately. For as many nice things as there are about ruby, I find it very difficult to debug, and the broad application of metaprogramming, mixins, and other language tricks ends up delivering apps that have highly coupled state that fail in unpredictable, hard to debug ways. Javascript has the same problem. Frankly I don't think the ruby community is producing code of better quality than the php community at this point. There is great stuff that we can finally easily share thanks to composer.
Metaprogramming & dynamism are neat ideas but I just don't think it scales well with the constructs that those languages have. PHP 5.4 has traits which are really nice for this type of thing, and Scala's traits are even nicer. The point being that other languages can deliver that flexibility without becoming unmanageable, and I don't think there's a path to that with Ruby or Javascript.
IMO, I think languages like Ruby and Javascript will actually WANE in the far future as new languages come along with better constructs for empowering developers with dynamism that can be better managed and have faster runtime performance. I think Ruby will end up as a frowned-upon language with crap libraries and Javascript will more and more just be used as a build target.
Correction: if it compiles everywhere ... it's not waning. C, C++, and JavaScript are with us for a long time. But, you're right about Ruby. :-)
Ah yes, 2013 PHP:Ruby is the same situation as 2008 Perl:PHP.
5 years ago, you may have been right. Now? You are so wrong.
Before bashing something, you should make sure you're correct.
> But it has.
Honestly, how can languages (what PHP in the end boils down to) possibly evolve?
Example: you cannot bolt OO to it later on, PHP, Perl and to some lesser extend even Python are a testimony to that. It just does not feel right, leads to syntactic horrors and is usually not very performant.
Neither can you modify the syntax. You can add to it. But not much modify existing syntax. For tiny changes all hell breaks loose.
> [...] and feel like they're doing the wider community a service by making declaring a religious war against PHP.
I think the religious-war card is clearly overused. This is not a religious-war, it is an effort by programmers who rather use the best tool for the job then the bizniz/customer dictating them a languages/framework/CMS. PHP will not be fixed, mission impossible, they know it and therefor advocate a retreat-strategy.
The article describes that the community has (be it very late) finally developed some tool, a package manager, that make it slightly more bearable. But the language and its community still suffer the exact same unfixable problems.
An analogy: even in COBOL-land some problems get fixed up until today, but not fundamental language issues, nor community issues.
Yes, I compare COBOL with PHP. Many, or most, languages will someday be 'legacy' languages. Some just a little sooner then others. :)
$topic = $this->get('model.Topic')->find($topic_id);
$this->get('guardian')->ensureVisible($topic);
becomes this: $topic = Topic::find($topicId);
Guardian::ensureVisible($topic);It has its good points and all of its current features can be implemented (and already has in other projects) with HTML fallback in PHP. But I feel the biggest problems Discourse is attempting to solve is sociological, not software based. Whether software can fix human nature is another topic altogether.
Full disclosure: I don't use Discourse and don't plan to any time soon. I still believe any site/forum worth it's salt should be available via wget so that rules out most web apps (I don't believe a forum should be a web app).
PHP was shit then and it's shit now. I earned my first money by writing things in that language and I'm very glad that I moved away from that particular technology and web development in general.
I really dislike PHP as a language, but it's not fair to call it shit. The language is maturing.
Slim Framework http://slimframework.com as a microframework.
From my experience using it, Laravel also feels a lot "lighter" than the other big frameworks of the past. It's a bit less opinionated, and it's much easier to get set up and running.