Why PHP continues to thrive in the age of the PaaS
plus.google.com
plus.google.com
I was absolutely blown away by how much work it required to get started. That, and how painful it was to explain to a non technical person how to make visual changes.
I was told by a few friends I vented to that what I was doing was "too small" of a project, or "Rails is meant for web apps" which confused me because I assumed a site where you could upload images via a form and then browse and view them was right up its alley.
Edit: A lot of comments are talking about wrapping my head around the framework, MVC, ect. I had no problem building the initial application. My sore points are more about deployments and updating smaller things, like the image of a link. non-technical people don't often remember "oh, and if you want your change to show up, go to this folder, open 'restart.txt' and change it in some way. doesn't matter what, just add a space to the end".
Rails is great for creating a site with a form where people can upload images, it's a 20 to 30 minute project in rails, pretty much just take any rails blog tutorial and add paperclip. (Note, it's not a 20 minute project for anyone who doesn't already know rails)
Rails is not for non-technical people. Rails is like a great jig, if you're a master craftsman it's going to save you a lot of time, if you're not don't bother, just tweak things until they fit together. If you're someone who has spent the last 5 years building furniture by tweaking things then you will love a jig.
With Ruby, I have to spend, at least 3 months learning the concepts behind the Rails framework and what the article OP mentions just to get to that 20 to 30 minute mark.
If anything it's all meaningless, and what everyone should understand is that while the closer you are to the web server itself (CGI+PHP, Node.js, Classic ASP), you can quickly create any type of code, at the loss of organization and order.
In frameworks (criticism of Rails can also be attributed to Wordpress IMO) you have a much larger ramp up time learning the concepts and conventions, and once familiar, are able to LEVERAGE those patterns.
But don't bother me with PHP vs Ruby. I run SSI on nginx. It's not even in the same league as those two. BUT it's even easier to spin a basic 5 page website. All tools have their specialties.
In the second you say it takes 3 months because you have to learn the framework. Honestly if it takes you 3 months to understand rails well enough to do a CRUD app there is no way you're learning PHP well enough to do the same CRUD app in less time.
The only possible way to program PHP is to be pretty much ignorant of everything in which case PHP will actually do kinda what you wanted. If you learned PHP then either it's not actually doing what you think it's doing, or some config variable changed and would have done what you thought except it didn't, but don't worry just add some code to change that config variable for a while, and then change it back.
PHP is zen.
There is a story of a young, but earnest PHP student who approached his teacher, and asked the Master, "If I work very hard and diligently, how long will it take for me to learn PHP?"
The Master thought about this, then replied, "Ten years."
The student then said, "But what if I work very, very hard and really apply myself to learn fast. How long then?"
Replied the Master, "Well, twenty years."
"But, if I really, really work at it, how long then?" asked the student.
"Thirty years," replied the Master.
"But, I do not understand," said the disappointed student, "at each time that I say I will work harder, you say it will take me longer. Why do you say that?"
Replied the Master, "When you have one eye on the goal, you only have one eye on the path."
Can you point me to some resources which don't fall into the trap you highlighted?
What I like about it is clean separation, a few command for common things, and if SSI doesn't directly support what you want you just hand it off to another program.
That's not one hour. That's one minute.
Requiring a professional is a flaw, not a virtue. It's particularly problematic in our industry, where the end-user and most of the people involved in the production are not professional programmers.
Just as you'd never want to use an AED at a hospital (unless every medical professional was unavailable)
Your statement depends entirely on the context. I agree that requiring a professional to assemble my IKEA furniture would be a flaw. Requiring a professional to assemble my custom marble kitchen countertop totally makes sense and I'd hardly slam IKEA for not having such a package in Aisle 12.
Don't you think that depends mostly on whether there are professionals available?
I can do your app in Rails pretty damn quickly at this point (with one of my current skeleton frameworks I can add authentication administration and other nice features pretty much "for free" as well)
But tell me I have to do it CodeIgniter or Laravel and I'd be completely lost for days.
I've heard someone call PHP "the C web framework". I thought it was fitting, and in addition, it seemed that even as a C web framework, it was a failure.
I think you're in the wrong place. Reddit is this way.
CS-wise (and design-wise), it's very much a failure. It's a market success, though - just like VHS was, many years ago. ;-)
I'd like to also point out that if you want to do software dev by the book applying various sofware engineering principles and not just stringing something together that works, you're pretty much forced to use a framework. (either due to lack of time or lack of skills for building one the right way).
Sure, sometimes the most important thing is rolling something up quickly, but other times your project will be used by more than a handful of people, and/or you'll have expectations of producing monetizable value and anticipate regular maintenance/upgrades for which a different strategy is required.
When you're first starting with it, especially moving from creating PHP files, it seems very counter intuitive and over complicated. But once you get used to the layout, you understand why it really is far superior for creating websites.
They take longer to get set up, but as your project grows the incremental work to "change one small thing" stays relatively constant, whereas coded from scratch php or lightweight frameworks tend to have complexity of a change that is exponential with the number of lines of code.
It's a question whether the investment is worth it for what you're trying to do. Sometimes, quite reasonably, the answer is no.
I've got my django routine to the point where it takes me about 30-45 minutes to spin up a new stack that I'd be happy to code on for years -- to me that's a relatively minor investment for huge rewards.
I didn't mean for my comment to come off as snobby, I just hope you don't discard rails/ruby (or branching out from php) because you feel it's not the easiest to work with out of the box (even if only for non-technical people).
1 - A php script on a server with a script with some code on it.
vs
2 - A full featured MVC framework, complete with version control, database integration, easy deployment, which is easy for other developer to jump into, etc etc
How can these two options be equated?
Like you said, they're very different entities, but a lot of people can't tell or don't care about the difference.
Ah, your assumption was correct but incomplete. Doing that and a bunch more is right up its alley, but if you're doing only that, there are much easier ways.
Most companies/clients, particularly outside of the SV/SF bubble, value a working solution over technical elegance. They're not irrationally ideological about programming languages, and they don't want to pay $120,000/year or $125/hour to a developer with two years of experience.
Given the supply of developers of various skill levels who can build working solutions using PHP, and the number of existing commercial and open-source applications based on PHP, it's no surprise that PHP is thriving.
> But the question is, why should PHP still be easier to deploy than Ruby/Rails, Python/Django, Node/Express (or Metro)?
It's interesting that the author grouped Ruby, Python and Node with frameworks for his comparison to PHP sans framework.
Incidentally, I think one of the advantages of PHP is that a lot of PHP developers, especially those who have been working with PHP for some time, didn't get started with a framework. Heck, before there were mature frameworks, many PHP developers rolled their own frameworks and micro-frameworks, a valuable exercise.
Third party frameworks are great, but they can easily become a crutch, and when you don't know anything but the framework, they can be downright dangerous.
What percentage of Ruby on Rails developers who started their careers with Ruby on Rails are capable of building a moderately complex Ruby application without Rails?
Mainly because people rarely talk about pure Ruby/Python/Node CGI development. They're almost always run through an app server.
I realise there are indeed some excellent PHP frameworks nowadays, but to my knowledge, most can still be run in a basic CGI environment. And more to the point, probably the majority of quick hacks in PHP are still done without any framework.
[BTW I meant Meteor, not Metro.]
This, however, is going to be an unpopular opinion amongst the PHP crowd, but I can distill the rest of your comment into the following statement: "PHP is thriving because companies are cheap, don't care about quality as much as cost, and there is an over-abundant labor supply of poorly skilled, mainly self-taught PHP 'developers' who are willing to work for peanuts and get the job done to an adequate level." There's nothing inherently wrong with that, but trying to turn it on its head by implying developers skilled with, e.g. Ruby/Rails frameworks (see note below), are essentially overpaid and narrow-minded is just absurd.
Note: I especially am not a fan of Ruby, so don't take this as a defense of the language or its developer-adherents. I'm actually fairly language agnostic; "right tool for the right job" and all that.
That's an interesting reading of my comment. A less cynical reading might be that companies tend to:
1. Value cost-efficiency.
2. Understand that the constraints of time, cost and quality are all related and must be balanced based on business and project need.
3. Recognize that a smaller labor pool tends to increase cost and risk, sometimes unacceptably.
Most companies simply don't have the luxury of, without regard to cost and schedule, writing blank checks for development, demanding perfection (elegant code, the technologies du jour, premature optimization, etc.) and limiting their employee/contractor pool to rockstar engineers with CS degrees from top universities.
I worked for a typical megacorporation for a few months (in Maryland). This is consistent with what I've observed. the company's main goal is to do what's required as cheaply as possible.
That said, Rails is starting to become more popular among the enterprise crowd. The main reason for it is that developers are more productive with Rails (given that they are working on a nontrivial project and have prior experience).
> What percentage of Ruby on Rails developers who started their careers with Ruby on Rails are capable of building a moderately complex Ruby application without Rails?
I think the main problem is that a lot of people try to learn Rails before learning Ruby. We end up having a lot of people who are experienced with a particular framework (Rails, jQuery, whatever)... but they know basically nothing outside that framework.
PHP is also one of the easiest languages for Designers to learn. If you know HTML, adding a few bits of PHP is easy.
Even if you dislike PHP, (I certainly do) you end up getting good at it because enough projects touch it that you kind of have to be good at it. It is like JavaScript, I don't like JavaScript as a language, but it is essential because you can't not know it.
In 10+ years of professional web development, I've had, I think, 1 client ever who had PHPBB on their site, but I work on at least 1-5 sites a month that are running a variation of WordPress (or just PHP in general). And every new site we setup is running WordPress on the back-end now.
I've also never had a client come to me who was running a Ruby, Python, etc, system. The strangest it has gotten was a Cold Fusion site here and there, and maybe once a year a .Net / ASP site crawls through the door..... and we have pretty religiously completely converted the sites to PHP in these cases before we start to manage them.
I think the pervasiveness of modern, complex js techniques in recent years have been eroding that situation, because (especially with the gentle on-ramp of jQuery), PHP programmers are forced to become good js programmers too. Right now that means that a lot of the parochial attitudes of PHP programmers end up in the js community - and you see that in node.js, but ultimately it means that those programmers become familiar with two extremely different programming paradigms, and that will make a third language a lot easier to learn. When not trapped, they will leave.
I never understand the argument that PHP is an easy language (which this post doesn't suggest), though. PHP is hard because it is awful, and it's awful because it's hard. Consistency and lack of hidden state make things easier, at least for me. PHP is an easy language to put into production. Ruby is an awful language to put into production. I'm not even sure why the two get compared other than that Rails is supposed to be "easy" and PHP is supposed to be "easy."
A better feature to use to compare Ruby and PHP is that both of them fall to shit pretty immediately at load unless you are so good at enough layers of the entire stack that you're running on that any ease of learning or using PHP and Rails will make a minimal difference to you.
having to execute the whole application from the entry point on every page hit is just awful. APC will only save you the loading from the disk and compiling part, not the whole execution chain.
with node and others the application is just sitting there, listening to a port, and fires the right callbacks when a request comes in. the application startup cost is paid once. not on every request.
there are people who have tried to reproduce it in php by having php running and serving multiple requests in a similar manner. This is really treacherous since php didn't even pretend to free memory under any circumstances ever, until about php 5.3.
since moving over to writing servers, i just feel that the php model of executing the script when a url is hit is just fundamentally wrong.
> APC will only save you the loading from the disk and compiling part
Is that not the slowest part?
According to the benchmarks here, http://www.techempower.com/benchmarks/#section=data-r7&hw=i7..., PHP is only really slower than Node in serving up a plaintext response and a json serialization (although, it is only about a 5% difference in responses/sec between the two).
If you already know RoR and have your dev machine and deployment environment all set up, then it's not hard to get a Rails app working. Rails has a significant advantage with the use of gems (and bundler, etc.) for easily adding complex features.
I still use PHP for my home projects most of the time because I haven't bothered to set up Rails on my VPS, so the effort it would take to do so just isn't worth it compared to how easily I can drop a PHP app in place. (I am using a framework in PHP too.)
But then, the author was talking about PaaS not setting up Ruby on a VPS. So in that case it's probably just about how comfortable the developer is with each language. I'm a bit more comfortable with PHP because I don't like debugging Ruby GEMs that use instance_eval black magic for DSLs and/or have to be inserted as Rack middleware. Not unless the project is large enough to make Ruby gems worth it.
(Eg. if I want good unit and integration testing. For home projects I rarely do integration testing. E.g. #2 was rack middle ware for REST API.)
In PHP, you need to learn some HTML, some SQL, and general web concepts that Rails hides.
No, learning isn't bad. No, I don't think scaffolding is acceptable. I've used PHP since v3, and Rails for a couple of years, and many other languages since 1999, and I'm just trying to get into the beginner's head.
PHP has similarities to Bash scripting. Language sucks. Syntax is awful. You wouldn't want to build anything big with it. You feel dirty and ashamed every time you use it.
But... if you just want to get shit done, it's often the path of least resistance. I can live with the shame.
By the way, Mike isn't just talking about PHP here. It also applies to CGI, ColdFusion, ASP, JSP and lots of other old technologies that make you want to cry. Basically anything where you have a web server and you can just drop executable scripts in a directory.
Even though I rarely use PHP any more, I still write a lot of my Python and Ruby web-apps using classic CGI instead of the popular frameworks because it's just so quick and easy (and dirty). Deployment is a breeze, managing servers is simple and it's ideal for quick mashups. Been meaning to write more about this: http://helpmewrite.co/people/joewalnes/ideas#idea-1978
Combined with a better overall language (that still has it's warts, lets be clear here) and an ever expanding amazing ecosystem of great libraries and you have something that is easy to deploy _and_ fun to work with.
Thinking LAMP as a whole - the speed of new versions of MySQL (5.6, 5.7) and the Percona branch are also pretty sweet.
But Memcached, APC, and wrappers for Redis probably have done the language much more of a service in ways...
When it comes to PHP, I always remember that when it comes to the tools, you can do almost anything with almost any other tool. And the flamewars are just waste of time.
Many people say PHP is not elegant. Yeah, it's far from perfect. But have you written any PHP app recently? The answer is almost always no. The fact is that normally, you heavily use a framework and your interaction with 'naked' language is minimal. I mean, the shitty naming conventions (or lack of) and etc has minimal effect.
Just here comes another problem, there are just a LOT of half-assed frameworks. And for some reason many devs like to roll out their own one. Usually not the good devs.
But on the other hand, some frameworks are around for many years (well, in Web 5+ is many) so probably 99% of the issues you will have were faced by someone else already, and the solution will be in the first google result.
In conclusion, no it's not perfect in some ways (nothing is perfect, anyway), but it lets you get the shit done very easily.
I am just not one of the people who get religious about the languages. You use PHP? Cool. You prefer Ruby? No worries, that's fine for me!
Most of the same things we say about PHP deployment (it's easy, can be done in one file, etc) could equally be applied to writing CGI scripts in Ruby or Python. PHP is just a more extreme example of CGI, and arguably easier, because there's so much support for PHP-based CGI compared to Python/Ruby/Node CGI.
But the pay rate for PHP developers is miniscule because every Pakistani and Indian is a PHP expert for $1/hr. Try to post a $20 professional website job on Elancer - and in 10 minutes you'll get 20 lancers eating each other for your "business".
So "thriving" is to be taken with a grain of salt.
Lolz.
There's also a ton of complete software solutions available, like phpBB, vBulletin , Wordpress etc. The PHP industry offers more scripts for a one off $x download which can then be deployed via FTP by a non-technical person who doesn't know git.
The rails/django ways seems to be to sell everything as SaaS. The upshot of this is that a non technical person can get something started with a PHP based system, so by the time they call a serious developer in to help there is already inertia.
For a simple pages with no prior coding experience, PHP is the best tool for the job. However if you plan on building complicated web apps as a profession, then perhaps learning a better tool is worth it.
For example, you can replace Visual Studio with PHP in this image:
Deployment, Staging, Package Management, etc are worth their weight in steps over the long run.
Like a few people have mentioned, Boiler-Plate/Template projects are how many of us work around quickly bootstrapping a new project.
* decide which *(c|s)gi package you want to use
(thin, webrick, gunicorn, unicorn, puma, tornado, 100 more)
* write your own supervisord/circus/god/whatever
wrapper to make it restart automatically
* fight rvm/virtualenv/chruby/whatever
Notice a pattern? I can deploy a sensible, non-minimal php web app with "apt-get install nginx php5-fpm && scp" whereas I need already a decent amount of decisions for the other 2.With PHP deployment only gets complicated at a larger scale. With Python and Ruby web apps it's complicated from the start.
When I used to be a Ruby developer, every time I heard that "PHP is easy to deploy", I made a less-than-one-minute demo showing how to create a Sinatra app from scratch and deploy it on Heroku is just few commands (any Sinatra dev here can do it).
This assumes you've setup your keys properly, and have a grasp of this already. If you're assuming prior knowledge and configuration, would the same be true of setting up your Heroku toolchain?
Insert into Filezilla, and mission complete.
For the sake of comparing, here's how I make a throwaway app super quickly in Ruby, almost equivalently to a PHP deploy:
$ ssh server
$ kenji init project # [1]
$ cd project
$ tmux # launch a background session, edit some code
$ bundle exec rackup # in a pane next to my code
Boom, brand new web-app is running on my server in less than a minute's work.[1]: This is a Ruby web-app microframework. https://github.com/kballenegger/kenji