Hacker News new | ask | show | jobs
by kemayo 5369 days ago
To replace PHP you need:

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.

3 comments

Yeah, exactly. This headline could have been written with the same justification in 1999. Yet PHP refuses to die. Clearly us hackers are missing something important.
The fact it actually solves real world problems would be a first "something important" us so called hackers are missing.
Having not used php for 12 years, I recently accepted a freelance job for a client who had been left in the lurch by his php developer who seemingly abandoned the project because she was out of her depth.

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).

Major PHP versions are the evolutionary jumps for the language. They don't tend to worry as much about backwards-compatibility when going from PHP3 to PHP4 to PHP5. I've read that PHP6 was supposed to take it further and outright remove a lot of deprecated and insecure aspects of the language, but I don't know if or when PHP6 will be released.

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.

I would suggest that minor PHP versions often are, too. Significant internal changes between 5.x versions have caused some code to break (and other code to act very differently than it was originally intended to).
Note that python3 still doesn't have widespread adoption, because there are still widely used libraries lacking support for it.
But in the coming future it will. All major libraries and frameworks are going to port over to python 3.

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.

"But in the coming future it will. All major libraries and frameworks are going to port over to python 3."

Don't bet on it. It has been too many a years already, and no dice (or minimal dice)

This was a big topic of discussion at PyconAU this year.

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.

I don't agree that MVC and beginner friendliness are fundamentally incompatible. Nevertheless, if you can't get a "hello world" site set up in a very small number of essentially trivial (and easily memorize-able) steps then that's a big show stopper.
It really depends on the beginner I guess. It seems like what kemayo is saying is that there are beginner programmers and then there are people who don't want to be a programmer at all really, but might like the idea of having a dynamic year string printed in the footer of their page.

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.

From the perspective of the "average" professional programmer with a CS degree the vast majority of all programmers, even those who get paid to do it, are rank and utter beginners. Most programmers cannot solve fizzbuzz. Most programmers don't grok recursion, and have trouble with iteration from time to time. If you were to look at a graph of # of programmers within different skill level bins the "beginner" bin would outweigh all the others by a significant margin.

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.

Well said. Your second paragraph expands well on what I was thinking when I said we forget that beginners have a different idea of what 'trivial' means. The MVC concept (for example) might be trivial to those who get it, but it's likely seen as undesired friction by the beginner, while simultaneously being a good next step for them to acclimatise to should they be wishing to progress. Something that better facilitates this - or things like it - than what we currently have would be great.
Are you saying that developing an API in PHP is insane?
No, I'm saying that the stuff built into PHP is weird and inconsistent. I should change it to "sane default library" from "sane API".

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).

> No, I'm saying that the stuff built into PHP is weird and inconsistent.

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.

You're ascribing things to me that aren't present in the text.

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.

But it can (and should be) fixed. It's not that difficult.

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.

The problem is not that "two different dudes implemented it. At different times. Probably, from different continents. They didn't notice it at the time". Is is that it was allowed to be added to the core library without it being questioned and fixed before it was too late to fix for compatibility reasons. That is the ultimate problem. I would rather a language or framework or library move slowly and correctly than add things haphazardly.
You're not getting what I'm saying. Even if you are super careful, mistakes will be made. What's important is how you deal will them once they're there.

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.

I do understand what you are saying though for the same reason, it makes me not want to use PHP in a production setting. The fact that the core developers are willing to add things without thinking them through forcing the users to deal with problems that can't be fixed so as to not break existing sites concerns me.
The thing is, these functions were added a long time ago when the language and the project itself was in it's infancy. It's purpose and audience was different. I doubt anyone developing at the time expected it to last this long and be used by this many people. The goal was to put in as much functionality as possible to be useful. It was web scripting for C programmers.

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.

If the inconsistencies really bother you, write:

function my_in_array($haystack, $needle) { return in_array($needle, $haystack); }

or whatever, and be done with it...

So now there are some functions you have to prefix with my_, and others you don't?

You're not really helping your cause here.