The PHP Singularity

I worked in PHP during college for my job at the University… it was fine but I didn’t grow to like it. I’m a Microsoft stack guy but even Javascript is more fun to program in than PHP. I definitely prefer C#/Javascript and the barrier to entry for both is so low now what with all the freebie editors (Web Matrix, VS Express, etc).

It’s definitely time you tried Lasso 9. Probably the most elegant language on the planet right now: http://www.lassosoft.com.

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?

I cannot speak to the solution to the alleged problem of PHP that you and many other programmers, when speaking at your highest levels of snootiness and condescension, have lambasted innumerable times, beyond the point of tedium, as you yourself point out in this post.

I am not a programmer, but a lowly scripter, an Applescripter at that, which is actually why I’m writing, because of the passing bashing it was given in one of your quotes.

Enough with the crapping on Applescript. It gets things done, it leverages the power of first-class applications, such as InDesign, TextWrangler and hundreds more in such a way that it enables non-programmers who don’t care about clever list-sorting algorithms, to accomplish important tasks for real projects for real money, quickly, and without having to become ‘real’ programmers, which as you have made so clear, mere mortals should never try to do anyway.

Maybe PHP is popular because it works, because it is easy which is interesting, because it yields results without a lot of mucking about in hyperspace. Easy is interesting, hard is boring.

Personally, if all I was going to do all day was pull out nails, I’d take the double-claw hammer, thanks. I guess I want to take the easy way if the destination is the same.

Of course, if you and the other code critics were REAL programmers, you would have written your own replacements for PHP, to your exacting standards, using REAL languages that don’t use wussy crap like memory management. Get down to the metal or get off the pot. Don’t try to learn though, please.

The problem here is that Jeff and a number of others don’t understand certain dynamics and how significant parts of the web really work. While language choice may have some meaning for mega web stuff (ala Google, FaceBook, Twitter, Digg, etc), there happen to be a fair number of people out there not doing things at that scale, and don’t really give a shit about languages at all. They want something done, and they typically want it done as inexpensively as is reasonable. Those are the real driving factors for some significant chunks of the web, chunks that PHP owns.

For all the PHP bashers, here is my employer’s typical scenario: large, well known local non-profit wants a “state of the art” site (of course by their definition, meaning it has to look “cool”), with an easy to use and flexible CMS, a blog, an event calendar, and they want to manage a large number of forms themselves. Some forms require payment processing. They don’t care a twit about languages. This is very easy to do with WordPress + GravityForms ($99 developers license). No backend programming required, at all. Only frontend templating stuff. On our end, its a no brainer. There is nothing else out there, except maybe some other PHP stuff that could do this for anywhere near the same budget. I could write all this from scratch, or probably get some pieces of it with other frameworks, but then we move from low to mid 5 figures to well in to six figures. Why should we do that? Because PHP sucks? Get a life.

At the end of the day neither the client, nor the owner of our web shop, nor our staff gives a rat’s ass about the language itself. Its totally irrelevant to our business, and many, many other businesses out there generating web content. We want what our clients want: the “best” (as determinded by the client) finished product we can get with the least expense. Thats it.

If somebody can come up with a Python|Perl|Ruby|WhatHaveYou ecosystem that is as extensible as those core PHP apps like WordPress (20,000+ plugins), Magento, Drupal, Joomla, etc, and you can produce a better end product, maybe you can start moving some of us in the trenches doing low end grunt work to your point of view. Else, you are just talking pie in the sky, wasting bandwidth and bolstering your own egos.

The real problem is PHP didnt evolve. Other languages learned to standardize (camel case or Underscores in functions… not both) and have started doing ‘convention over configuration’ like Rails (Ruby), Grails (Java), Django (Python). PHP is still a mess to code in.

And forget ORM because there is no good solution that compares with Hibernate yet… especially not for PHP. Personally, I just switched to Groovy/Grails because it has become AMAZINGLY mature, can be compiled/scripted, makes use of Spring/Spring security and other libraries, has a load of plugins and can integrate flawlessly with Java.

After doing LAMP dev for 13 years and personally working with Zend, I can tell you they have ZERO plans to improve the language and have told me as much.

Rather than bickering about the best/adequate language or framework, why don’t we create something new, or at least improve something already good? We now have some hindsight on what makes a good language, particularly when it comes to the cloud. Many good things come out of dissatisfaction with the way things currently are.

Move forward people! If it turns out to be really good, people will come!

I’m a PHP programmer by trade. Ducks I loved this article, and in many ways you are right. If someone came up with a coherent alternative to PHP we would all be using it. But really, nothing comes close to it’s ease of use. PHP has many faults, but the things that it does do well, it does the best.

I would be interested, what do you have in mind? What would make a good programming language for the web in your eyes? What would you do better then PHP? You have the ear of a lot of programming, you might be able to make this happen.

I’ve got a $2 bill that says Jeff’s working on something with Python.

Ruby (Rails) is far too hipster (and far too convoluted for anything practical) for a long-time .NET developer to embrace. Philosophical differences aside, Rails is a lot less about solving problems and a lot more about the meta of solving problems.

Node.js – maybe. Seems too experimental to me, though. It’s the next great ooh-aah-look-at-that thing. It’ll make your toast, it’ll wash your car, it’ll rub your shoulders after a long day! Oh, yeah, it’ll kinda sorta let you write some code, too. But all the cool kids are doing it! All the cool kids that loved RoR 2 years ago.

Perl? Ok, I couldn’t even finish typing all 4 letters without starting to snicker.

Python is lauded as a language that promotes good programming habits. Yes, you can write FORTRAN in any language, but Python actually goes out of its way to encourage you not to. It’s lacking the ubiquity and the breadth of libraries and support of the bigger contenders, but I would say that’s actually a good thing when you’re looking to start fresh, rather than carrying along 18,000lbs of garbage for the ride and trying to pretend it’s not making you really tired.

Heh, this reminded me of the good old post about Magpie Developers: http://www.codinghorror.com/blog/2008/01/the-magpie-developer.html

Especially David Megginson’s process, which starts with " Elite (guru) developers notice too many riff-raff using their current programming language, and start looking for something that will distinguish them better from their mediocre colleagues."

And the first thing that comes to mind is that this whole JeffScript idea is yet another iteration of this process, but there’s another thought which emerged from this statement.

No matter which language becomes The Next PHP, there will be a lot of riff-raff programming in it. In fact, that’s what makes PHP so popular. It’s so easy for mediocre and beginner programmers (and even non-programmers!) to write something in it, with little effort.

So, if you want to make the The Next PHP, it has to be even simpler for these people to get their shit done. Otherwise you end up with yet another footnote in history. And somehow it has to manage to stay mind-numbingly simple, while fixing all the pitfalls of PHP. And that’s the hard part, IMHO.

If you don’t like PHP then don’t use PHP hahaha!

To me all of this babbling resembles the OS ideological war: windows vs linux. Some people just can’t live without spitting on the mainstream because it is mainstream. Surely there are always pros and cons. Pointing them out and discussing is a good thing. I mean the real ones. The misfit hyperboles such as the double-clawed hammer annoy me. Clearly having nothing constructive to say one should STFU.

I agree with Jeff’s “work to fix the broken or create an outstanding alternative”. However, it’s always easier to vent one’s frustration then to create awesomeness. This is the sad truth I’m aware of.

If you don’t like PHP then don’t use open source software like Wordpress, Drupal, Zencart, PrestaShop and even Facebook :))

PHP may not be the nicest language BUT it works easily and with almost every server without the endless configurations and server addons that others seem to use.
I tried ruby, perl and python and java etc, but to actually configure a server to run these is a nightmare for novices etc.
PHP just upload the files and call directly from html if necessary. Simple!
I tried for days trying to configure my server to run ruby on rails etc. What a nightmare. End of day. restore and stick with PHP and javascript!

“…One of the explicit goals of my next project is to do whatever we can…”

I like the sound of that. :slight_smile:

@Robin, @Jeff - As I said - what’s the project, who are “we”, and where can I join? :slight_smile: That is, if it’s possible, of course. Since it’s opensource, I hope that the development will also be open-ended, and input/code from outsiders will be welcome.

I agree with Jerelunruh. Laravel is pretty nice. You should check it out.

http://www.laravel.com

PHP is an amateur language, coded and maintained by amateurs. There’s nothing particularly wrong with this as long as that’s what you expect. If you expect to run any sort of mission-critical system with it, then caveat emptor.

How is it amateur? Mostly through very poor design. Here are some examples.

Having the same operators for comparison of strings and numbers just doesn’t work in a weakly typed language. All of the coercion that goes on behind the scenes breaks stuff. It’s how you get intransitive equality operators (“foo” == TRUE, “foo” == 0, but TRUE != 0). It’s how you get long strings that happen to look like numbers (password hashes, perhaps?) being equal when they’re not: “123456789123456789123456789” == “123456789123456789000000000”). It’s how you get things like NULL < -1, yet NULL == 0, meaning that sorting is nondeterministic (big problem).

Other concepts are simply not understood properly by the designers. This is the only language where the ternary operator is left-associative. This code:

TRUE ? “a” : TRUE ? “b” : “c”

yields b in PHP and a in every other language in existence that has a ternary operator.

Maybe most egregious of all, this is a language that was created basically to write Web pages. At its heart, its job is to read plain text requests and write plain text responses. Yet after 17 years in service, the designers don’t understand enough about the domain to introduce proper Unicode handling into the language.

If you can deal with stuff like that in your development language, then more power to you. I wish you the best. I personally am very wary about using such a tool no matter how good I am at wielding it.

@Daniel: I don’t agree with your debugging criticism. If you’re using “echo” to debug a complex project, you’re doing it wrong. Use a server-side debugging setup, and you’ll see its equally powerful to, say, Visual studio debugging.

On topic: I can’t argue about PHP’s poor language design, but I do want to put it in perspective. In two parts, a technology part and a business part.

Technology-wise, many (semi) professional PHP applications nowadays are built upon pretty good PHP frameworks, most based on the MVC pattern. It’s a valuable pattern to learn, as it is used across languages and platforms. These frameworks do quite a nice job in somewhat enforcing seperation of concerns and within each layer, helpers and utilities are offered to help out at a detailed level. When applied correctly, you’ll usually end up with a PHP application that is maintainable, which is a major improvement from the typical HTML/PHP spaghetti PHP was known for.

Looking at the kind of applications one builds with PHP, they’re usually data-driven websites. Typically you will not find a lot of business logic or processing in these applications. As such, only some core aspects of PHP the language are “touched”, such as string manipulation. While that exposure may be a nasty one, it is a manageable one. It only takes a few projects to know the ins and outs and to work productively with it, despite its shortcomings.

You may argue that getting used to a poor language is a wrong attitude to begin with, and that we should long for a better one. I agree. But this is where the business part comes in. Before I get to that, one more thing…you know what else sucks? HTML. And Javascript. And CSS somewhat. Browsers suck as well. Love it or hate it, but the web is a big hack, none of these technologies were ever designed to produce real applications. Still we do, and we will continue to do so.

Business-wise, nobody cares that PHP is a poor language. Nobody cares that something is “not enough OO” or doesnt have namespacing. What makes PHP a business success? Here’s my view:

  • It’s a gettings things done platform
  • It’s widely available
  • Staff is widely available on the market
  • It’s cheap
  • It has a low learning curve (well, not really if you “proper” PHP)

It delivers. This doesn’t mean other platforms don’t, it just means PHP delivers and that makes the world go round. I think you will have a hard time building a relation between any of the supposed technical shortcomings of PHP, and actual negative business outcomes. And therefore, those shortcomings are not important enough for an alternative.

None of this changes the fact that PHP as a language sucks. I welcome its successor. You could opt for Ruby, Python, anything as a better language but I just want to say it needs to become as widely available as PHP. With that I don’t mean hosting. There’s more aspects to it. A very important one is the job market. You could become a kick-ass Ruby specialist but depending on your geographic location, the job market for that may be tiny or non-existant. We need something way better than PHP but it also needs to be as widely available in every aspect that matters.

Except now it’s 2012, and fellow programmers are still writing long screeds bemoaning the awfulness of PHP!

I briefly flirted with using PHP for a personal web project around 199… 6? 7? Back when they still openly called it “Personal Home Page[whatever]”.

It (PHP) was a barely-documented pile of random code then.

It’s kind of terrifying that people are still using it… deliberately.

(Tati: That’s not a Microsoft page; they just contracted registration for a conference out to some media company. Nobody has an obligation to dogfood such that they only use contractors who use their own tools.)