Hacker News new | ask | show | jobs
by coldtea 3767 days ago
>Hint: PHP is not one of those.

Hint, PHP is 100% one of those. The bad rap is either because of hipsterism or for issues that have been long solved.

The rest of its warts are no worse than the kind of BS any language has -- in fact before JS got in fashion the same things was said all the time for it too (for its bizarro coercion rules, only fp arithmetic, bs scope rules etc).

4 comments

Modern PHP really isn't all that bad, I still wouldn't recommend people go into PHP development out of fear that they might stumble into one of the pre-modern hellholes that I only barely escaped in the early days of my career.

It's almost an irrational fear, but I remember working on plugins for applications where plugin hooks were non-existent, and the canonical approach was to patch code. I remember applications where there was no frontend server, but rather a sprawl of PHP files each doing one thing and hooking into the 'main' system via a 'require settings.php'.

Apart from that, working within PHP still obliges you to do a lot of hairy things---like working with Drupal. Now Drupal is certainly better architected than say Mambo/Joomla ever was, but it's still a better CMS than it is a web framework and for some odd reason lots of companies insist on building things into Drupal even today.

Now ... all of my recent knowledge is second hand, I've been out of PHP and into Python for at least 5 years now

Drupal 8 is actually pretty nice. It can be a good choice for a web framework if you want a CMS.
Have those issues long been solved?

I'm not snarking; I honestly don't know. I tried using PHP years ago, threw up my hands in horror, and have never touched it since. I felt a little bad about that, but a few years back Eevee's "PHP: A Fractal of Bad Design" [1] persuaded me I wasn't missing much, and that my "learn a new language" time was better spent on Scala and then Python.

So what's changed in the last few years that makes it 100% as good as Ruby or Python for web development?

[1] https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/

>I'm not snarking; I honestly don't know. I tried using PHP years ago, threw up my hands in horror, and have never touched it since.

Without exactly knowing what exactly bothered you and what you use instead, we can't answer.

As for "PHP: A Fractal of Bad Design", I find the article quite shallow. One could say the same things comparing something like Python to Smalltalk, and yet Python is fine as it is.

You really can't answer this question?

> So what's changed in the last few years that makes it 100% as good as Ruby or Python for web development?

That seems like it should be pretty straightforward.

> One could say the same things comparing something like Python to Smalltalk, and yet Python is fine as it is.

If you've already dropped the standard from "100% as good as" to "fine as it is", then I think you've answered my question. Nobody's denying that PHP is a perfectly cromulent language; things get built in it. The servers hum, pages render, revenue is made. For its audience, it's fine as it is. fine But as far as language quality, developer experience, or aesthetic quality goes, I think PHP's kind of a mess. I don't mind that people don't care about the things that Eevee raises. Different strokes for different folks, after all. But I care about them.

Personally, having spent the last year writing Python, I agree that it's fine, that it's adequate. But I think it's often no better than adequate. The object orientation is bolted on and a bit clumsy, there are 70-or-so global functions that mostly should go objects, the inclusion stuff is kinda broken, there's a bunch of stuff that looks like Java envy, etc.

Given that's how I feel about Python, which is honestly fine, you could imagine why I think PHP looks like a novice in the 90s ate a half-dozen random O'Reily books and then threw up in a compiler. For people who do almost all their work in that language, have high detail memory, and are on the naturalist end of the naturalist/theorist spectrum, I think that's ok; they'll get by happily. I'm just none of those things.

>If you've already dropped the standard from "100% as good as" to "fine as it is",

Actually there's no logical inconsistency being "100% as good as" to "fine as it is". Obviously something "fine as it is" could be "100% as good as".

>But as far as language quality, developer experience, or aesthetic quality goes, I think PHP's kind of a mess.

If we're comparing it to something like Scheme or Haskell or Smalltalk, yes. So, compared to the "aesthetic quality" of what? Javascript? C++? Perl? Go? Java?

As for the developer experience, can we get any actual qualified statements? Because the average developer experience of getting lost in the JS framework-du-jour land, or the Java developer churning BS enterprise factories upon factories is probably worse. So what exactly is bad with the developer experience? Certainly not the tools, from Composer to IDEs catering to the language. And I'd say not the fact that "it just works" without elaborate setup (or do people love configuring stuff in other environments?).

>Personally, having spent the last year writing Python, I agree that it's fine, that it's adequate. But I think it's often no better than adequate. The object orientation is bolted on and a bit clumsy, there are 70-or-so global functions that mostly should go objects, the inclusion stuff is kinda broken, there's a bunch of stuff that looks like Java envy, etc.

All of points being to it being a pragmatic language that developed from early versions.

>* For people who do almost all their work in that language, have high detail memory, and are on the naturalist end of the naturalist/theorist spectrum, I think that's ok; they'll get by happily. I'm just none of those things.*

Well, I don't do most of my work on the language (I mostly work with JS these days. I've also been using Python professionally since before 2.0, with early Zope et al). But I still find it perfectly fine.

If one has an issue with "70-or-so global functions", for example, I can't imagine how he would feel with JS "global by default" scoping -- which unlike PHPs is a core language issue.

Sorry I missed your reply until now.

> there's no logical inconsistency being "100% as good as" to "fine as it is". Obviously something "fine as it is" could be "100% as good as".

One phrase I take meaning "adequate", the other "good". Of course, if the thing you're comparing it with is merely serviceable, then yes. If all you're saying is that PHP is no worse than Javascript as a language, then sure, fine. I also don't think Javascript is a particularly good language.

I thought you were saying that PHP's issues "have been long solved", so I thought perhaps I was missing something since my last encounter. But given the tone of your responses here and your repeated evasion of the question "So what's changed in the last few years that makes it 100% as good as Ruby or Python for web development?" I'm just going to keep running with my theory that I'm not missing much.

Because it's relevant to this thread, here is a presentation that I did on Go from a PHP perspective for a local PHP group.

http://www.brightball.com/golang/go-from-a-php-perspective

TLDR: Go is good at the things PHP is bad at. PHP is good at the things Go is bad at. They actually compliment each other very well.

I agree, but if someone were starting a new project I'm not sure why I'd recommend PHP over any other stack.
Things I like about PHP: it's not perl, which it replaced for webdev. It's very optimized, and people with fat budgets pay for that (eg. Facebook). It connects to everything. Most of its (useful to webdev type situation) libraries are more mature than the equivalents in other languages, because more people have used them for longer. It had working unicode from the early days. It runs everywhere. Loads of people know enough of it to be dangerous / collaborate, and they tend to be numerous in the young/cheap hire pool. It's pretty much web-oriented, but can do scripting fine as well. It has a relatively stable configuration. Honestly, I think it's a very Unix-like solution to webdev problems, because it lets you roll your own solution, stays out of your way (unless requested), and encourages you to code in higher level languages. Yes, a lot of the code out there is horrible. Yes, most people code on frameworks which replace half the language with ugly hanging half-implemented abstractions. Yes, the function name thing is a pain. But mostly, really always almost mostly, it just works ... quite fast indeed, and everywhere. Yay PHP!
Ooh, please don't badmouth perl. Modern perl (e.g. https://pragprog.com/book/swperl/modern-perl-fourth-edition ) is a much more sanely designed environment than modern php is.
I originally wrote a long comment about how I've written CPAN modules and worked professionally in perl but will never do it again, explaining why technical betamax superiority was irrelevant because perl's users left before it got its act together, but I think in hindsight a simpler summary would be this: grep 'man perldsc' ~/.bash_history|wc -l
each to their own. I'd like to do more stuff in other languages, but my perl skills are in too high demand, and it's fun.
Works, gets constantly better, no JS-like fatigue, fast PHP7 engine, tons of tools, libs and support.
Isn't all of that true of, say, Ruby?
I am pretty fluent in ruby, which I learned after PHP specifically because I wanted to migrate, and I really enjoy using it. However, compared to PHP ruby is slow, it took ages before it had a half-decent unicode solution, and once you step out of the rails rah-rah it's a bit desolate on quality libraries... there's 10 half-built versions of everything, and no decent go-to implementation. On the plus side, ruby is nominally better for reflective metaprogramming, but that's really a rare use case.
The "fast PHP7 engine" part not. Raw Ruby was slower (but comparable) to raw PHP, so with this new engine which consistently runs real life workloads 2x, PHP7 should be like twice as fast.

And PHP still has more vendors, support in all kinds of hosts, even in third world facilities, and more companies offering commercial support. Plus there's stuff in PHP that don't exist with the same level of maturity/adoption/community in Ruby/Rails, e.g. Wordpress.

And even a path to static typing, through Hack.

It may be, but the above poster also left out one of PHP's strengths - availability. It's already running and ready to go on whatever cheap shared host you've been on for the last 20yrs. Ruby/Rails likely isn't.