
PHP needs to die. What will replace it? - seldo
http://seldo.com/weblog/2010/09/27/php_needs_to_die_what_will_replace_it
======
jlgbecom
I've been using PHP professionally since it was called PHP/FI, and while it's
a terribly designed language, I've longed stopped hating it. I know all of
it's quirks, and I know all of it's work arounds, and the density of support
it has can't be beat.

I wouldn't complain if a better server-side language came around (not a big
fan of Ruby's syntax, but Google's Go looks enticing), but until then, I've
built incredibly complex apps in PHP, and rarely do I run into a limitation of
the language. My biggest issue in the past was the lack of namespaces, and 5.3
has those.

I think the best thing you could do to get a new language as popular as PHP
isn't to evangelize, or even to make the language dead simple, but make it
dead simple for administrators to add support to a typical shared hosting
environment.

~~~
seldo
PHP's amenability to shared hosting environments is an advantage I failed to
mention.

I'm pretty much in the same place as you with regards to PHP: I know it like
the back of my hand and everything and everybody works with it. But the code
is ugly compared to other languages and I really want method chaining, dammit.
Plus, of course, I don't want to have to write an MVC framework every time I
want to do something.

~~~
jlgbecom
Unless you're being more specific than I think you are, PHP5 has basic support
for method chaining, I use it all the time.

~~~
byoung2
I use structures like this in PHP5 all the time:

    
    
      $object->doThis()->doThat()->doTheOther();
    

But maybe he is referring to method chaining using PHP's built-in functions.
There isn't a way that I'm aware of to do the following (short of wrapping the
built-in functions with your own classes):

    
    
      $string->preg_replace("/[^A-Za-z]+/","_")->trim()->upper();

~~~
seldo
Precisely what I meant, thanks for clarifying.

~~~
BerislavLopac
But this is not method chaining, that's simple function nesting, and can
easily be done as:

$string = preg_replace("/[^A-Za-z]+/","_", trim(upper($string)));

Or am I missing your point?

------
gkoberger
PHP can die when there's another language that's as dead simple to run as PHP.
A new programmer can open up a text file with a php extension on (pretty much)
any web server, type "<? echo "Hello World"; ?>", and it works.

~~~
jameskilton
You are mixing your requirements really badly here: a language that's "dead
simple to run" vs a language that works stupidly simple with the web.

Ruby is very easy to run: puts "Hello World"

As is perl: print "Hello World";

Php? <?php echo "Hello World"; ?> (wtf is all that crap, says the new
programmer)

The point the OP is trying to make is the "stupid simple with the web" side of
the equation. Of course the PHP side isn't as simple as "the language runs on
the web". PHP runs on Apache because of the tons of work put into mod_php to
integrated it and make it work as easy as possible.

You can't "just run" php on nginx, lighty, etc. Then you need to setup FastCGI
instances, and now you're no different from Rails land with mongrels or thins.

~~~
api
He is referring to an under-appreciated virtue of good software:
installability.

apt-get install php5

Usually you don't even need that.

~~~
chc
I don't understand how this is distinct from PHP's competition. Python is
"apt-get install python" — two extra characters are not going to break even
the greenest noob's back.

~~~
jrockway
And if this is the argument, Perl is in Debian's default install anyway. Hell,
the APT system is partially written _in_ Perl...

------
bl4k
A lot of misinformation in this post. Perl pointers? The Perl hash is the same
as the PHP assoc. array (thats where they got it from). PHP has both lambda's
and method chaining (method chaining isn't a lang feature).

confusing language and platform/framework - "the language now requires
modification by a framework to do what you need." and "I want a language that
assumes everything I will be building is an MVC web app, and builds that right
into the core language, not just a library.". yikes.

Not sure what else to believe in this article after spotting basic errors (not
to mention terrible cliches, assumptions, no background or references etc. and
statements like this - "nowadays it doesn't feel like you're doing it properly
these days")

~~~
seldo
You're the second person to mention that perl doesn't have pointers;
references are not strictly speaking pointers but functionally very similar. I
think it's pretty obvious those are what I was referring to, and disputing the
naming seems like nit-picking.

Many of PHP's basic functions do not return objects, therefore method chaining
frequently doesn't work. It would have been more correct to say that I want
"everything is an object" to be a feature of the language.

Lambdas only recently turned up in PHP (though I'm pleased to see them!). My
point is that in PHP these features are being shoehorned in late in life, and
it seems like a language which was designed with the expectation of these
features would be a better choice at this point.

And finally, yes, I want a language that assumes everything I will be building
is an MVC web app, and builds the necessary infrastructure at the language
level, with the performance and stability gains that implies, rather than
having it built as a framework on top of the language. It seems weird, I
realize, but no more weird than PHP seemed in 1995, with its assumption that
everything you'd be writing was a web page.

~~~
chromatic
_references are not strictly speaking pointers but functionally very similar_

I have more than a passing familiarity with C and Perl. References and
pointers are very different. For example, you have to know _where_ you
allocated the memory pointed to to work with pointers effectively. You can
also lie to the compiler about the type of pointer. You can also do math with
pointers.

These are very useful things to do in C (or assembly or C++ or whichever
languages give you access to raw memory), but you don't have to do any of
those things in Perl because you don't have access to raw memory.

Similarly you can get into a circular reference situation with references that
you won't normally find in C unless you have a specific type of garbage
collector.

 _disputing the naming seems like nit-picking_

Accuracy is important in programming. The difference between lightning and
lightning bugs is not merely degree.

------
jrockway
Perl has pointers? Uh, nope.

Also, how does Perl not have associative arrays? Oh, you mean that vectors and
dictionaries are separate types, whereas PHP has one type that does both
poorly? Yeah, I'm sure that's why PHP is so popular.

(What is it with people writing about Perl as though they are experts without
ever having written a Perl program?)

~~~
seldo
Looking back at my own experience as a newbie developer in 1995, the
convenience of PHP was absolutely the reason I picked PHP over perl, and
having arrays that could also be dictionaries if I changed my mind was a big
part of that.

~~~
chromatic
What kind of programs are these where you don't have to rewrite a bunch of
other code anyway to account for the difference between keyed and indexed
lookups?

~~~
neilk
PHP programs.

------
asnyder
Yet another article that wants a language to be a framework. Ruby on Rails is
a framework just like Symphony, Kohana, etc are frameworks for PHP.

Thus you can't compare something like Rails to PHP, but rather would need to
compare Rails to the many frameworks out there. There are many frameworks out
there that make working with PHP a joy, some like NOLOH (which I'm a co-
founder of) feels like it's own thing completely allowing you to work in a
single language that shields you from having to deal with the craziness that
is client-server interaction, AJAX, Comet, SEO, etc, something which the
author alludes to wanting to have.

If you don't want to use a framework, PHP can be very useful by itself to
write quick scripts, just like many other languages. Furthermore, the release
of PHP 5.3 last year has moved PHP forward considerably and makes the
frameworks and libraries available for it even cleaner, and more powerful than
before.

Personally, I'm an advocate of using the best tools for the job, but first
it's important to understand what in fact that tool is and what it's capable
of.

Ultimately, any blanket statement that suggests something that's being used by
millions of developers and some of the largest companies out there should die
just doesn't sit right with me.

I've noticed that it's in vogue to bash PHP, but frankly, with the current
state of the language, along with its frameworks and libraries, there's no
better time to work with PHP. It reminds me of a recent exchange I had with an
associate of mine, we were talking about writing a script and when the mention
of PHP came up, he bashed it without reason. He hadn't used PHP in years, but
just had this impression in his mind that it was bad. Several days later I
showed him the completed script in PHP and how clean, clear and concise it
was. He was amazed.

I would hope that we could move beyond such statements and take pride in what
we produce, instead of second guessing yourself when the tool you're using is
getting the job done, lets explore some of the amazing tools, frameworks and
libraries that are pushing PHP forward.

~~~
jlgbecom
_I've noticed that it's in vogue to bash PHP, but frankly, with the current
state of the language, along with its frameworks and libraries, there's no
better time to work with PHP._

I've noticed that, too, I think a lot of people who bash PHP may have used it
at one point, switched to something like Rails or Django, and assumed that PHP
stood still, which just wasn't the case. In fact, while I may not use rails,
I'm very glad it came about, because it was a very necessary kick-in-the-ass
to other language communities to address common and necessary development
concerns.

The thing about new technologies, is that they rarely replace the old
technologies, usually they just provide new ideas to make the old technologies
better.

~~~
rbxbx
I wouldn't be surprised; that's certainly the pattern that befell (early-ish)
linux users that moved away from the platform.

------
lkrubner
The language that newbies love is never going to be the language that experts
love. Andy Hunt writes about this somewhat in his book Pragmatic Thinking and
Learning - newbies need a level of structure and support that experts would
feel to be braces restricting their movement.

Whatever eventually replaces PHP will have to be easy for beginners to get
going with. I assume it will not be a compiled language. I think that rules
out most of the languages on the JVM, even the really easy ones, because it is
on the JVM, and dealing with compiling is one more hoop that beginners won't
necessarily want to jump through. CLASSPATH is not friendly. Likewise, I'd
rule out .NET languages.

New languages tend to gain a foothold when people change contexts, so I assume
cell phones offer a starting point. A light weight script language that works
on cell phones? I am not sure what that will be.

------
larrykubin
Yes, let's kill PHP. Now we just have to figure out who's gonna rewrite
Facebook, Wikipedia, Yahoo, flickr, digg, all drupal sites, all Wordpress
blogs...

~~~
seiji
Facebook has said php is a legacy problem and they wouldn't use it again if
they were starting over. The Wikipedia code is horrendous. Wordpress is a
security exploit masquerading as a CMS.

------
jbarham
I've found PHP very useful as an indicator of what jobs I do _not_ want to
apply for.

------
bobds
I have a similar love/hate relationship with PHP. I write PHP because I want
my code to be used by as many people as possible. As long as another language
gets even a tenth of the deployments PHP has, I will gladly start writing
software in that language.

One thing that must surely die, is PHP 4. Please stop making your PHP projects
backwards compatible from PHP 4.2 and up. PHP 5 is a lot more palatable and
5.3 even more so.

We have to kill PHP version 4. With fire.

It would be a service to all PHP users, as well as the PHP developers who
still have to maintain the 4.2 branch. And it would move PHP 6 one step closer
to reality, from the pipe dream it seems like today.

------
noodle
perl is dead?

[http://www.indeed.com/jobtrends?q=perl,+php,+rails,+ruby&...](http://www.indeed.com/jobtrends?q=perl,+php,+rails,+ruby&l=)

~~~
rbranson
[http://www.indeed.com/jobtrends?q=perl,+php,+rails,+ruby&...](http://www.indeed.com/jobtrends?q=perl,+php,+rails,+ruby&l=&relative=1)

~~~
noodle
that is also an accurate picture, but lack of growth doesn't imply death.

~~~
rbranson
It doesn't imply it, it forecasts it.

------
ysaw
Someone is going to figure out a really nice framework on top of nodejs for
making webpages with javascript.

edit:

Which is to say, I think javascript is a great language, has the benefit of
being the de-facto language of UI development on the browser (and on a lot of
embedded apps now as well). Nodejs alone is much too low-level and evented for
normal humans to use for throwing together a web site without callback
mindfucks, but its a great base to build something on.

------
davidw
There's some confusion between PHP and Perl, the languages, and PHP and
Perl+various things as solutions for creating web sites.

------
cesarsalazar12
I think most people is missing are missing the point. The issue isn't whether
PHP, Python, Ruby or Perl are better as of today, but if we are missing
something that is even more aligned to web development. For the past few years
PHP has been the language of choice for many many programmers because as its
name imply, it "pre processes hypertext" (and words actually matter). Do we
need some new kind of language (not framework) that understands caching, REST,
CRUD, templating, asynchronous calls the way we need it on the web of today
(and the near future)?

I guess nobody here is calling for a new language to rule them all, or for a
champion framework. I guess as hackers the least we can do is _DO NOT_ assume
that what we have today is what we'll need tomorrow.

I don't know if there's an easy answer to the dilemma (or if your arguments
are solid enough) but it makes me think. Thanks for bringing this up.

------
lallysingh
One major point of contention: the quality of PHP's documentation is a
_critical_ part of it's overall value to developers.

A language isn't done until it's documented. Parts of the language available
that aren't documented simply don't count.

A competitor has to beat PHP on both the lingual and documentation fronts to
win.

------
wccrawford
If a programming language 'needs to die', it does. If you have something
better in mind, go ahead and write it. If it really is the replacement for the
language you hate, I'm sure everyone will thank you for it.

True programmers aren't stuck to a language. They switch to whatever's best
for what they're doing. Often, that means sticking with the language they know
best to minimize issues and speed development. But often, they know multiple
anyhow and have more choice available.

True programmers make a point to learn about the new languages and their
strengths and weaknesses. If a new language came out and was worth looking at,
they would. They may not learn enough to actually use the language yet, but
always enough to know when that language might be the best solution.

------
mgrouchy
I imagine that the convenience of PHP is why its still going strong. Simply
because you could have a html file with some php tags in there and throw it up
in a directory on your webhost and you now have a "dynamic" webpage.

~~~
andfarm
The problem is that most popular PHP applications (and, by extension, most
PHP-driven sites) are far more complex than that model allows for. It's
telling that HTML appearing before a <? tag is generally considered a mistake.
:)

------
aaronbrethorst
> Ruby is a newer, cleaner language, with modern features and a sparse,
> elegant syntax...

This isn't entirely true. According to the two languages' Wikipedia pages,
development on PHP started a year after Ruby. The first public version of PHP
came out six months before Ruby.

<http://en.wikipedia.org/wiki/Ruby_language> and
<http://en.wikipedia.org/wiki/Php> have more.

Here are the salient dates:

\- Ruby conceived of in December 1993

\- PHP development started in 1994

\- PHP/FI 1.0 released in June 1995

\- Ruby 0.95 released in December 1995

\- PHP 3.0 released in 1997

~~~
chc
Those dates don't say what you're claiming. They say that PHP development
started _at most_ a year after Ruby was "conceived of" ("December 1993" could
be as little as one day before something that happened in "1994"), and PHP/FI
1.0 was released before Ruby .95.

Also, I'm not sure comparing languages by when somebody started toying with
the first prototypes is very meaningful. You could say Clojure is decades old
by viewing Lisp as a prototype.

~~~
aaronbrethorst
Sure they do.

The implication in the article, as I read it, was 'Ruby is a wizbangy new
language that sprouted into being only recently' whereas the truth is that it
and PHP are just about the same age.

~~~
chc
Maybe I wasn't clear. I was disagreeing with the statement: "development on
PHP started a year after Ruby"

The dates you posted show that this is almost certainly not the case, though
they do indeed disprove the idea that "Ruby is a wizbangy new language that
sprouted into being only recently".

~~~
aaronbrethorst
The very latest possible date real development started on Ruby was Aug 19,
1994. <http://cvs.ruby-lang.org/pub/ruby/1.0/ChangeLog-pre-alpha>

It is likely this code predates that date given that there is no reference to
the 0.95 release or anything before that.

update: the earliest release I can find is Ruby 0.49 from
<http://eigenclass.org/hiki/ruby+0.95> (direct link: ftp://ftp.ruby-
lang.org/pub/ruby/1.0/ruby-0.49.tar.gz)

The earliest date mentioned in the CVS entries file is March 17, 1994.

To me, the point of this whole thing is that the author's statement of "Ruby
is a newer...language" is inaccurate. You're absolutely correct that I cannot
definitely prove that "development on PHP started a year after Ruby."

And language age comparisons are entirely meaningful in this case, given that
the OA _specifically_ describes Ruby as a newer language than PHP. Ruby is
definitely clearer and cleaner. But it is certainly not newer.

------
jcromartie
PHP established itself when there was no real contender for a HTML
preprocessor that could mix server-side code in with web pages. There are a
staggering number of choices for this now, but none of them come anywhere
close to being widely supported on every Linux shared host in the world like
PHP is.

------
ax0n
Hah! Rails? _Seriously?_ Rails is a framework, not a language. And there are
far too many really huge project using PHP (larger than any Perl project I
know of) to suggest whacking PHP for Ruby in any flavor.

------
billybob
Am I the only one who sometimes wishes I could write PHP-style pages in Ruby?
Sometimes a whole framework is overkill. I wish I could make Ruby pages as
simply as I can take an HTML file and sprinkle in some PHP.

------
there
he cites performance as the main reason why he hates frameworks, but it seems
like a compiled php module that implements an mvc framework would gain
performance and put the "web development back into the language", so to speak.

creating a new language is not the answer. that will work up until the day you
need to do something beyond tying a database to an html form, like process
images or encrypt files or talk to a weird database that isn't mysql. php,
ruby, and python have a ton of modules and 3rd party libraries that can be
tossed in to accomplish a lot of things.

------
acconrad
(Insert hackneyed religious battle between Python and Ruby here).

~~~
seldo
Precisely what I was trying to avoid by being as respectful as I could to both
languages. They're great, they just don't do what I want.

~~~
acconrad
Haha nothing against your article - it's well written. But if we're on HN, any
post that can invite an argument, will invite an argument.

------
ahi
My day job is mostly php and I have come to hate it. 5.3 is tolerable, but it
was released in 2009 so a lot of servers/hosting are stuck with the completely
fucked PHP of the past 15 years.

PHP.net's documentation is pretty good, even though half of it is discussion
of language limitations. The problem is that PHP is also the first language
every new developer so there is an incredible noise background. Searching for
a problem in another language I can usually find a could good blog posts with
solutions and comments. In php it's mostly blog spam complete with sql
injection holes and other bugs.

------
trustfundbaby
Maybe I'm a little grouchy today but the article was a bit annoying to me.

\- His argument for why PHP needs to die basically comes down to "PHP is
lacking is lambdas and method chaining".

\- He flirts with a possible replacement to PHP being Ruby on Rails, even
though he comes around to note that Rails is not a language (essentially
making that whole tangent masturbatory)

\- Then he forgets to assess Sinatra <http://www.sinatrarb.com/> which really
sounds like something that actually fit the mold of what he's actually looking
for (allows you basically run Ruby on a webserver)

------
petervandijck
Actually a thoughtful article.

------
pinksoda
To each their own. Use something else if you want, but there's millions of
people who don't want PHP to die.

~~~
phaylon
Correct. And people in the Perl community didn't stop just because someone
else had more market-share in web development. There's many area's of
programming and I'm always surprised when people think web development is the
only one that matters.

~~~
seldo
A good point. I focus on web development, and the question is entirely about
what will replace PHP in the field of web development (not that PHP is
extensively used anywhere else).

~~~
phaylon
I agree. I'm not sure if the "replacement" will be a single technology or
merely a standardized interface for hooking up web applications on a host.

