The PHP Singularity

I’m currently making a living from my PHP + MySQL clone of a Rails + Postgres app. I started the project ~6 years ago because Rails was such a whore to deploy, hoping that it would become redundant within a few months as rails became widespread. But no, PHP + MySQL still has about 99% of the “cheap-as-hell shared hosting” market share, with no alternatives, and I’m still maintaining that project since so many people rely on it. Not a day goes by when I don’t want to strangle a PHP developer for their retarded design decisions :frowning:

Please, somebody, make it so that I can just drop “index.fcgi” into a directory and it will run that code (in whatever language) as a fastcgi process (with the user ID of the file owner); then get that module installed on 95%+ of cheap shared hosts. I really want to rewrite my software and compete with the other clones based on quality, and not on me being the most willing to tolerate PHP’s bullshit. Heck, even if that makes the python / rails / node.js clones easier to deploy and makes my project entirely useless, at least the world would be a better place…

Python is easy too! Just ssh in, create a virtualenv, use pip to install dependencies, upload your files, set file permissions, use root access to configure your web server to load the app via fastcgi, spend a few hours debugging all the glitches, and you’re done!

I have no idea how anyone thinks that this is as easy as “upload files, done” :expressionless: Heroku and co come close, but they’re still more difficult than that, and they’re way more expensive than bog-standard shared hosts.

I personally hate having to lookup which comes first in a explode() or a strstr() if I brain fart for some weird reason, but I don’t blame php

This reminds me a lot of Stockholm Syndrome. PHP causes pain so consistently that people consider it the norm, and they think it’s amazing whenever it manages to do something only slightly awful. Once they’re attached, it could say that 1+1=3 and they’d still rather blame themselves than the language…

So, as a person looking to learn a language for the web, what should it be?

As some have already said: throwing PHP out completely is like throwing out the baby with the bathwater. Why not build a library that makes PHP less sucky, similar to jQuery?

PHP has its purpose which is developing simple sites fast. Python and Scala can do that too but they are much more sophisticated. Scala might one day compete with Java in the enterprise world. Hybrid languages on JVM are very interesting.

On the front-end side, all can be done with JavaScript much nicer while having HTML completely separate. If you have a nice event-driven or service-oriented backend which responds to your Ajax calls, what the hell would you need the PHP for? The world is changing, I personally prefer to adapt to the change and not get used to mediocracy of hacking code fast.

Nah, I like PHP. Thanks, though!

Being a Delphi programmer with a fair knowledge of C and C++ and able to put together a SQL script, PHP was a shock to me system. My applications is mostly business orientated with integration of fingerprint readers etc. and I want to port it to the web and mobile. PHP stopped me dead in my tract. Because its unreadable from my point of view and I have not control over the hardware. So I am watching this blog for alternatives!

One of the explicit goals of my next project is to do whatever we can to buff up a … particular … open source language ecosystem such that it can truly compete with PHP in ease of installation and deployment.

SHUT UP AND TAKE MY MONEY.

I’m going to post my 2 cents.

I started on Perl and switched to PHP because Perl wasn’t threadsafe. PHP worked just fine threaded, but ultimately php-fpm became standard, to get PHP out of the memory space of the web server and make it independant.

Much of the crying about PHP has to do with it being a cPanel out-of-the-box install and nothing more. For example, out of the box there is no opcode cache, and cheap hosts don’t set the opcode cache large enough to actually get a good hit rate for Wordpress (which requires more than 56MB to function) On top of the RAM requirement (which can require 128MB just to do one thing.)

Wordpress and Mediawiki are some of the most obnoxiously programmed PHP applications in use, yet they are the most popular.

If someone wants to come up with a winning replacement for PHP, come up with a new language that automatically works in threads. So far nobody has done this in an elegant and easy to understand way. Hell most Apache installs still use inefficient pre-fork because that’s just what most linux defaults are.

There’s nothing wrong with pointing out the obvious. However PHP complaints from high profile coders have some side effects. It’s not just how the language grew, but the community took some defects.

Recurring rants as this incur some overcompensating on behalf of the php.net developers. Given time they’ll “enhance” the language, similarly questionable as the original bit. For example PHP5 brought some overdue simplifications, but they also half-assed access modifiers to make it “more object-oriented”. They didn’t understand the usage origin, nor read past the first syntax chapter of C++ for dummies.

Likewise PHP 5.3 with the namespace syntax. It’s the result of rushing features in because of language bickering. And it doesn’t stop there. The shitty backslashes are now used by vast majorities of developers for creating taxonomies, not for resolving identifiers. A lesson well understood in Python, but still to be learned in PHP land. But by then a dozen new idiosyncrasies will have been introduced.

Their development model doesn’t sustain the widespread usage and desires for improval. And pointing out the problems with that only adds to that spiral of doom. There are alternatives now with Quercus etc., but they lack the community support and self-reliance.

Hate it as much as you want - it’s not as bad as people make it out to be. It really isn’t. Here’s the solution to your woes:

Security (Blanket) through Obscurity. Take all the inconsistent functions and hide it all behind objects. Ta-da: You now have an object oriented thing to work with, exceptions and all, and at that point it isn’t bad. Or, download one of the half dozen or so good frameworks and it’s all done for you.

Granted, you shouldn’t have to do that, but there you go. PHP has its blemishes, but it’s not THAT bad. It seems to me that if PHP had a “function consistency” then most complaints would disappear overnight. I still hear people complaining about broken features that have been obsoleted YEARS ago, yet they still bemoan them as if they has just been pushed into recent releases.

Side note: Complaining about the php.ini that you don’t even need to touch 95% of the time? That’s really weak. REALLY weak.

You might as well rant about MySQL as well - it’s the PHP of databases, and yet I see it being used everywhere with minimal complaint.

Would I rather be writing stuff in Python? Sure. It’s nicer. Faster. But quite frankly the documentation sucks compared to PHP, and and the people in the community are far more standoff-ish than the PHP community. No offense to the nice guys I have run across - I’ve found some nice people out there - but by and large

If you really think that there is a better product out there, then why isn’t it on every single crappy ass web host in the world? If it isn’t as easy to install and manage then you’ve already lost. Sorry.

I really do hope that Python manages to get to that level of simplicity. It’s nice, cleaner, and has some great features (despite the funky spacing requirement, but I can live with it) but until then: stop bitching and HTFU or do something about it.

A few people above have hit the nail on the head here. Shish2k is one. I’d like to add a few additional points.

  1. Cheap, shared hosting doesn't come with shell access. Any language and/or framework that requires shell access to deploy is dead in the water.
  2. By proxy, basically any language that has an elaborate reusable component library (i.e. gems, eggs, cpan) is pretty much dead in the water as well, unless there's a *really* straightforward way to bundle the libraries with your app and have them require zero installation or existing libraries.
  3. Packaged component library systems like RubyGems and Python Eggs are hell for newbie developers.
  4. "import" / "require" / "use". Fucks sakes, it's 2012. Why do we still need to do this shit?
  5. Compiling. Bye bye Java, C#, and basically all other compiled languages. You might be awesome in your own right (C#), but it's just too much work and requires too much knowledge about toolchains.

The second and third points sounds backward, but half the time the package systems:

  • Don't work nicely on Windows (if at all)
  • Have complex interactions with system vs app installations
  • ...and thus launch into dependency hell
  • Require a lot more knowledge about the underlying system to use properly than a new developer wants to learn

For developers familiar with the environment, these systems (mostly) work well. But for devs (even reasonably experienced ones) learning, it’s a massive hurdle - and given that they’re relied upon so much, it’s another “dead in the water” call for the “better” languages. And it’s a gigantic hurdle for shared hosting deployments.

PHP doesn’t really have this problem - so much shit is bundled with the runtime installation itself, very few developers need anything that requires PECL, and PEAR is a) pure PHP, so less of an issue, but more importantly b) kinda shit most of the time, so noone bothers to use it.

So - to get whatever language system we to actually work, here’s what we need:

  • Packaging system:
    • That's done developer-side only. No commands to run on the server.
    • Native code only - no compilation or dependency requirements outside this system itself
    • Packages download as source code into your local application tree, load automatically without importing in your code, and don't require *any* system configuration (env vars etc)
  • Language and runtime:
    • Simple syntax that's readable. A subset of Python would be fine, Ruby might be a little... esoteric. PHP's existing syntax is actually surprisingly good in this regard, save for all the dollar signs.
    • Environment needs to be well-standardised and VERY well featured - stuff like SQL database libraries, gdlib, XML, JSON, DOM etc need to be packaged as first class citizen libraries, and expected to be installed by default
    • The above libraries need to load themselves dynamically without any include() or require or use or import statements. This pretty much means the language needs a very strict and very simple namespacing system.
  • Slow-moving target. Python2.x vs Python3 will cause issues for years. Ruby's release speed causes big issues with old gems etc.

Basically, this is a very difficult task. And, there’s nothing out there already (that I’m aware of) that does even half this at all well.

Python or Lua would both be reasonable alternative choices. Both are “real” programming languages, which have already been used for CGI scripting. Lua has the edge over Python in performance, but Python is more popular and has a (much) bigger standard library.

I’m surprised no one mentioned Steve Huffman’s course on Udacity*. Simply point an aspiring web developer there, and many will be hooked on Python web developing for life.

*http://www.udacity.com/overview/Course/cs253

Personally I put my hand up for JavaScript as the obvious alternative (think Node.js). I know such a suggestion would create a look of horror on many a programmer’s face - but I’m sure this more to do with JavaScript not being Java, having the word “script” in its name and weak typing not giving the IDE’s much help. But the upside is we can stop writing in two different languages on the frontend and backend

OK very simple relies on 5 basic lines of PHP and allows you to import PHP functions but has any one tried XML XSL as a blogging platform? No it does not make you look cool or get your whites whiter but the PHP you do use is now simple and straight forward. I use it for blogish type code all the time.

OK here is a analogy that fits: PHP is like a piece of Quartersawn Oak. One craftsmen makes a piece of Stickley furniture. The wood worker at home with an identical piece of wood makes ashtrays.

But since we have far more cigarette smokers than furniture collectors you see many more ashtrays. PHP needs more craftsmen.

Keith h,

You do know PHP has include, include_once, require, and require_once, and even use, right?

Distros also like to ship PHP in pieces, so you wind up installing more than the core language to actually use it. If you build from source, you have to install all the dependencies for each of the included libraries, or it doesn’t get built. I’d imagine “cheap, shared hosting” has already taken care of this, so maybe you’ve never had to install these packages yourself. Someone had to.

I’ll also freely admit to knowing almost nothing about Microsoft’s compiler toolchain, yet I’ve managed to write C++ and C# on Windows without this being a problem. I’ve written plenty of Java, too, without having to care how the compiler gets invoked. This isn’t the issue you think it is.

If the chief complaint about non-PHP languages is “newbies have to learn too much to use them,” let me suggest you have to learn a lot of things to use PHP well too. If you don’t like thinking and learning, I suggest another career.

One of the explicit goals of my next project is to do whatever we can to buff up a … particular … open source language ecosystem such that it can truly compete with PHP in ease of installation and deployment.

Tell us more about this next project !!!
Have you started it yet ? What’s the progress so far ?
Is this project backed by StackExchange (the company) ?
How can we contribute ?

There was this fella once, gay dude, bad habits but quite bright, Turing, or summat, had this idea about what could do what and what could do anything. It seems PHP = FORTRAN = COBOL == (Just to piss you off), PL/1(What a fucking horror that one was) = Python = Ruby = Algol = Algol 68(see how old I am) = OK, you get the point.

When I’m not hacking about my computer I work with tradesmen - plumbers, carpenters, electricians. You should look at their tool boxes. Horror, upon horror, chipped chisels, busted wrenches, dull saws, bent drill bits, und so weiter.

There is no perfect tool. Well, except maybe Obama.

I think what everyone’s missing here is that PHP is CHEAP CHEAP CHEAP! If I need to set up a web department I know I can get three or four PHP monkeys for the price of one .net guy, and in my labour market (Thailand) there just are no Ruby or Python guys around.

I’m not building the next google, just very simple sites and processes. These days I don’t even need to cut code, just poop out brochure sites running WordPress.

Any replacement for PHP has to:

  1. Be easy to learn. I should be at ‘hello world’ within 10 minutes or less.
  2. Run on both Apache and IIS fairly easy and be simple to set up.