PHP needs to die. What will replace it?(seldo.com) |
PHP needs to die. What will replace it?(seldo.com) |
Examples aplenty.
Wow, that's a pretty strong statement. I would like to see some sources for it or at least further explanations.
Get a hobby, you won't hate PHP so much ;)
Uh. http://www.indeed.com/jobtrends?q=perl%2C+php%2C+ruby
I think newbies just found easier languages to work with than Perl for web dev, which says nothing about the use or demand for Perl in industry.
Change that infinitive to "to deploy", and you're spot on.
PHP will likely be replaced, but not for a long time and it will take time. And there are still a lot of perl hackers out there too, none suffering (aside from having to use perl).
so you will need something equally instant-gratificational.
only without the horrible warts
rails was too clever. stupid people are afraid of clever.
I don't see anything to hand.
PHP has already been replaced by Ruby/Rails as the good thing that should be used for new projects. Only PHP developers don't see that.
You lost me when you tried to argue that ORMs are not useful. Its easy to see why PHP developers think that, though.
I'm all for a PHP alternative. I use it because it's ubiquitous, but I have no love for the syntax or the internals. But the only way you can compete with it is to have the same kind of momentum mixed with the kind of frictionless use that comes standard.
You aren't going to convert the masses of php hacks with an opinionated and rapidly changing framework like Rails. These are people who still mix logic with templating and you want them to learn an ORM, Coffeescript, Sass and Moustache?
> You lost me when you tried to argue that ORMs > are not useful. Its easy to see why PHP > developers think that, though.
Really? So the object-relational impedance mismatch problem isn't real? You lost me when you completely ignored the real engineering trade-offs involved in choosing abstraction layers like an ORM. Its easy to see why Ruby developers think that though.
The PHP app I am currently saddled with generates anywhere from 100 (absolute minimum) to 40,000 MySQL queries on every single page view thanks to a developer who didn't know what ORMs are for and was clearly behind the curve when it came to architecting scalable applications.
I have never seen a PHP application abuse a database connection so thoroughly in my life. If he had just stuck to a nice, lightweight PDO wrapper and been able to craft some decent SQL statements, we wouldn't be rewriting this thing right now.
It sounds like you've already lost.
In fact, I'll go so far as to say that what you're saying is indicative of the kind of out-of-touch response that keeps any of the proposed alternatives from replacing PHP.
Java, C and C++ are viable solutions, due to their popularity.
1. To be on all shared hosting everywhere. I.e. you need to be really easy to install, and preferably not involve long-running processes that shared hosts might choke on.
2. To be beginner friendly. No requirement of understanding MVC, or running commands in a shell (hi RoR!). Pure instant gratification. Someone's first step into using PHP is likely going to be "I want the current date in the footer of my page", or "I want a random image on my homepage", or something like that. Anything like that you can handle by taking your existing page and dropping a tiny snippet in where you want the change to happen. <?=date('Y')?> is a potent thing to someone who has never programmed before.
(Note: For point 2 many of the things serious programmers hate about PHP are actually advantages. All the functions in one big namespace? That's great! A newbie doesn't have to try to understand `<? import datetime; print datetime.date('Y'); ?>.)
It's easy to replace PHP for serious developers. We like advanced features, and care about a sane default libary. We're willing to use complex tools to get a payoff.
It's hard to replace PHP for non-programmers who just want to tweak their static page in notepad, or install a blogging package on their cheapo shared hosting.
To sum up: if you don't address both of these points then you haven't killed PHP. You're competing with Python or Ruby or whatever. PHP will carry right on ignoring you, because you're not addressing its fundamental use case.
I have to say that I was pleasantly surprised by some of the new language features that php has borrowed from elsewhere... eg: closures, anonymous functions, docstrings.
IMHO php is held back primarily by messy, inconsistent documentation and extremely ugly parts of the core library that are also riddled with inconsistencies that should have been deprecated years ago.
Not that I would consider starting a new project in php - I just love programming too much for that; but I believe php will evolve, benefiting from other languages.
Really, it needs it's own "Python 3" (out with the old, smarten up the new).
Those of us who have been working with computers for a long time - particularly those of us who write code - too easily forget what it's like to be that true beginner and often have a very different idea of what 'trivial' means compared to the beginner. What might barely be a speed bump for us can often be an insurmountable obstacle for them and I really wish I was better at remembering this more often.
My current favorite example of this (ignoring the naming scheme for string functions entirely) is that in_array and strpos are functions that perform (almost) the same task, on two different types. They take their arguments in the opposite order. strpos($haystack, $needle) vs in_array($needle, $haystack).
To me, the best thing about PHP is that it is so easy to deploy to pretty much any shared hosting on the planet, not to mention really easy to set up on your local machine (with WAMP/MAMP).
I love Rails, but on many occasions have built projects in PHP (using a decent framework like Kohana) just because I was putting this on my client's shared hosting account and didn't want to deal with having them get a new server, or just plain setting up Rails. Yeah yeah, I know there's passenger now, etc. -- still not as stupid easy as dropping a php file into a web directory (and assuming that Apache is set up with mod_php, or FastCGI or whatever -- which it always is).
Rest assured that I would rather hire a good PHP developer than this guy to code in Ruby.
PHP >5.3 has lambdas: http://ca3.php.net/manual/en/functions.anonymous.php
PHP >5 can support easy method chaining if you return $this from your method.
Lambdas are not yet common, but method chaining is already easy to find in most well-designed PHP libraries and frameworks.
Code that writes your boilerplate for you is helpful and all, but if your language requires a pile of boilerplate to get anything done, then something is already wrong.
If the same functionality is implemented, the code is being generated somewhere. Ditto with his dismissal of Ruby on Rails because Rails is not built into Ruby like PHP's web app support is.
then what PHP is lacking is lambdas and method chaining.
Does the author know anything about PHP at all? As far as I can tell method chaining has been available as long as PHP supported OOP and Anonymous functions have been supported for several years since PHP 5.3 was released.
This makes it really hard to take the author and the article seriously.
The author doesn't know about any other languages either, it seems.
I stopped reading when he argued that PHP's assocative arrays was an advantage; hashes/dictionaries are in all the scripting languages. (Afaik, they come from AWK by the way of Perl, anyway -- they were created many years before PHP existed.)
>> the critical thing Perl was lacking was PHP's wonderfully flexible "associative arrays"
I grabbed my copy of "Learning Perl" from 1997. Chapter 5's topic? Hashes.
Let's replace it with "Here's how we can improve."
Honestly, we may be best off doing a CoffeeScript style pre-processor for PHP. Because PHP isn't going anywhere, no mattter how much we may prefer other languages, PHP's popularity is one of pure pragmatism, something the language purists don't seem to understand.
Get me from 0 to "Hello, World" as fast as you can. That's how you build the next PHP.
Look at what everyone is doing right now: make an app in javascript+html5+css, serve those static files, and feed the app with json. Save bandwidth, scale easier, and just have better control of the display by manipulating the display directly.
tl;dr - Nothing will replace PHP, because no one is making tools for that case (file-oriented-web) anymore.
The truth is that for professional, skilled developers, mastering their Nth language is an increasingly smaller investment compared to their first.
But for people north of HTML coders and south of professionals, they have a lot invested in the scripting skills they've developed and nobody is interested in seeing the value of their investment diminish for a reason like this.
People here always tout PHP's installed-base as a big "plus" for the language. But I think more than that is the mindshare.
It seems like you can't mention PHP without people inferring that you're a lesser programmer or that you clearly don't know what you're doing.
There is no need for any language or framework to "die".
If you do not like PHP (or Perl or Python or COBOL or Ruby or Java) just do not use it. There are plenty of alternatives.
If you and your team can be productive with any of these languages, go for it. PHP with modern OO-frameworks, like Yii, can support rapid development of complex web apps just fine. Facebook runs just fine on PHP even without any 3rd party frameworks. The proof is in the development and deployment. The only way you can "kill" a language with so much support is to offer something 10x better or create some exclusive tie-in. Where is that magic offering?
Vote with your feet and dollars and just take it easy. There is no need to fight the imagined oppression.
The post isn't comparing PHP with no frameworks versus Rails. Indeed, the author's conclusion is that Rails doesn't sufficiently separate itself from PHP with an MVC framework (and he listed a few).
I know news is slow these days, but this kind of posting needs to stop.
After that comes PHP's special flavour of OOP. I'd prefer to call it 'Do Whatever The Fuck You Like Orientated Programming' given the abundance of 'magic methods' and other functions that try really hard to make sure you've got a cheeky workaround for something you can't be bothered doing properly (creating countless security issues in the process). And that's before you start using classes as pseudo-namespaces for collections of static functions.
The disappointing side is that someone who learns PHP before anything else will have a heart attack when they realise that very little of what they know applies the same to another language.
It's so loose and care-free that it doesn't care what you do or how you do it. (Not helped by the mountains of useless tutorials and documentation that teach awfully bad practices.)
So I guess the thing I dislike about PHP is that I learnt to use it but it didn't give me good programming skills.
This is precisely why I fell in love with PHP. My first was BASIC, my second was C, my third was Java, but my fourth ... oh god ... like that slutty girl who will let you do absolutely anything. How can you not fall in love with that?
(programming languages and sado-masochistic tendencies would be an interesting avenue to explore...)
if you don't like php, don't use it.
I spent a good chunk of my day looking at PHP code and profiling data. Assocs are terrible for performance but it's not a fatal flaw IMO. What people really want are separate "vector", "dict" and "set" types. It also needs a decent standard library to replace dyslexic crap like explode(). And don't get me started on the string libraries and the abuse of preg_* functions.
Lastly, comparing plain PHP to Ruby+Rails isn't fair. I prefer Python myself but even then I need something like webpy or Google's appengine library to make reasonable app.
Frankly, unless you are very large scale php is never your bottlenecks, I/O is. And if php become your bottlenecks, you have already won.
(of course you could find exemples of math-heavy calculating sites where this isn't true, but that just means you don't know how to pick the right tool for the job)
Even if you are not CPU bound, HipHop is steadily adding grown-up features to the language that make it quite nice to use, functions like mysql_connect_with_db() which save a database round-trip, and extensions like xhprof which will tell you what is actually slow.
And HipHop is most definitely not the solution, the only reason to use HipHop is if you are Facebook.
There aren't any numbers to back the idea that 2 to 4X performance means something. It's pretty easy to spend $5-10K per month on a single dev, thats a fair bit of hosting.
If the concern is speed of page rendering go with .NET, the JVM, or C++ it's much faster than rails or PHP will ever be. The trick is to use RAD/MVP to get you to that twitter like world of hurt. Then you rewrite in a faster language once you know what your product is like.
When you say it's easy to spend $5-10k per month, you're obviously thinking of a company whose business is the software, but this does not apply to most websites in the world.
It's incredible to me how the fantastically talented X rockstar ninjas can't produce a better replacement for, say, Wordpress given how much technology and our general understanding of building web apps have improved since 2003. Less blogging, more coding.
This is by far one of the easiest stack deployments I've ever done. I'm even thinking about writing a push-button windows installer to do all the installation and configuration stuff for me in the future. If there is any interest, I'll share it.
And heck, couple those technologies with jQuery, and I imagine that you could use CoffeeScript to develop for both the server and client side of a web app.
Easy and way cool.
a demo video also helps create a lot of interest.
For example: you can update the Rails code on the server, maybe run some data migrations or last-minute production tasks against the new codebase, and THEN tell Passenger to reload the application code.
On an unrelated note, having the Heroku service around for low-traffic side projects or whatever is just plain awesome.
Also, we're mostly programmers here, but there are a vast number of websites created by designers who have very limited understanding of programming and hosting setups, and all they know is shared hosting, copying files via ftp, and setting up wordpress (and maybe creating a database in phpMyAdmin).
Speaking of wordpress, that reminds me of the #2 reason for PHP's continued popularity despite its arguable sucktitude: applications! See http://www.codinghorror.com/blog/2008/05/php-sucks-but-it-do...
You can get this with PHP's APC opcode caching with file_stat turned off. You deploy and when you're ready you clear the opcode cache.
Or if you want to deploy and clear, then add that to your deploy script. Done.
I think the only thing around right now with a realistic shot of replacing PHP is JavaScript with node.js, but it will require widespread deployability. If and when node.js becomes easy to deploy on cheap hosts it has a huge number of wins over PHP (to begin with -- one less language to learn, and then even more importantly node.js understands the web page it's buildings and no other server-side language does this).
Also things like, file_get_contents() is stupid simple. It's often abused but you can put anything in that and get something back. Even a URL. Who care's if every once in a while you get a 500, or 404. Most of the time it works just fine.
PHP is going to be really hard to replace. I think your better off looking to graduate PHP developers to something else.
Well put.
The closest thing I've found is the serve gem, which lets me launch a web server from my current working directory. It lets me quickly mock something up in ERB, Haml and SASS without messing with Rails or Sinatra. As a complete newbie, with no coding experience, PHP is a much easier hill to climb than Rails or Django, which is Mt Everest by comparison.
Look at all the questions on stackoverflow from total beginners: they don't understand much of what they are doing yet, but they already have working forms and several pages and, well, results.
Of course, that's also part of what makes people hate php.
I understand why that is, but I can't help but think that it's optimizing for an edge case instead of the whole operation. I'm willing to invest a little bit longer to get to "Hello World" on day one if it means a lot less pain for every day to follow.
Other technologies can try to push on the "PHP problem" from above, and they can make a lot of progress, but they won't ever "win" because the inertia of PHP is coming from below. The only way to fully get rid of PHP is to beat it on its home turf, and that's firmly in the "Hello World" realm.
Now in this article there's a telling clue to why he thinks writing SQL by hand is better than using any ORM:
> I can knock out a good website in an hour in PHP, and an excellent one in a day or two.
This suggests that he's working primarily on tiny projects. Of course if you are working on tiny projects than an ORM doesn't buy you much. Also, there is perhaps no language suited better to tiny web projects than PHP and I don't see that changing. If you want to make something measurably better than PHP for general purpose web programming you start having to make decisions that developers don't want taken away from them. Rails does what it does by being opinionated, but it works because if the opinions are ill-suited to your project you can still use Sinatra or whatever. If you move too high up the abstraction layer while trying to still serve a wide audience you end up with the kind of morass that is Drupal, where the system can do almost anything adequately, but it doesn't do a great job of anything because of the creaking weight of the infrastructure that attempts to be everything to everyone.
But I don't think it's a small investment to learn a language and framework. You can learn the basics of ruby, or python, or Java reasonably quickly if you have a reasonably broad background in programming languages, though even that takes a while.
But the frameworks, those really do take an investment. It takes a real investment of time comfortable with Rails or Django. Not to get the initial site or scaffolding up, but to get comfortable enough that you're no longer stymied when you need to do something non-obvious.
And the Java frameworks, oh jeez. To get all that working takes ages. A dependency injection framework, an MVC framework, an ORM, getting it all to work with Maven or some other build too, sheesh that takes a long time, and there are so many dispiriting little errors to chase down.
Well, maybe there really adept coders just don't have a problem with this, but I have this suspicion that it doesn't come down to being smart. This isn't about mastering some difficult algorithm and then implementing it in python or ruby instead of java. There are a lot of idiosyncrasies.
I remember Ellen Ullman (she wrote "Close to the Machine", a reflection on programming before these types of books were so common) described programmers as "serial monogomists", becoming very loyal to their environments for a while, then abandoning them and finding something new. I remember another line, about how you can be a senior developer in one environment but not even know how to turn the machine on in another.
I'm not saying there aren't people who can switch easily, but I do think it comes at a cost, even for people who are reasonably adept programmers.
When trying to answer the question of "what tools should I, as a serious professional who is in this for the long-term, choose to work with right now?" it's really short-sighted to balance everything on how easy it is to get to "Hello World".
Would you choose an operating system based on how easy it was to install, or how pleasant it was to use?
PHP is all bad parts. Easily the most inconsistent, poorly designed language in popular use today.
One-based indices instead of zero-based.
It's trivial to write, there are lots of libraries that do this. I've worked on a lot of string processing code in Lua. It's not as easy as Perl or Ruby but it's not by any means hard.
> One-based indices instead of zero-based.
Other than violating the expectations of people used to other C-like languages, this is not in any way even remotely a problem. I don't know anybody who's spent any significant time with Lua who regards this as more than a minor detail.
That's why you can replace PHP with RoR, you need to replace PHP with something that out PHP's PHP, but is based on sounder principles so that in the important cases where a beginner is climbing up the skill ladder or a system originally created in a "beginner language" grows or becomes sufficiently advanced they won't hit a brick wall where they need to migrate to an entirely different technology in order to progress.
I agree that they should take things even further and really clean up the language before releasing the next major version. Fix the needle-haystack vs. haystack-needle inconsistencies, function naming conventions, and so forth.
The adoption rate of a new major version on shared hosting providers is relatively slow, so it'd be a perfect time to really shake things up and clean it up.
But we are missing the point here. PHP could need a cleanup from the ground up even if they have to break a lot of stuff this could help the language to evolve.
Don't bet on it. It has been too many a years already, and no dice (or minimal dice)
CS types might recoil at the mixture of behaviors that are baked into PHP's workhorse data structure, but most of them turn out to be quite useful. (And it makes it easier for the beginner programmer to decide what data structure to use: you have keyed data? a list of data? a set of values? doesn't matter, just use an array!)
This is the point at which serious students of language design point out that, if you look at it from a certain angle, PHP doesn't have arrays built into the language. As it turns out, treating two distinctly different data structures with different semantics and performance characteristics as the same thing multiplies edge cases and bugs.
Edit: For a beginner that wants a Visual Basic for web, sure. By now I have different needs, to enjoy using my tools. (And for the record, if I need to keep order of a hash/dict/etc in some language, I generally use a "traditional" array in addition. That is probably too complex for a beginner? :-) )
Edit 2: I'm not dumping on PHP, it is a useful tool for many people. I just wish the development of the language had been handled a bit more carefully.
Deployments are rarely atomic actions. With Capistrano, apps are stored in versioned release directories. Apache points to a 'current' symlink which points to the latest release directory. Upon deployment, Capistrano creates a new app directory, runs database migrations or updates configurations or creates asset files or whatever is necessary to upgrade the app. Only after it's done will it update the 'current' symlink and instruct the app server to restart.
Consider what happens if you upload your new PHP app with FTP. If someone visits /some_page.php while you're uploading then he could access an old version of it. Suppose some_page.php depends on common_library.php which may have been updated to the latest version in the mean time. Then things blow up because the new common_library.php is not compatible with the old some_page.php. With Capistrano, the deployment is as good as atomic.
Capistrano also supports deploying to multiple servers at the same time, and even to servers that are behind a firewall and can only be accessed through a gateway server. It supports rolling back to a previous version. And much more.
Couldn't get it to work myself due to various issues related to running DirectAdmin control panel, and protections against symlinks it has built in.
One-based indices stop being a "minor detail" as soon as you realize that out-of-bounds indexing doesn't fail, but returns nil. Time to re-examine all of your code. Combine this with the natural mathematical awkwardness of one-based indices and it can get really frustrating, really fast.
I had to do Lua for some game design stuff a few years ago, and these were the two things which stuck out at me almost immediately and bothered me during the entire ordeal. Maybe I've been spoiled by Python, Perl, Java, C++, C, and other languages, but it's deeply frustrating how wrong Lua is about this.
> Maybe I've been spoiled by Python, Perl, Java, C++, C, and other languages
Probably. :)
One of Lua's main goals is to provide a language easy for beginners to use for small tasks. This affects its design in some other rather annoying ways (like for example, variables being global by default rather than local) but they were pretty carefully made decisions.
The context of this thread is, "what could be a good replacement for PHP?" I think because Lua aims to be easy for inexperienced programmers, it's a rather good choice, even if some of its characteristics can be surprising or annoying to established developers experienced with other languages.
Having listened to several Python core developers as well as core developers of some major web frameworks and libraries, I have no doubt that Python 3 will replace Python 2.
I think the key tipping point will be when the major web frameworks support it.
The official party line on the delay was the lack of a WSGI spec for P3, but there has already been one for several months now.
You never asked yourself WHY. See, that's the important question, isn't it. WHY.
I'll tell you WHY. Because two different dudes implemented it. At different times. Probably, from different continents. They didn't notice it at the time.
But, eventually, someone noticed it. And then they did something really crazy. They didn't fix it. Because that would break the software already using those functions.
It's impossible to write a perfect language from the start. Hell, it's not possible to write a good language from the start. Things that you didn't see crop up and you have to add functionality. And sometimes, the way you added it isn't right ... at that point, you have two choices.
You can fuck your existing user-base up the ass, refactor your code, change the interface, and do it "right" ... or you can do everything you can to mitigate the damage, while keeping the interface the same.
I can pull up software I wrote 10 years ago and it'll still work. Perfectly. You can only say that about languages that do it right.
And guess what? Those languages, they always have lots of warts. Because someone made the hard choice and kept something that's ugly, instead of fucking over a shitload of people to make it pretty.
I'll take function over form any day.
I had a pretty good idea why that's how it is. I even completely agree with not changing it now. Backwards compatibility is important, no argument there.
That doesn't change that it's the sort of niggling annoyance that drives people to dislike the language.
Choose a convention (ie: always $haystack before $needle), find the methods that don't conform, and print deprecation messages for them, add their replacements.
Then in the next major release, remove the deprecated methods. Hell, you could even put the deprecations in in a module so that those who can't/won't update their code won't have to be left behind.
It may be impossible to write a good language from the start, but that shouldn't deter from fixing those mistakes.
PHP chooses to be ugly, over shafting its user-base by deprecating shit left and right. I like that. It tells me I can use it in a production setting.
The problem with a language that moves slowly is that if there's an opportunity, it might just miss it. I was working in PHP in the early days and every release brought features you wanted to use yesterday. Perhaps if PHP didn't have the huge rate of change it did then maybe it would have never caught on. Python is several years older than PHP and yet it didn't come to web until long after.
function my_in_array($haystack, $needle) { return in_array($needle, $haystack); }
or whatever, and be done with it...
You're not really helping your cause here.