The y axis labels are clearly in factors of 10 and the title of graphs says "...(Logarithmic scale)"
What more could you want them to do? remove the parens? I was going to say bold the text... but it is already!
PHP has no shortage of weirdnesses and warts, but it occurred to me recently that no other major language was created expressly for the purpose of rendering web pages. All the other major contenders (Python, Ruby, Java, etc) are, for better or worse, general-purpose programming languages, which are pressed into service for rendering HTML strings using various libraries and frameworks.
The common wisdom is that PHP's success is due to ubiquity, deployment, and low barrier to entry. While all those are true, the fact that so many web-focused tools are baked into the language itself (meaning minimal time to hunt/learn/evaluate third-party libraries) shouldn't be ignored.
I haven't programmed in PHP for a long time and I could have forgotten, but I don't think there are many (if at all?) web specific language constructs. There are many things in standard library tuned for use in a web environment, that's true, but they are not a part of the language. The only thing I can think of as a web specific in a language itself is a '@' thing used for silencing errors.
On the other hand there are languages like Opa and Ur/Web or Racket instaweb dialect which do include language construct specific for web, for example static typing for forms, send/suspend or statically typed xml expressions.
I may be wrong on this and I would welcome a correction from someone better informed on the matter.
Oh, I just thought that maybe php.ini is another thing that's specific to the web... But I'm not sure, for example there is site.py file in every Python distribution which effectively serves the same purpose, just uses Python instead of ini format.
Anything else in the language? I'm really curious.
I use PHP every day, and kind of take pride in that. We get a lot of shit for this labor of love, but damn do I enjoy it.
That being said, the PHP ini is a config file that defines some of PHP's runtime parameters and, in some cases, controls modules and drivers that have been installed for PHP. The closest thing I can think of comparing it to would be the JVM config.
I use PHP for a crapton of scripting as well, namely scraping, which has nothing to do with PHP's web app capabilities as that all leverages curl.
The part where PHP files are essentially HTML files (ie you can start with a file consisting of "<b>hello world</b>" and add some code as you go) is where the made-for-web really shows.
While obviously a bad practice, it also enables non-devs to organically learn the language in bits and pieces. Sometimes they move on to create hugely influential platforms like MediaWiki and Wordpress, sometimes they just build very hard to maintain websites. PHP in a nutshell.
Probably more importantly is that the internal errors are still being raised, there's just additional comparison logic within the PHP engine to suppress them internally.
Is there such a thing as web specific language constructs? The way I see it language constructs are language constructs no matter where or how they're used. I think the main point to keep in mind here is that PHP was made for the web while other popular languages used on the web were created moreso for the purpose of being general scripting languages.
Yes of course, certainly there are language constructs or features specific for some domain. That doesn't necessarily mean that such constructs can't be used in other contexts or domains (sometimes they can, sometimes not) but they were introduced into a language with a specific domain in mind.
For example Erlang's `receive...after...end` and `!` are language constructs that are specific to the domain of message passing concurrency and they cannot be used for anything else. On the other hand Erlang's bit syntax is specific to the domain of writing binary network protocols but can be used for extracting data from binary files or constructing chunks of bytes for interoperability with C (structs).
There are many more such examples in various languages - despite being "general purpose" they frequently include features and constructs useful for some specific domain - it's a natural way the languages are created and evolve.
I'm using the term "language" very loosely; you are technically correct. To be clear, I'm referring to the 5000+ global functions, as well as the myriad classes, that are part of PHP's standard library.
> no other major language was created expressly for the purpose of rendering web pages.
Unfortunately, as far as I can tell, it was created from the View perspective of MVC. PHP in my mind is equivalent to the special language of a template processor library of some other more general language.
Similarly, I don't think the set up time has been addressed by any of the other choices in language out there. It is really easy to choose N number of hosts and drop an index.php file into the folder. There are global companies that still hire small firms that write PHP for one-off contests, etc.
I'd say it started closer to making C more accessible for web programming (no fussing with pointers, memory allocation, bounds checks, etc), which incidentally makes it really easy to present content. It's also the reason for the inane naming conventions in lots of the "core" stuff.
I strongly disagree with your implication that it's only useful as a presentation layer, however. Some quirky syntax doesn't at all make it an incapable language; the real problem in my eyes is there's no one go-to framework for MVC work, a la Rails or Django (there's no shortage of choices, but that's not necessarily a good thing).
Heck, the second Google hit for "php mvc framework" for me was a 2009 guide to writing your own (talk about not getting the point of a framework). There were two more pages in the top ten for PHP MVC framework comparisons.
Heck, the second Google hit for "php mvc framework" for me was a 2009 guide to writing your own (talk about not getting the point of a framework). There were two more pages in the top ten for PHP MVC framework comparisons.
Ha ha ha... yeah... writing your own php framework... who would do such a thing...
I understand why it's supposed to be a bad thing but I also think it helps to understand the principles involved in frameworks and the mvc pattern, and one way to do that is try to make your own. Then when you pick a real framework it won't seem like magic.
> I strongly disagree with your implication that it's only useful as a presentation layer, however.
That's not what I meant. I meant that it was created from the perspective of a View. There's no other reason that php code has to be delimited with <?php ?>, other than it was originally designed to be embedded in html. This alone shows how the creators envisioned PHP to be used.
> PHP has no shortage of weirdnesses and warts, but it occurred to me recently that no other major language was created expressly for the purpose of rendering web pages. All the other major contenders (Python, Ruby, Java, etc) are, for better or worse, general-purpose programming languages, which are pressed into service for rendering HTML strings using various libraries and frameworks.
For non-trivial web applications, the "rendering HTML strings" is one of the smallest parts of the job.
The lack of separation between application and HTML output in PHP may be an asset when starting out or when making lightly scripted web pages, but when creating an application that just happens to be served up over the Web (and possibly served up other ways too), those general-purpose languages are much more natural fits for the job.
Browser -> POST -> Database -> XML -> PHP + XSLT => HTML
Prevents HTML from being mixed with PHP. PHP becomes the "controller" in the MVC world. This makes the application easy to migrate to another language.
Why do you think so? This makes perfect sense to me - imperative language wraps purely functional one, and sits on top of declarative, relational language(s)[1] for data storage and manipulation.
The GP is using a very well thought out configuration; this is using the right tool for the job incarnate. If I wasn't lacking in SQL department I would probably do exactly the same (probably replacing PHP with something strongly and maybe statically typed).
[1] SQL and XML seems a bit redundant, but I don't know what they are used for exactly. Also I lumped both SQL and XML together as "relational" because of XQuery, but I admit that I don't know much about the latter and this may be not accurate.
Long ago I learned that system source code is not as important as data. You can always hire hot-shot software developers to (partially machine-)translate the system into the langue du jour.
Using XML allows means the data associated with every "page" in the system automatically doubles as a service (SaaS). XSLT allows those those services to be translated into JSON, ASCII, PDF (via LaTeX), XML, or the format du jour. With this architecture, the amount of time to publish a new export format for every "page" in the system is reduced to the time it takes to write a new XSL template: hours to a few days.
All pages can reuse the same code to render themselves:
What language can make every page output XML, PDF, JSON, or ASCII, without changing the business logic, data model, or spending more than a few hours developing each new format?
What lack of separation? Don't take this the wrong way, but have you ever actually tried to use PHP in a non-web context? Running "./foo.php" is just as easy as "./foo.py", "./foo.rb", etc. All of these complains seem to come from people that have never even tried to do this kind of stuff. It's damn easy.
If you echo HTML, you get HTML. If you echo binary data, you get binary data. JSON, XML (including SOAP bodies), text, nothing at all, file i/o, direct socket connections, exit codes - all are supported equally well. The only thing vaguely related is the HTTP headers that you get for free if you're running it behind a fastcgi module (apache's mod_php, nginx/php-fpm, etc).
Hey, it sounds as if you don't know what you're talking about - at all.
You can write a single PHP file that includes HTML, Javascript, MySQL, CSS and PHP, but that would make you a bad developer, or it's such a simple one-off thing that you don't worry about it.
Or, you can develop with maintainability in mind and separate those 5 concerns out.
> You can write a single PHP file that includes HTML, Javascript, MySQL, CSS and PHP, but that would make you a bad developer, or it's such a simple one-off thing that you don't worry about it.
Tools facilitate workflows. The fact is, PHP very strongly facilitates your "bad developer" path. That's why there is so much PHP code that goes down that path, compared to other languages.
Yes, you can go off on a better path. But better designed tools make it much more easy and natural to do things the "right" way.
PHP makes your "bad developer" path the path of least resistance. That's bad.
This isn't unique to PHP, by any means. Visual Basic was much the same, even in later versions where you actually could write well designed code if you knew what you were doing. The IDE, documentation and design of the language encouraged you to make bad design decisions, much like PHP.
.Net languages aren't immune to this either, particularly Windows.Forms and ASP.net. To write decent code in those, you basically have to fight the IDE and the framework every step of the way. ASP.net MVC makes it much easier to write good code, at the cost of being harder to user if you don't already know what to do. Your average newbie can't just point and click until he's half way there.
PHP has decent frameworks, like Symfony. They make it much easier to do the right thing, and harder to do the wrong thing, at the cost of being more difficult to learn.
Props to the Symfony team though. They're still trying to make something good out of PHP long after most other decent developers abandoned the platform on favour of something less newbie-driven. It helps a lot to have that kind of framework available, just in case I have to use PHP for something.
Edit: Accidentally said that ASP.Net MVC encouraged bad code, but meant it encouraged good code.
I do PHP a lot, and no serious project uses PHP dirctly to render HTML. Well, I've seen PHP templates, but they are always separate from the actual code.
I think PHP's success is due to several factors:
1) Easy to set up and start. It even has a built in web server now.
2) Lots of useful functions.
3) Lots of useful extensions.
4) Weak datatypes. Newbies don't have to deal with too many error/warning messages. (and yes, i wish PHP had a strict typing mode).
5) The documentation is absolutely amazing (at least for the popular things).
6) The community. Even before StackOverflow, your PHP questions would be answered instantly.
Yes, PHP has its problems, and it does allow you to easily mix the PHP, HTML, JS all in on file, but while many people consider that as a path to shitty code, I consider it an easy way to tinker and try things, which is very valuable for beginners.
Security holes, or just bad practices in general.
My biggest gripe with PHP is that every CMS, framework, custom built site uses a different style, some echo HTML some even output HTML in the middle of a class definition etc.
I remember reading popular Joomla! extension that counted the number of elements in a one dimensional array with a for loop.
They are just the language of the year, this year it will probably be all about go and node.js and maybe next year it will be about Steve's Language and ASP.
Moral of the story is, it's just whats in season this year. Some people will argue better languages, but really there are problems with all of them.
If you want to do freelance work, learning PHP (or ASP) is mandatory. Sure, Ruby is great, but you'll keep stumbling on :
"our shared host is PHP only, we don't want to change for another"
"we want wordpress"
"our computer guys know a little PHP, we need PHP"
"what the fuck is Ruby ?"
So you'll try to educate your client, to explain why Ruby us great. But you'll fail, because most clients don't give a shit and, for their very basic needs, PHP is as good as ruby.
I think it makes sense to learn PHP. The only money i'm making right now is javascript (working on Business Catalyst sites) and Wordpress (custom themes and plugins.) Many decent self-described programmers would consider it shitwork, and they'd probably be right... But there's a lot more PHP work out there right now than there is Python or Rails.
The problem with php is that there is no central registry where you can submit your own module like Ruby gems and npm registry for node.js. It feels like you have to reinvent the wheel every time you work on something new...
because it works.
q&d scripting to applications. its easy to write bad code in any language, one of my favourites is forth - write only is fair comment, maintaince?
php - easy to use, easy to abuse.
>If you find yourself repeatedly putting down a technology, then take some time to actually learn and use it. All the jokes and snide remarks aside, Perl is tremendously useful. Ditto for PHP and Java and C++. Who wins, the person who has been slamming Java online for ten years or the author of Minecraft who just used the language and made tens of millions of dollars?
I think we've reached "Peak PHP" our data[1] shows PHP isn't growing at all in the top million sites and Netcraft's data reflects that if you take the "active sites" bar back to the middle of 2011.
66 comments
[ 5.2 ms ] story [ 179 ms ] thread[1] http://news.netcraft.com/wp-content/uploads/2013/01/php-tren...
It's the reason I picked it up back in 2001. Being a C programmer up until that point it made the transition to web development incredibly easy.
On a side note, I still remember how awesome being able to do `"some string" == $var` was.
A novice can just pick up PHP and run with it. She can start blindly with unstructured code, then move to methods, then finally to OO.
The downside, of course: http://www.flickr.com/photos/raindrift/sets/7215762949290803...
The common wisdom is that PHP's success is due to ubiquity, deployment, and low barrier to entry. While all those are true, the fact that so many web-focused tools are baked into the language itself (meaning minimal time to hunt/learn/evaluate third-party libraries) shouldn't be ignored.
On the other hand there are languages like Opa and Ur/Web or Racket instaweb dialect which do include language construct specific for web, for example static typing for forms, send/suspend or statically typed xml expressions.
I may be wrong on this and I would welcome a correction from someone better informed on the matter.
Please don't use @
Oh, I just thought that maybe php.ini is another thing that's specific to the web... But I'm not sure, for example there is site.py file in every Python distribution which effectively serves the same purpose, just uses Python instead of ini format.
Anything else in the language? I'm really curious.
That being said, the PHP ini is a config file that defines some of PHP's runtime parameters and, in some cases, controls modules and drivers that have been installed for PHP. The closest thing I can think of comparing it to would be the JVM config.
I use PHP for a crapton of scripting as well, namely scraping, which has nothing to do with PHP's web app capabilities as that all leverages curl.
While obviously a bad practice, it also enables non-devs to organically learn the language in bits and pieces. Sometimes they move on to create hugely influential platforms like MediaWiki and Wordpress, sometimes they just build very hard to maintain websites. PHP in a nutshell.
People have started using this and I find no reason to tell them "it's bad practice", although it only spares 5 chars typing...
For example Erlang's `receive...after...end` and `!` are language constructs that are specific to the domain of message passing concurrency and they cannot be used for anything else. On the other hand Erlang's bit syntax is specific to the domain of writing binary network protocols but can be used for extracting data from binary files or constructing chunks of bytes for interoperability with C (structs).
There are many more such examples in various languages - despite being "general purpose" they frequently include features and constructs useful for some specific domain - it's a natural way the languages are created and evolve.
Unfortunately, as far as I can tell, it was created from the View perspective of MVC. PHP in my mind is equivalent to the special language of a template processor library of some other more general language.
I strongly disagree with your implication that it's only useful as a presentation layer, however. Some quirky syntax doesn't at all make it an incapable language; the real problem in my eyes is there's no one go-to framework for MVC work, a la Rails or Django (there's no shortage of choices, but that's not necessarily a good thing).
I would say there's a lot of consensus around Symfony
http://symfony.com/
Heck, the second Google hit for "php mvc framework" for me was a 2009 guide to writing your own (talk about not getting the point of a framework). There were two more pages in the top ten for PHP MVC framework comparisons.
Ha ha ha... yeah... writing your own php framework... who would do such a thing...
I understand why it's supposed to be a bad thing but I also think it helps to understand the principles involved in frameworks and the mvc pattern, and one way to do that is try to make your own. Then when you pick a real framework it won't seem like magic.
That's not what I meant. I meant that it was created from the perspective of a View. There's no other reason that php code has to be delimited with <?php ?>, other than it was originally designed to be embedded in html. This alone shows how the creators envisioned PHP to be used.
For non-trivial web applications, the "rendering HTML strings" is one of the smallest parts of the job.
The lack of separation between application and HTML output in PHP may be an asset when starting out or when making lightly scripted web pages, but when creating an application that just happens to be served up over the Web (and possibly served up other ways too), those general-purpose languages are much more natural fits for the job.
The GP is using a very well thought out configuration; this is using the right tool for the job incarnate. If I wasn't lacking in SQL department I would probably do exactly the same (probably replacing PHP with something strongly and maybe statically typed).
[1] SQL and XML seems a bit redundant, but I don't know what they are used for exactly. Also I lumped both SQL and XML together as "relational" because of XQuery, but I admit that I don't know much about the latter and this may be not accurate.
Using XML allows means the data associated with every "page" in the system automatically doubles as a service (SaaS). XSLT allows those those services to be translated into JSON, ASCII, PDF (via LaTeX), XML, or the format du jour. With this architecture, the amount of time to publish a new export format for every "page" in the system is reduced to the time it takes to write a new XSL template: hours to a few days.
All pages can reuse the same code to render themselves:
This cleanly separates business logic and the data model from presentation, plus much more. Perhaps it is masochism, though. ;-)Having to duct-tape XSLT on top of PHP just because PHP can't cut it is rather perverse.
The only thing I can think of that's worse than "programming" in XSLT is ColdFusion.
If you echo HTML, you get HTML. If you echo binary data, you get binary data. JSON, XML (including SOAP bodies), text, nothing at all, file i/o, direct socket connections, exit codes - all are supported equally well. The only thing vaguely related is the HTTP headers that you get for free if you're running it behind a fastcgi module (apache's mod_php, nginx/php-fpm, etc).
You can write a single PHP file that includes HTML, Javascript, MySQL, CSS and PHP, but that would make you a bad developer, or it's such a simple one-off thing that you don't worry about it.
Or, you can develop with maintainability in mind and separate those 5 concerns out.
Tools facilitate workflows. The fact is, PHP very strongly facilitates your "bad developer" path. That's why there is so much PHP code that goes down that path, compared to other languages.
Yes, you can go off on a better path. But better designed tools make it much more easy and natural to do things the "right" way.
PHP makes your "bad developer" path the path of least resistance. That's bad.
.Net languages aren't immune to this either, particularly Windows.Forms and ASP.net. To write decent code in those, you basically have to fight the IDE and the framework every step of the way. ASP.net MVC makes it much easier to write good code, at the cost of being harder to user if you don't already know what to do. Your average newbie can't just point and click until he's half way there.
PHP has decent frameworks, like Symfony. They make it much easier to do the right thing, and harder to do the wrong thing, at the cost of being more difficult to learn.
Props to the Symfony team though. They're still trying to make something good out of PHP long after most other decent developers abandoned the platform on favour of something less newbie-driven. It helps a lot to have that kind of framework available, just in case I have to use PHP for something.
Edit: Accidentally said that ASP.Net MVC encouraged bad code, but meant it encouraged good code.
I think PHP's success is due to several factors:
1) Easy to set up and start. It even has a built in web server now.
2) Lots of useful functions.
3) Lots of useful extensions.
4) Weak datatypes. Newbies don't have to deal with too many error/warning messages. (and yes, i wish PHP had a strict typing mode).
5) The documentation is absolutely amazing (at least for the popular things).
6) The community. Even before StackOverflow, your PHP questions would be answered instantly.
Yes, PHP has its problems, and it does allow you to easily mix the PHP, HTML, JS all in on file, but while many people consider that as a path to shitty code, I consider it an easy way to tinker and try things, which is very valuable for beginners.
For a starting developer, does it still make more sense to learn PHP?
You'll have to be extra-diligent about making sure the sources you're learning from aren't full of security holes, however.
If you want to see quality, look to the new generation PHP frameworks: Zend Framework 2, Symfony2, for example.
However, newer projects and startups are moving towards Python and Rails so if your goal is to be in that game, learn one of those.
There's an immeasurable amount of new work to be done in PHP. You have absolutely no numbers to back up your statement.
Moral of the story is, it's just whats in season this year. Some people will argue better languages, but really there are problems with all of them.
"our shared host is PHP only, we don't want to change for another" "we want wordpress" "our computer guys know a little PHP, we need PHP" "what the fuck is Ruby ?"
So you'll try to educate your client, to explain why Ruby us great. But you'll fail, because most clients don't give a shit and, for their very basic needs, PHP is as good as ruby.
(not that I know either... yet...)
[1]: http://getcomposer.org/
If you want to get your feet wet with a multi-user web application, I recommend trying Sonata's sandbox: https://github.com/sonata-project/sandbox#installation
Composer just happens to use packagist as a default repository. It alone is not a repository.
http://pecl.php.net/
http://prog21.dadgum.com/123.html
[1] http://trends.builtwith.com/framework/PHP