The PHP Singularity

PHP is popular, for the same reasons JS and Wordpress are popular.

They are:

  1. Intuitive, easy to use (think apple products)
  2. Popular and it’s easy to get support.
  3. Web hosts provide it for dirt cheap, ASP.NET+Windows hosting would be a lot costlier, plus a really deep learning curve for the framework. If the same noobie tried picking up C++ or Java, as if it were PHP, they’d be in a world of hurt.

PHP just works, it because popular not in regards to its flawed design decisions but how easy it solved problems. JS suffers many of the same problems. The different with PHP is that there are alternatives and yet, it still remains the king of server-side programming languages in general (because the other solutions are more complex).

C++, Java, C# were all carefully designed languages and enforce that you learn real programming concepts to get something up. They are also more commercialized solutions, which means they are not for the majority. The only way for something to overtake PHP (and be elegant), is for it to be as available, cheap, and intuitive.

I have deep knowledge of HTML and CSS and I’m learning different languages (MooTools, PHP, Python, will be picking up C++, SQL as well). I want to try my hand at solving problems in each and see what appeals to me when it comes to solving different types of problems.

Python is personally my favorite language in general, but I’ll be developing web applications in PHP for some time. If you’re disciplined and learn good coding habits, you can engineer great code. Just don’t copy and sling, try to UNDERSTAND why you make decisions in your software.

Write bad code first, then write it less bad.

I think of PHP like those old beat-up trucks that you see on the road that look like they are going to fall apart at any moment. They have all kinds of tools, random bits of wood and the tailgate has been replaced by plywood.

Thing is, as scary looking as that contraption as, it is making money for the owner. This is why PHP continues to operate: you can make a website trundle along from job to job with it. Is it unsafe? Sure, but mostly for the people behind it, hoping those 2x4s stay put (who represent the people who keep hoping that PHP driven site doesn’t leave their personal data scattered all over the information highway).

@sadaek is right on the money. These are exiciting times for PHP. While the language itself is horrendous, take a look at the frameworks that run on top of it. Symfony, Composer,… Albeit, with their flaws are excellent tools which keep developers from reïnventing the wheel as far as the low level stuff (session storage, file handling, request routing,…) is concerned. Writing your own mini CMS/F might be exciting, but today, don’t even think about pushing them beyond your own personal projects. It’s just plain redundant to do that.

It’s also all about the sort of tool you need to get the job done. Wordpress is a blogging tool with a history. It’s internals are a pile of steaming excrement, I agree. Yet, the front end is great for users and with a few clicks, you can easily set up a blog. But don’t start to build entire platforms on top of it. It’s just not meant to do that.

I do agree that the low level functions of PHP are a mindfart. Having said that, you can still map your findings here: https://bugs.php.net/ Mind you though, PHP’s biggest issue is its’ legacy. Powering the Web comes at a cost: you can’t just start rummaging around at the low level without breaking all those hacks people have written over the years. It’s probably just cheaper to leave those in. If Python had the same success, we’d probably be taking a dump on typical Pythonesque monstrosities that we don’t even care about the slightest bit today.

I’m a fan of PHP - and I’ve been using it for a while now. I prefer to work on top of Code Igniter (a nice MVC framework).

I’m also a business, I provide services to my clients, blazingly fast, solid and DONE when they’re supposed to be done.

If you really want to replace PHP with a language you think is “real”, well, it will be challenging. As a businessman, here is what it must be able to do:

  1. Be anywhere I want without install/setup complications. I should NEVER have to worry about it being everywhere and ready when I want it. I don’t want to waste time or my money setting up some software just so we can start to actually work. I don’t want a dedicated person to the setup and configuration of the development language, its tools or plug ins or requirements and so on. That is just a waste of a job on something that adds no value at all.

  2. It must come with adequate tools to complete common tasks - session management, database connectivity, file management (upload, file system access), image manipulation, compression, security, email, and so on. These should all work “out of the box” without much configuration or concern about the server or what not. Having to develop these is a waste of time and money.
    2a. To use said services, I shouldn’t need more than a couple lines of code - or even a single line of code to implement it.

  3. It must be extremely well documented in plain language (English and all) - with implementation examples that are meaningful. Seriously, the autodoc “documentation” is utterly useless. I can usually find the solution to any issue I have with PHP using Google in a matter of a few searches. And when I say ‘solution’, I don’t mean a document page that explains the function I’m wrestling with, I mean an actual example of the code that solves my problem almost line for line exact. Otherwise, I’ve got to spend time developing solutions to known problems - there is nothing new under the sun and, pretty much, no matter what the task is, someone somewhere else did it before you.
    3a. It must also have a serious amount of third party detailed examples of implementation.

  4. I shouldn’t need any special tools or special/additional skills to use the language. By this I mean, I shouldn’t have to waste time learning (developing a skill) how to use the server merely to complete using the language for any reason. If the language requires compiling, it should happen automatically without me having to tie files in or deal with configuration issues merely to see the code work. In PHP, it is upload the file, open a browser, test it, done. I shouldn’t have to do more to work with any replacement. I shouldn’t need a special IDE which can work with the language to make it so that I can do what I do in PHP (instant testing). The additional time to merely compile and configure files for compilation adds no value to the project and is an inferior aspect of a language.
    4a. It should be loosely typed. I really don’t care if the data is an int, double, float, char or blob, just deal with it as I want you to. Seriously, casting variables or creating functions to convert them is “better” than the language automatically doing it? The best smartphone has one button on it and the touchscreen reacts differently depending on how it is interacted with, I don’t need to tell it when I’m scrolling to scroll, or when I’m tapping a link or resizing the page, it just does it automatically - this is the best design out there - and I think there is nothing wrong with expecting my language to be just as flexible, especially when it really only matters to esoteric metrics on what is a “real” language or not…

  5. It needs to work flawlessly with mySQL and/or any other database that shares the same distribution as mySQL. It should be able to manage the connection and all transaction to the database and it should do it in a few lines. Creating our own connection code or transactional libraries is a waste of time. They should be extendable for custom functionality as needed.

  6. It needs to come with complete MVC frameworks, from small, light and tight to large, complex and complete. It needs to have a TON of applications built in it so that I can take one off of the shelf and modify it and then publish the work in weeks or a month. I shouldn’t have to reinvent the wheel ever.

Essentially, everything above is related to rapid development to contain development costs. My clients don’t pay for esoteric development done at whatever you think is “right” - they want something setup, installed, stable and working NOW. Until you can provide a language that is as versatile and economical to develop in, PHP is simply a better language because it can do that while all of the other languages can’t. The measurement isn’t how well the language adheres to some metric or design concepts that you believe are relevant, the measurement is how the language solves the problem.

Right now, I have a client who uses PHP and mySQL to serve over 2 million visitors a month, I’ve seen the complexity of the operations and to re-do this in one of your so-called “better” languages would take a considerable budget and a team of several developers (having seen similar projects at a corporation I’d worked at a few years back). I’ll complete the MVC re-write of the site in a few months on my own (have about three weeks to go to complete phase 1, phase 2 will take another two months - then its done - and I’m part time with them). The best language is the language that gets the job done for the most economical price. Simply paying more to develop in a “better” language that adds no value to the end product isn’t a better, but a bad business decision.

It seems to me that PHP took off because someone who doesn’t know how to code can start with index.html, rename it “index.php”, add a variable here and a tweak there, and before you know it you’ve got Wikipedia. And nobody wants to rewrite that from scratch in a new language.

You could do the same thing (roughly) with Python, with a few modifications. You’d need a “.pyml” (or whatever) format for embedding Python in HTML-- but then you’d need to convince all the web hosts to include it. (Which might not be that hard, if there’s enough demand: they nearly all support Python.)

The thing that’s hardest to replicate is the ecosystem around the language: starter guides and how-tos that assume little or no programming knowledge. But perhaps a StackExchange site could help with that.

As a replacement for PHP, Python seems to be the best language: it was designed for beginners (kids, actually) while still being reasonable for use by real software engineers. I’m not a big Python fan, but having used both, I’d take it over PHP in a heartbeat.

The other language worth considering is JavaScript. Being able to use the same language client-side and server-side makes a lot of sense in terms of reducing the learning curve.

It seems a little odd that Jeff would take on the project of killing PHP when he doesn’t want non-programmers to program ( http://www.codinghorror.com/blog/2012/05/please-dont-learn-to-code.html ). I can’t imagine him succeeding with a negative attitude toward his core audience. Still, I can’t complain if all we get is a halfway decent PHP alternative that gets used by a few high-profile open source projects.

PHP for all its brokenness is easy and it’s small in workflow terms (code then hit refresh to test), and I don’t mind using it to do websites, but god damn that dollar sign convention is so annoying. Makes typing variables a pain in the ass.

With a good framework and sensible abstractions, and using an IDE takes away most of the frustration you guys mention. I feel like most of these arguments are, “I saw bad code and don’t want to develop solutions so it’s time to argue that the language is horrible.” I mostly agree with ChronoFish And More’s simple assertion, the language is extremely fast to develop with and if you have any sort of CS training and discipline with normal coding standards, PHP apps can end up having very elegant and sensible solutions for projects.

Getting confused from explode() when you have an IDE popup to show you which variable goes where is extremely nitpicky in my opinion. If it really gets to you, you can always find an object oriented library of the languages constructs so that you can do a less confusing $array.explode(’/’) or something similar.

I agree that there are a lot of things that should simply be deprecated as the language moves forward, as sometimes having 10 different ways to solve a problem results in baddies coming in and making hard to work with apps… but at times like that I feel it’s times like that to show that there are more efficient and cleaner ways to do things and build up the programming community :P.

Coming from a programmer that started off on Visual Basic then moved to PHP/Javascript and is in the process of Transitioning to Java

What I like about PHP is the Inline User Interface, automatic garbage collection and memory allocation and what I hate about PHP is the Inline User Interface and the lack of Thread control

From my webwork PHP isn’t meant to be a large scale, its suppose to be quick and simple. And from Experience you can make it as such.

However, what i don’t like about php is the lack of Seperation from User interface from the Core. HTML and CSS are established User interface tools. Web Designers Learn this. However, as a programmer, Iam forced into a position to treat it as part of the framework costs which I desipise.

Likewise, when it comes to threading, PHP can be difficult to work. Since I’m forced to use multiple documents for different people calling one document and setting sleep variables to make sure they aren’t reading it too often. Was a bit painstacking, though also an interesting puzzle

But I’m less inclined to say its a worhtless language than to say it needs a proper library. Wordpress was an attempt that5 I think failed horribly. Magento is worse for the simple fact Layout.xml is their attempt to make a new HTML. I do think that PHP is fine for the fact its quick and simple, though obviously it can use some changes.

Isn’t it ironic that one of the better stackoverflow clones is written in PHP :slight_smile:

<?php dump($high5); ?>

PHP definitely sucks if you use any real programming languages. It has always sucked, but I just think of it as server side duct tape.

This was a very funny article and I just loved it!

I remember very well my first contact with PHP when I said: “C’mon you can’t be serious…” after reading a few lines of code and tried to understand the language.

And that general view that “it works, so I f… don’t care” it is a worldwide tendency on disregard critics and take shortcuts. And I feel that goes beyond code… unfortunately.

Pretty soon we will have PHP like MDs ("Take that medicine… it works and solve your problem right here and right now… ");

Is there something in Python like Wordpress? just drop it in your webserver, pull up a installer page with 2 or 3 questions and it’s ready to use.

At least with stuff like Symfony2, PHP seems to be getting better.

Excellent article, thanks for the same. The very aspect PHP is so pervasive is the fact that it is easy to use and is being used both by the coding and non-coding community. Until a better alternative is available, PHP, for all it’s faults, is here to stay.

The only way I see that PHP could be displaced is if you take PHP and fix its faults… and then make it so, that the new JeffPHP can run oldstyle PHP and newstyle PHP side-by-side in the same file. This would offer both an easy migration path for existing code and an easier learning curve for old-time PHP coders.

I does matter that PHP sucks. It matters a lot. PHP can only be safely used by a top shelf, well-trained programmer with a ton of patience. Except that a well-trained programmer would never use it because there are countless better options. So that leaves the dregs to use PHP which is also not shocking, because the PHP dev team is filled with amateurs.

This means that PHP is really useful to no one and should be used by no one.

I am not surprised that you don’t understand this since you are obviously under-educated. Time and time again, you have shown this. Have you figured out that all programming is mathematics yet? I would be impressed if you have finally learned what math is, but I know you haven’t.

PHP sucks, if you use it you have no business programming. Full stop.

“A low barrier of entry is not a bad thing.”

It is a very bad thing. Programming is the only profession that allows untrained people to work in the field and we all have been paying for that.

Programming is a professional endeavor, if you do not have the brains or the will to get an appropriate degree(CS, CSE, etc) than GTFO. Without formal training, programming is black magic.

Look at Jeff Atwood, he is untrained and read some of his stuff, he simply lacks the understanding of computers,computing and mathematics to talk intelligently. Instead he takes his third-graders understanding of math and tries to apply that to debunk Dijkstra. To Jeff, programming is magic, just like it is to 99% of the people who use PHP.

The internet is an extremely unsafe place because of these amateurs with no clue what it going on. PHP ‘devs’ lead the pack in producing unsafe applications.

"Ok, so PHP is not perfect, but I don’t see you pointing out any good solution to use instead if that exists. If you don’t want Rails, a big Java Enterprise or some Bill Gates server… then what are you left with? "

The problem is that PHP is not perfect, nothing is.

The problem is there is nothing good in PHP.

Pointing to crappy $5 hosting means you don’t have a problem worth working on. It also means that Heroku is going to be much cheaper for you, and it scales effortlessly if you need it to. It is also simple to deploy to.

Rails is fine and is a snap to deploy. Absolutely simple, of course you need the CLI, but PHP needs it as well. The crappy hosts just do it for you and you better pray that they compiled it in a way that whatever you want to run on it will.

The rest of your comment it typical of ignorant PHP “devs”(is there any other kind?) Other options include:

C - you would be nuts to use this
C++ - you would be nuts to use this
Perl
OCaml
Scala
Lisps - CL, Clojure, etc, etc, etc
Erlang
Javascript - node.js or even on the JVM
Smalltalk
Haskell
Python
Ruby - Ruby is not Rails, and the Ruby ecosystem is much larger including other frameworks and template libraries and other libs. Most of the web-centric Ruby libs are Rack compliant so they all work together seamlessly. Yes, you can mix template libraries in a single web app and even frameworks like Rails+Sinatra.
JRuby - Gives you the best of Ruby and Java and is up to date(ie runs on Java 7 and is more or less Ruby 1.9.x compliant(Some Ruby features just won’t ever work on the JVM, but it is not a huge problem since those few features are rarely needed) so it makes sense to put this separately. Unlike say Jython, which is quite poor and lagging significantly behind Python.
This list could go on and on.

With the exception of C and C++(correct me if I am wrong) all of these have frameworks if you need them and they all have the needed libraries if you don’t want to use a framework

Of course your typical PHP “dev” isn’t educated enough to easy change languages, which is why a competent CS program doesn’t teach languages, it teaches concepts.

1 Like

Please stop writing novels on how BAD php is - without any code in them. It’s useless waste of internet space and user time (stuff tending to be infinite is not a good enough excuse to waste it!).

Please, present your arguments with code, and show samples of how things can be better with the language you happen to think is “Da Best Ting Eva”. Too much of it to post in a blog? No problem, just make+link a Git repo for it, we’ll go ahead and check it out.

I wouldn’t expect anything less from you, Mr. Atwood.

I agree with Hardikdangar, PHP is fine as a simple frontend language. These days I mostly build web applications so most of the code is JavaScript, I use PHP for templates, routing and to handle building JavaScript and CSS and including it in the page, this is the simple stuff PHP makes very easy. For more complex server side functionality use something else and have PHP or JavaScript interface with it. Our core application is actually written in C.

The problem I’ve had with PHP ever since it was started is not that it’s a bad language, but that it started out as a bad language in exactly the same way that Perl 4 was a bad language (unsurprisingly, as PHP developed from a Perl script) and then proceeded to fix those problems, one by one, in exactly the same way Perl had already done it, several years before - and yet PHP became very popular while most people trying to use Perl for web programming are still asking basic questions about CGI scripts written in Perl 4 like it’s 1994.

One of the best proofs of Worse Is Better that I ever saw.