The PHP Singularity

If you want to get rid of PHP, keep it conceptually simple. Mircea said that Python or Ruby are alternatives - they are not. Non-programmer people would need to learn about classes and objects*, and about how a good web app generates HTML in at least two steps** and how to map*** tables to objects (that they have not yet understood) and what are modules and why they are important and…

Or, well, one can start with PHP, learn how to do a “Hello, World” in two minutes and save some data in MySQL in ten minutes.

I am a Java programmer at work (could be no more corporate-y) and a Python developer in my projects (could be no more hipster) but I admire PHP and its ability of solving problems. It grows because, some times, some poor soul wants to create an online encyclopaedia, or some teacher needs an online teaching platform, or someone wants to write a blog. Those people do not want to learn to program, they want to solve problems.

I thing most projects to defeat PHP are doomed because programmers got it wrong. PHP is not in the same league of Python, C#, Ruby, Java or whatever. PHP is more like Excel, a not-so-beautiful tool for helping laymen to solve problems with a computer. And you know what? I like spreadsheets, although they are extremely shitty from a programmers perspective (PROCV() anyone)?

Paulmorriss proposes to write an alternative to Wordpress. Nice! After that, create an alternative to Mediawiki, Moodle and OpenCart as well. Oh, and do not forget: they should be useful, stable and easy! Now, let me tell my history: I was a fiercely advocate for Linux in my undergraduate days. I was always pointing how it was more stable and secure. What used to happen is that people kept asking me how to, let us say, edit MS Office documents or running AutoCAD or using Photoshop. With some time, various open source projects created solution to it. I liked it because I am an Ubuntu user and I need these applications, but for the common people from windows, they are lame clones for something they already need. Also, if they needed some application, they could hack it with Visual Basic or Delphi, while they would start learning about autotools(!!!) in Linux. All these alternatives people created, as great as they are, just did not solve the real, bigger problem, that is to empower non-programmers. It does not matter how many alternatives to real applications in PHP you create - the poor user will stay disenfranchised if not using PHP.

So, this is it. If you want to ban PHP, create a new as-easy-as-Excel tool for the web. It will be ugly, because those tools are aimed to little problems, but do not delude yourself that people out there care about the “elegance” of your language. Everything our favorite languages has was put there to satisfy us, not PHP users. If we want to win, we need to unlearn.

But do we want to create another unlearned tool?

* And man! I was a C programmer and it took me some two years to get it
** First, generate the data, then pass it to a template engine.
*** Every time you say the word “map”, you can count on your layman listener getting lost. This is hard mathematical stuff, you just forgot it because you are used to it

What needs to change is the notion that hosting your own web app, using open source software, involves uploading “scripts” to “web space”. As long as this is the way 99% of hosting operates, PHP will maintain its prevalence.

All the things going on with virtualized cloud hosting are key here. Move from the paradigm described above to where installing your own instance of, say, a blogging engine means uploading a complete VM image (or chef/puppet cookbook, or whatever) to your hosting provider, and open source developers are once again free to use their favourite technology.

(Disclosure: I’m the author of Schnitzelpress, a tiny Ruby/Sinatra based blog engine that was mostly born as an experiment to find out how much of the above is possible today.)

As a fellow programmer forced to use PHP on daily basis, you all miss the worst part of the language - the terrible terrible debugging and tracing options. If you have a complicated project it is almost impossible to debug with anything else than print_r or echo. I feel like being punished for lots of sins.

So if your open source project is something that can get the world off of PHP without invalidating all the old working and tested code - just show me the github link.

What we are trying to achieve with Composer ( http://getcomposer.org ) & Packagist ( http://packagist.org ) is to bring PHP to a higher level by encouraging sharing of small libraries. Encouraging re-use by making it dead easy to publish a package and depend on others.

This means less wheel reinventing, and overall people get more time to work on their one specialized lib instead of having to write boilerplate crap over and over again. So we end up with higher quality libs, and everyone wins.

That does not directly fix the language, but it helps a lot by abstracting crappy C-like functions under much more usable OO APIs. Curl has wrappers, GD/Imagemagick too, streams are coming. This creates a nicer “DSL” on top of PHP, so that all you’re left with from core is the language syntax and a few string and array manipulation functions that are not as consistent as they could be, but it’s not so hard to learn if you use them every day.

I find we these are exciting times to be writing PHP.

So, Jeff, where do I sign up for the team? :slight_smile:

Magento is not a good example of PHP. I’ve had to deal with Magento, and I describe it as being written by Java developers who decided to use PHP for the ubiquity of deployment.

Remember: You can write FORTRAN in any language.

People will even take your beautiful, perfect language/ecosystem and write PHP in it.

There’s a technology with pure saturation and you want to throw that away. Terrible idea. Embrace PHP to gain the saturation you could never hope to get on your own. PHP runs on ALL servers. Who can replicate that? If Java, Python, Ruby, and .NET can all fail to achieve the same ubiquity, what chance do any of us have?

Replace “PHP” with “JavaScript” in your article – it’s the same problems. Only choice for a language for its scope, terrible design decisions, yadda yadda. Yet the entire modern online experience is based on it. How have we coped and even thrived with JS? One solution is by embracing it as the backbone to make better libraries as was done with jQuery. Now we have an awesome library that runs on all browsers.

@Emil Vikström

Doesn’t Perl already fix the ‘hackish state’? While you can use frameworks, you can also write a simple script with the CGI module. It is also very easy to deploy [ upload files and you’re set ]

Also, it has good support for web stuff. CGI [ or Apache2::Request in Apache’s mod_perl ] does all the parameter parsing / HTTP headers / file uploads, CGI::Cookie does cookies, DBI does databases, FCGI does FastCGI, etc.

It also has quite good web-related documentation, or at least that’s what my googling-skills found.

It only needs some metapackage-style module which depends on CGI, CGI::[stuff], HTML::[stuff], DBI, FCGI and other useful modules for web programming. Then, installing would be aptitude install libweb-programming-perl or cpan Web::Programming

@K Lawerence

The fact that PHP is widely used affects all web programmers. More users == more/better libraries == easier development in that language.

@Timw4mail

What’s that difficult in setting up Python/Perl/Ruby/Any_Sane_Language? You install an interpreter for that language, some modules/extensions/gems [ these two steps are one aptitude install ... command ], you configure your webserver for CGI/FastCGI and you write scripts. As easy as PHP

@Paulmorriss

I would help, since blogs are a big part of the internet. However, there should also be some other very-used projects in the Miracle Language [ maybe stuff like e-commerce, maybe a generalized CMS, maybe a forum and maybe others ]

@Jos3000

Compiling stuff like Ruby/Perl/Python to PHP is not easy. Making a new language which has the same amount of libraries/written code as Perl, Ruby, or even Python has takes a lot of time. Therefore I think we should aim for a language which already exists

I have been using PHP for years. I’ve heard all of the critiques. Many times. The most common point about them all is that they have not evolved over the years. People that hate PHP have been hating it for years and they still have PHP 4 in mind.

It’s a bit like saying Java is horrible by thinking about applets or J2EE.

The language has evolved since. It is possible to write beautiful code in PHP. Just look in the direction of Symfony2 and Doctrine2. Sure there are quirks, but there are some in every language. Just unit test your code and you won’t have bad surprises.

There is plenty of truly horrible PHP code out there. But there are a bunch of truly pathetic programmers too, and they happen to share their code. No language is going to make novice programmers write good code. The language might make it look good, but any good programmer with experience in the language can point it out.

Don’t like PHP? Don’t use it. Unlike JavaScript, it is not imposed on you.

Agree @Anthony Ferrara

“I think you miss a very key point, that sucking matters for shit when you’re able to get stuff done with it.”

I’ve seen so many cases where the customer threw out a carefully designed solution, developed at great expense, in favor of an internally hacked PHP site. Management regrets it, but the people on the workfloor are in love with the PHP site.

Likewise, I’ve never seen an official PHP project fail. The result might offend the OOP developer, but there is always a result, and it always does more it less what it was supposed to do. If I compare this to the success rate of Java or .NET projects, I can only hang my head in shame.

I’ve long thought the reason for this is Boyd’s Law PHP basically forces you to iterate from day 1.

PHP delivers.

@my previous comment
"I would help" should be “It would help”

@Robert McRackan

Don’t Python/Perl/Ruby also run on all servers? Perl and Python also tend to be installed by default on most Linux distros

@Adam Victor Nazareth Brandizzi

You don’t need to know what objects are to write Hello World in Python/Perl/Ruby, or to store something in a database. You just need a code example, and then you can start writing PHP in Python/Perl/Ruby :slight_smile:

[ Well, non-programmers should be just that: non-programmers. That’s the problem with both Excel and PHP: they turn non-programmers into semi-programmers which output massive amounts of awful code ]

I think if we look at the history everything we see has glory days. but in real world everything is just an ‘Leaky abstraction’ as said by great joel. language is as good as abstraction it feels.

I have used every server side scripting language and i found most of them are unreliable and having huge problems. take asp.net when started they created great abstraction by dragging and dropping components it putted all code and when something got wrong developers of .Net didn’t knew what was the problem cause they never worked with underline technology. weather it was web forms code messed with JavaScript or anything else to create abstraction.

The reason i believe php used by so many devs is its as natural with html and css as much you can get and it never really get into the way of developer who wants to do something. if you want to do some system task they give you functions you can run system commands. you don’t need to learn those 20,000 namespaces to work with something simple.

The problem part is people think they can deliver high performance apps with php. if you have really huge application just deliver the front end with php and use something appropriate to manage back end. cause php at the end of the day is scripting language not JAVA or C or C++.

So DEAR JEFF, STOP Renting on PHP or start renting on everything. :slight_smile:

Don’t Python/Perl/Ruby also run on all servers? Perl and Python also tend to be installed by default on most Linux distros

No. And there’s not much else to say about it.

You don’t need to know what objects are to write Hello World in Python/Perl/Ruby, or to store something in a database. You just need a code example, and then you can start writing PHP in Python/Perl/Ruby :slight_smile:

Deployment in PHP tends to be much simpler than the other systems. Go look at deploying a RoR app, for example. That isn’t to say there aren’t exceptions, but in general the above is true enough that it matters.

[ Well, non-programmers should be just that: non-programmers. That’s the problem with both Excel and PHP: they turn non-programmers into semi-programmers which output massive amounts of awful code ]

That makes people millions of dollars a year. You’re forgetting that the people paying you don’t care about anything except the result. And the results speak for themselves.

@Daniel You should give XDebug a try.

Nothing makes me love PHP more than people who tirelessly talk about how shitty it is…

I’d have to say that the reason PHP is ubiquitous is not because of Jeff’s mistaken claim that it’s easy to install - it’s flippin’ easy to use: just inline it with your HTML in a .php file, and Apache magics it out to the world (I should know - I write in it for all my scripted pages).

If Python were as simple to embed (yes, it can be done - but it’s not the same from a simplicity viewpoint), we wouldn’t have to deal with “PHP SUCKS!!!11!!!” posts every few weeks. We’d deal with “PYTH0N SUCKS!!!111!!!1!” posts instead.

Until random morons like me quit embedding our logic into our display (ie, until we all move to an MVC or similar paradigm), it won’t matter what the ‘language’ is, it will all suck.

Tired,

PHP is already dead!

Web apps need to deal with lack of connectivity, therefore must handle data and other functionality on the client. Only one language can do this on the client and server.

We are saved from PHP by JavaScript ;0)

As has been said previously - an Open Source ecosystem that can compete with PHP in ease of use, but without its faults, sounds terribly promising. Where and when can we find details?

A thought just struck me - ok, so maybe you can build your perfect “PHP killer” - but how will you get it adopted in the world? PHP is like a social network - people come because everyone’s there, and everyone’s there because they come. It’s the classic chicken-and-egg problem. How do you intend to get the “critical mass” of popularity to get it rolling?