Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

"Despite its popularity, PHP is considered by the programming elite, almost without exception, as one of the worst languages currently in use today"

I would say, the blogging-about-programming elite, rather than the actual programming elite. I haven't coded PHP in years, but some of the most brilliant devs I know use it when it fits the task.



PHP is a programming language (that is, a formal grammar for specifying the operations a computer should perform), but also an implementation of an interpreter for that grammar. You're talking about the implementation, which is of fair quality (certainly better than, say, MRI Ruby) and very widely-deployed, a combination which many devs (brilliant or not) take advantage of.

People who say PHP is badly designed, however, aren't talking about the implementation; rather, they're strictly talking about the language itself—the syntax, the semantics, and the standard library. There is no advantage to the way PHP-the-language does things; it makes nonsensical choices (like the flat, disorganized, all-libraries-included function namespace, the inability to chain method calls in a single expression, the extreme amount of "weakly-typed" cruft surrounding the comparison operators, etc.) which derive no benefit.

It would be strictly beneficial to the programming ecosystem if PHP-the-language were treated as an object-code for other, better-designed languages to target, such that PHP-the-implementation could be used without needing to write in PHP.


PHP-the-implementation is pretty spectacularly shitty too — it'd be even worse than MRI for persistent processes of any sort.

What's good about PHP is the execution/dispatch/deployment model, which papers over massive deficiencies in the infantile implementation (much less the know-nothing language).


PHP is not supposed to have persistent process of any sort. It's stateless (if you shard/share sessions well, it's super easy to scale).


Excellent point, and often (as now) overlooked. PHP does have some brilliant design choices, for example attaching itself to the Apache process, terminating when the request ends - this makes a lot less vulnerable to issues like memory handling. Some extensions may leak like a sieve, but since it's all cleaned up when the request ends it never really becomes a problem.


> certainly better than, say, MRI Ruby

Care to give some proof?

Say, performance-wise, MRI is not any worse than PHP[1]. And as far as I understand, PHP implementation is just plain horrible[2].

[1] http://shootout.alioth.debian.org/u32q/benchmark.php?test=al...

[2] http://blog.paulbiggar.com/archive/introducing-malicious-cod...


PHP has been able to chain method calls and members since 5.0. The main thing that can't be chained outside of PHP trunk is array access after a method or function call.


I spent a few years immersed in both PHP the language and PHP the implementation. Each is as shitty as the other.


I kind of agree. But I still find 90% of extremely talented programmers breath a sigh of relief when they find they're not having to use PHP. Even for web development.

PHP was great a few years ago, and by great I mean "one of the only options". PHP is active on every shared web host around. It's the norm. Only recently have the likes of Ruby and Python become popular on shared hosts. Personally I think that's fantastic.


63.5% of stats are made up on the spot.


He did say "But I still find 90% of..." as opposed to "90% of..." making it an opinion, not a pure statistic.

edit: that's not to say he didn't make up the statistic for his opinion.


Also, AWS/Heroku/GAE give you non-shared-hosting ways to deploy. Still, another tool in the box.


Ok, I'll admit, this may sound a bit trollish, but if PHP is not one of the worst languages, then what languages do you rank below PHP? C comes to mind, not as a bad language itself, but lack of web libraries, but that's about it.


It's hard to find a worse example than php, because when many "bad" languages fail in one or the other category, php seems to fail in most categories.

* Java has a really repetitive syntax, but it's libraries might make up for that.

* C++ with all it's features has bazillion ways to shoot yourself, but it's arguably fast and the syntax is bearable.

But php has both an ugly syntax, horrendous stdlib, and fame of security issues.

Maybe COBOL or MUMPS could be worse than php... haven't used these though.


I wouldn't call C a worse "language" than PHP by far.


It has messy stdlib (gets()!) and lots of features that you can shoot yourself in the foot with (software security would look very different if it had arrays like D).


The C standard library is very clean. gets is left in the C89 and C99 standards for backward compatibility an deprecated right now. Nobody uses gets nowadays.


Of the mainstream languages there probably aren't too many. But probably COBOL? C++ is pretty hateful too. Oh, bash is a nasty language too.

Your "worst" is probably ill-defined: C is bad for web programming, but is certainly an elegant language and pretty good in its niche.


VBScript is worse. There's always that.


I don't think PHP is a beautiful language. But that's beside the point. Sometimes you need a hammer, sometimes a screwdriver. You don't dismiss a tool because it's not pretty.


Hammer and screwdriver are equally ugly/pretty. But that's beside the point - it's not the ugliness of php that puts people off, it's the clumsiness and awkwardness of the tool.


I don't care that my hammer or screwdriver are ugly. My hammer drives in nails, and my screwdriver inserts and removes screws quite well.

To me, both are effective at the tasks I need them to accomplish.


Great, if a standard of mere adequacy is your goal it suits perfectly.


That's quite a broad statement.

Is Instapaper merely adequate, or is it better? Would it have been that much better if it was constructed in Rails?

IIRC, Instapaper's a PHP application. I could have mentioned a larger site, but Instapaper was probably a better example, since it's quite popular with HNers.


Well, I hate Rails so that wouldn't be my first comparison.

But yes, it would probably be more easily maintainable if written in a better language, and the developers would be able to add new features more quickly.

To comment based on your metaphor, the problem is not that the screwdriver/hammer is ugly. It's that the grip doesn't feel right and it's unbalanced. You can turn the screw and drive the nail, but it takes more effort and might leave your hands scraped up.


But grip, feel and balance are very personal, individual things. What fits for one person may not work for another. Just like programming languages.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: