News for hackers. Stuff that matters.
Re:PHP in 2019 by simias on Wednesday May 15, 2019 @07:14AM (#19918262)
As far as I'm concerned the bridges have burned a long time ago and I definitely can't see myself giving PHP a second chance. That being said, if I'm wrong and PHP has really managed to become a decent language (or at least something that's not completely insane) its defenders should focus on actually showing what modern PHP code looks like.

Is performance that much of a big deal for most people? In a world where Ruby on Rail exists I find that hard to believe. Server are cheaper and vastly more powerful now than in PHP's infancy, I'm sure that for the vast majority of use cases PHP's performance (whatever it is) is good enough.

The infamous "Fractal of Bad Design" wasn't about that, it was about the ridiculously inconsistent and error-prone API, the insane defaults, the counter-intuitive behaviour of '==', the headless chicken development roadmap where maintainers would add features because they were popular in other programing languages without trying to figure out if they had their place in PHP,...

Surely a lot of this has turned into technical debt? Even assuming that "modern" PHP managed to come up with better ways to deal with all of this, I assume that these obsolete functions and operators still linger for backward compatibility? If so how do you avoid them?

Again, I personally don't really care, but if you want to win new converts who haven't been as scarred by PHP as I have been I think that's where you should focus your efforts. Maybe somebody should write a point-by-point rebuttal to the "fractal of bad design" article?

Re:PHP in 2019 by swalsh on Wednesday May 15, 2019 @08:50AM (#19918856)
I was pretty anti-PHP before I worked for a multi-billion dollar company that was built on top of it. It's not a beautiful language, but it offers a lot of side benefits in terms of dev-ops, and tooling, and frameworks. As a company, the language was not something that held us back. The company moved really fast, and PHP was a large part a big part of why. In my career over the past 14 years I've done web work using ruby, python, C#, javascript, and Java. but that ugly PHP site was the one that impressed me the most. People moved fast in it, our tooling never held us back, everything just worked. It was the most utilitarian environment i've worked in. The first time I touched PHP, it was a spaghetti disaster... but today, next to python It's my go to language. It gets the job done faster, and it's maintainability is just fine. It really doesn't matter if sometimes things just look odd.
Re:PHP in 2019 by mywittyname on Wednesday May 15, 2019 @09:18AM (#19919071)
I have to echo this.

I worked on a data pipeline that was a mountain of PHP scripts bolted together with Bash and it was such a breeze to maintain. Using Symfony ensures that every command is well documented and consistent in design and use.

Something I never appreciated about PHP until recently is that character encoding is so much more robust in PHP than other languages. We were forced to replace our pipeline with Python because of a combination of "Eww, PHP" from new management and "data scientists use Python." Character encoding was a huge, unexpected annoyance.

Re:PHP in 2019 by kibwen on Wednesday May 15, 2019 @09:57AM (#19919395)
Which version of Python? I ask because making fundamental changes to character encoding was the single most disruptive feature of the Python 2/Python 3 split.
Re:PHP in 2019 by wwweston on Wednesday May 15, 2019 @02:45PM (#19922448)
> character encoding is so much more robust in PHP than other languages.

This is not what I expected -- my limited past experiences with anything outside of Latin-1 using PHP have been perplexing and not smooth (and I generally like PHP well enough). Can you elaborate on what features or approach can make things robust?

Re:PHP in 2019 by megous on Wednesday May 15, 2019 @05:38PM (#19924039)
PHP doesn't care about your encoding. Therefore it's simpler to work with any encoding in it, because you're managing it manually.
Re:PHP in 2019 by deckard1 on Wednesday May 15, 2019 @11:32AM (#19920411)
Most of this would apply to Perl, as well. Which I can't fathom why Perl didn't easily beat out Python in the data science world. It's incredibly stable (version 5, that is), fast, and can just about rip apart and parse any raw data you have with ease. Python may "feel" newer, but there are only a few years age difference. Even Ruby isn't that much newer.

Tragically, Perl developed its "unreadable" reputation because it was the language du jour of the system admin/hacking world. The first time most people experienced Perl was by finding some crufty old script that glued a bunch of shell tools together haphazardly. Few developers today have actually seen what good, production Perl can look like.

No disrespect to the wonderful system admins of years past, but those guys were a different breed. They weren't programmers. But Perl still let them get their job done. Their unmaintainable messes caused a great deal of harm to Perl.

Re:PHP in 2019 by acomjean on Wednesday May 15, 2019 @05:42PM (#19924071)
I maintain others Perl code and am no expert. Its our most use web tool and has been running for 10 years. I think Perl is different enough to confuse people who look at it (@,%,$) and it can make it hard to follow. I still have a little problems switching to it from other languages sometimes (do x unless y seems backward to me). I've also been told I write perl like a c programmer. Perl does have some beautiful parts though..

CPAN is great, but its hard sometimes when I just want to install something easy. It was the first great shared library and it shows its age a bit. Last time I ran it, it was compiling C code for some strange reason. We have trouble setting up shared perl environments, something we don'e have with python.

Biology has a lot of Perl code still, but it seems to moving to python.

Terrible code exists in many languages.

Re:PHP in 2019 by brendt_gd on Wednesday May 15, 2019 @09:00AM (#19918938)
I appreciate you sharing this. The goal of my post was not to convince people to "switch to PHP right now", but rather to tell them you can do pretty cool things with it, and that it's actually fun to work in.
Re:PHP in 2019 by chriswarbo on Wednesday May 15, 2019 @08:24AM (#19918679)
> ven assuming that "modern" PHP managed to come up with better ways to deal with all of this, I assume that these obsolete functions and operators still linger for backward compatibility? If so how do you avoid them?

I think the "path of least resistance" is important: developers are time-constrained, understanding-constrained, lazy (if they're virtuous), etc. There's a big incentive to do whatever is easiest/quickest.

When I last used PHP, about 5 years ago, there were OOP APIs cropping up to replace many of the standard global functions; namespaces had just been introduced; closures had become useful; frameworks like Symfony (and Drupal 8) were becoming established, rather than the old "plugin" approach of throwing around arbitrary code and hoping for the best; dependencies were being managed by composer; files could be autoloaded from sensible locations; testing frameworks like PHPUnit and PHPSpec had become best practice; etc.

Yet all of those things were opt-in and verbose. The path of least resistance was still:

    <html>
      <body>
        Hello <?php echo $_GET['name']; ?>
      </body>
    </html>
(For non-PHP programmers, this is appending a GET parameter straight into the page, which is an XSS vulnerability). Doing things "properly" took a great deal of effort and discipline.

Compare this to something like Java: it favours class-based OOP so much that even "hello world" needs a class. The path of least resistance is to do things "right" (from Java's perspective). Haskell's path of least resistance is simultaneously easier ("hello world" is just `main = putStrLn "hello world"`) and harder (`main` uses the `IO` type, whose API enforces certain conventions).

Deprecation warnings, linters, etc. can help with this; but PHP's only real strength is its installed base of code and developers; changing the language too much would throw away this advantage (akin to being a new language, see Python 3 and Perl 6); not changing it enough prevents the more serious and/or systemic issues from being dealt with.

I wish the language designers and users luck, but I'm really hoping to never use it again ;)

Re:PHP in 2019 by twunde on Wednesday May 15, 2019 @10:21AM (#19919632)
The $_GET/$_POST pattern is rare in modern applications (anything built in the last 5 years) and is rightly recognized as an antipattern. Similarly many of the older obsolete functions have been either removed or fallen out of fashion.

You are absolutely right that the path to this has been fixing the path of least resistance. Laravel and other frameworks have made it easy to get variables using their preferred methods (and automatically sanitizing input). Learning resources (tutorials, docs) utilize the OO functions and many of the older functions were deprecated and have been removed for years. If you look at one of the more infamous functions, mysql_real_escape_string (https://www.php.net/manual/en/function.mysql-real-escape-str...) that was removed entirely in PHP 7. If you look at the more modern mysqli, they've chosen to have both escape_string and real_escape string, but one is an alias to the other. Similarly, sane defaults have become the norm, especially since most developers are using containers or VMs/vagrant to program. The one major outstanding issue is the api naming is still inconsistent.

On a sidenote, the PHP docs are great with pages showing examples and notes talking about potential issues. When I switched to python I couldn't believe how bad the docs were in comparison.

Re:PHP in 2019 by rob74 on Wednesday May 15, 2019 @09:37AM (#19919252)
To understand that, you have to take a closer look at its origins. For me, this talk by Rasmus Lerdorf (creator of PHP) was a real eye-opener: https://www.youtube.com/watch?v=SvEGwtgLtjA He mentions that what we now refer to as the "PHP language" was originally intended to be only the templating system, and you were supposed to write your business logic in a "real language" such as C. However, as PHP got more popular, bits and pieces were added until the "templating system" became a full-fledged language. Sounds like this happened more by chance than by design. And because you can't throw all of that out, it shows until today. You can introduce new features, but doing that in a way that stays (more or less) backwards compatible is difficult and forces compromises - see type declarations, which are actually just type hinting and of very limited use. So sure, PHP is wildly popular because of its "first mover" status, so it will probably stay with us for the foreseeable future, and working in it may have become more pleasant over the years thanks to better tooling, but it will unfortunately never be as pleasant as in other, more well-designed languages.
Re:PHP in 2019 by jfengel on Wednesday May 15, 2019 @09:45AM (#19919304)
That's kinda the problem with any domain-specific language: it either requires a full language for support, or it becomes one (and generally not a very good one). Every language is an opinion about what things should be easy and what things are allowed to be hard.

I've got nothing against DSLs and template languages and such, but most of the ones I encounter make me sigh and say, "I know you thought it would be easier but it's just one more thing I have to figure out how to debug, without any of my usual debugging tools."

Re:PHP in 2019 by chriswarbo on Thursday May 16, 2019 @05:34AM (#19927471)
> what we now refer to as the "PHP language" was originally intended to be only the templating system, and you were supposed to write your business logic in a "real language" such as C

I did get a little perverse amusement at writing HTML files containing nothing other than single `<?php` element; where that PHP's job was to generate HTML; and it did so via a templating language (e.g. Twig or Smarty)...

Re:PHP in 2019 by stickfigure on Wednesday May 15, 2019 @09:06AM (#19918982)
You can't remove those old APIs without changing culture, and culture is really hard to change.

One thing that shocked me during my brief foray into PHP was how heavily popular PHP apps like WordPress rely on the filesystem. Want to move a site? Copy the database, and copy a bunch of files. It seems like there's a cultural expectation that applications run on a single server in your closet. Of course you don't have to write code this way... but people still do.

Re:PHP in 2019 by stefanfisk on Wednesday May 15, 2019 @09:51AM (#19919348)
WordPress is NOT an example of modern PHP practices though. The amount of legacy insanity in WordPress is enough to make any sane dev cry...
Re:PHP in 2019 by BlueTemplar on Wednesday May 15, 2019 @10:31AM (#19919748)
Why was it shocking? PHP (originally) stood for "Personal Home Page" after all...
Re:PHP in 2019 by mgkimsal on Wednesday May 15, 2019 @10:07AM (#19919497)
comparing a web page with a potential XSS vs a java 'hello world' (assuming console output) is a bit disingenuous, no?

<?php echo "hello world";

There - no XSS, no HTML, no class requirements.

Re:PHP in 2019 by chriswarbo on Wednesday May 15, 2019 @12:39PM (#19921163)
I think you're confused. The PHP snippet was to demonstrate my point that:

- The path of least resistance in PHP is often directly at odds with the "proper" way of doing things (including many things listed in this article).

- This is important because PHP's intended domain is Web development, so this can easily cause security flaws.

- Any attempt to "fix" this example will inevitably make it longer, more complicated, harder to remember, etc.

Your PHP "hello world" does not demonstrate those problems, since it has no XSS or HTML, so it is a poor example.

After this demonstration, I abstracted to the more general concepts of "path of least resistance" and "'proper' ways to do things", irrespective of language or domain.

To clarify my meaning for these phrases, and to demonstrate how language designers can use the former to push the latter, I gave two examples: Java pushing its preferred approach of class-based OOP, by disallowing raw, top-level statements; and Haskell pushing its preferred approach of monadic I/O, by enforcing the type of `main` and restricting the available APIs. Notice that neither of those examples make the "proper" way easier (that can be very difficult, in general); instead they eliminate anything that's easier (like top-level statements), such that the "proper" way is the easiest thing that's left. In other words, Java's requirement that even "hello world" be wrapped in a class is a good thing for Java programmers, since allowing top-level statements like `System.out.println("hello world");` would undermine the principles of the language. This general argument is not specific to PHP, and certainly not a direct comparison to the XSS snippet.

After defining and demonstrating these general concepts, I then returned to the specific case of PHP, to point out how backwards-compatibility with its legacy of easy, insecure approaches undermines the attempts to improve the situation. In other words, the "proper" way to write PHP (at least, back when I used it) is to use OOP, namespaces, type hints, escaping of user input, etc. Yet the design of the PHP language discourages all of those, by providing easier alternatives which are "improper" (like in my XSS example); and removing those alternatives (in the same way that Java forbids top-level statements) would break almost all existing PHP projects and require the majority of PHP developers to change their habits; and doing so would eliminate PHP's main selling point (installed base and developer mindshare).

I hope that clarifies why the comparison is not disingenuous (i.e. because I'm not making the comparison that you claim).

If I were to make a comparison of that vulnerable PHP code against something else, it would need to be against a language which is primarily designed for Web development (to avoid being disingenuous), and it should be designed to make the "proper" approach the easiest. The Ur/Web language fits these criteria nicely, and (from a quick skim of the tutorial at http://www.expdev.net/urtutorial/step1.html ) the equivalent to that PHP would be:

    fun greet data = return <xml>
      <body>
        Hello {[data.name]}
      </body>
    </xml>
Not only will this will perform the correct escaping, it will also be a type error if another page tries linking to this one without giving a `name` parameter.
Re:PHP in 2019 by pragmaticlurker on Wednesday May 15, 2019 @09:32AM (#19919203)
funny, because it's what React.js allows to do nowadays
Re:PHP in 2019 by icedchai on Wednesday May 15, 2019 @09:57AM (#19919392)
The difference is React actually handles escaping properly. It won't just dump out raw HTML by default, so you won't have an XSS issue.

PHP, on the other hand, requires manual escaping with htmlentities() ... It is very, very error prone.

Re:PHP in 2019 by FranOntanaya on Wednesday May 15, 2019 @11:24AM (#19920329)
You are comparing a framework to a language though. Escaping in PHP is usually handled by the templating component, you don't go around writing htmlentities() everywhere.
Re:PHP in 2019 by icedchai on Wednesday May 15, 2019 @11:44AM (#19920530)
If you're dealing with decade old code that uses no framework, you certainly do. PHP is, by default, a primitive templating language...
Re:PHP in 2019 by chriswarbo on Wednesday May 15, 2019 @12:42PM (#19921183)
PHP comes with a Web framework built in (that's what things like `$_GET`, `$_POST`, `htmlentities`, etc. are). It is also a templating language, that's why we need to write `<?` at the start (to open a PHP tag).
Re:PHP in 2019 by pdimitar on Wednesday May 15, 2019 @07:33AM (#19918356)
Agreed, articles like these do absolutely nothing to address PHP's insane warts, some of which you mentioned.

That's not helpful. Laravel can objectively be the best web app framework in the world and I still won't touch it, because of PHP.

Predictability, minimum WTFs per minute, consistency, sane defaults -- these win over short-term convenience, every time.

Re:PHP in 2019 by brendt_gd on Wednesday May 15, 2019 @08:57AM (#19918908)
For what it's worth, here's the source code of one of my personal side projects, written in PHP and Laravel: https://github.com/brendt/aggregate.stitcher.io
Re:PHP in 2019 by jaabe on Wednesday May 15, 2019 @08:48AM (#19918832)
One of my old friends has been working with php since forever, we’ve teased him over the years.

Since then we’ve moved to a world where every program is web-based. I mean, even huge enterprise systems in healthcare run on some JavaScript MVVM framework and a web-backend in the cloud.

The truth is that php is more adapt at handling this than a lot of the stacks you see in enterprise. It’s really kind of silly, but I don’t think we’ll ever adopt php either exactly for its bad rep. But sometimes I wonder if we shouldn’t.

Re:PHP in 2019 by jbrooksuk on Wednesday May 15, 2019 @07:30AM (#19918336)
> [...] its defenders should focus on actually showing what modern PHP code looks like.

Laravel does this very well, not just by being a great framework but also in its ecosystem (Envoyer, Forge, Spark, Nova, Horizon, Socialite) and its documentation (https://laravel.com/docs/master).

Re:PHP in 2019 by marcosdumay on Wednesday May 15, 2019 @08:47AM (#19918824)
Laravel has a Java-like problem of too many indirections, and has a really complex application model that breaks a lot of things. For that you gain an end of 00's quality templating system and ORM.

I understand that PHP developers love it. It's orders of magnitude better than doing everything by hand. But no, thanks.

Re:PHP in 2019 by isaacremuant on Wednesday May 15, 2019 @10:12AM (#19919541)
Just out of curiosity. What type of comparable work are you doing and what languages/frameworks are you using? How do they compare?
Re:PHP in 2019 by marcosdumay on Wednesday May 15, 2019 @03:58PM (#19923115)
I've created reasonably complex projects on Django (with late 00's capabilities), I've done things in Flask, Asp.Net, Java (with very out of date components), very simple things on Rails, and also used some non-OOP frameworks like snap, I've also used some newer templating systems. I have never created anything in Laravel, but I have done some maintenance.

Compared to Django and Rails, Laravel has those two problems I said. I don't think I ever saw a benefit of Laravel compared to them, except for the easy to deployment of PHP (that is a mixed bag anyway).

The ASP.Net and Java frameworks are so different that any comparison could join Django, Rails, and Laravel as a single point. Everything on those languages is more bureaucratic and stable, easier to compose more complex projects, but harder to create simpler ones.

Compared to snap (I've used very little of Yesod, but looks like it's alike here), the trio Laravel, Django, and Rails compose pages much better (it's a shame really since "compose" and FP go hand to hand, and I expect that to change in the future), but the FP frameworks are much better for creating data services.

Re:PHP in 2019 by lugg on Wednesday May 15, 2019 @08:35AM (#19918758)
If laravel is the best we have were fucked.

Laravel is fine for prototyping but it breaks backwards compat constantly, probably due to the massive amounts of over abstraction, not to mention layer upon layer of IOC hell.

Re:PHP in 2019 by conradfr on Wednesday May 15, 2019 @09:03AM (#19918967)
Symfony is better at handling backward compatibility and managing deprecation.

Still over-engineered I guess but sometimes it means you won't have to go against the framework for some complicated tasks.

Re:PHP in 2019 by dpcx on Wednesday May 15, 2019 @08:49AM (#19918843)
Can you share some of the BC breaking changes you've seen? I personally haven't seen any in quite a while, but I'm not using all parts of the framework.
Re:PHP in 2019 by lugg on Thursday May 16, 2019 @01:47AM (#19926474)
Read the migration notes for the last few releases. Anything that requires you to change your code is a breaking change and the reason you can't skip versions.
Re:PHP in 2019 by alunchbox on Wednesday May 15, 2019 @08:56AM (#19918898)
Can you explain the IOC hell? isn't most IOC / Dependency Injection patterns suppose to help the software maintainability ?
Re:PHP in 2019 by jrumbut on Wednesday May 15, 2019 @10:07AM (#19919504)
I tend to think of these more as enabling modularity and convention-over-configuration (being Rails-y if you will) rather than maintainability.

Prior to Laravel, the PHP way was minimal indirection and simple execution flow. I think it was hard to do something something different with Laravel, and definitely hard to do it in a way that offers performance and security and any other good thing you might want in addition to pretty code.

One disadvantage IOC/DI carry in every language and particularly in PHP is difficulty with debugging. If you have a file of functions and a template that generates HTML you could just read through the code yourself or use prints, now it can be hard to know where to put the print when each page load may involve a couple dozen files.

That, I believe, is IOC hell. My belief is you get through it by learning the framework internals, which is a lot of work (especially if you also have to fit something like Wordpress, Angular, your family, or Photoshop in your mind as well).

Re:PHP in 2019 by lugg on Thursday May 16, 2019 @01:45AM (#19926462)
Yes, they are supposed to.

The problem is that it gets taken to extremes when it's done at the framework level.

The pattern tends to encourage overly decoupled abstractions that are nigh impossible to wrap your head around.

Dependency injection is useful when you need to decouple for testing. Other than that it's rarely useful.

If your trying to decouple everything because "coupling is bad mmkay" your just cargo culting.

IOC is just anti OO. And I'm anti OO. But when you use IOC for every class yove got a huge fucking problem.

The only time I've seen IOC work well is across module boundaries in a system where modules were boundaries that could not be crossed without the IOC.

Within modules usual namespacing and new constructors were used liberally.

Re:PHP in 2019 by brendt_gd on Wednesday May 15, 2019 @08:55AM (#19918896)
> its defenders should focus on actually showing what modern PHP code looks like

This is one of my personal side projects, written in PHP and Laravel: https://github.com/brendt/aggregate.stitcher.io

Here's a list of all OSS package we maintain at work: https://github.com/spatie

Re:PHP in 2019 by duiker101 on Wednesday May 15, 2019 @09:09AM (#19918999)
some very interesting stuff in there! Thanks for sharing!
Re:PHP in 2019 by brlewis on Wednesday May 15, 2019 @08:10AM (#19918590)
>I assume that these obsolete functions and operators still linger for backward compatibility? If so how do you avoid them?

This. If there isn't a linter that bombs out on those things that used to be standard PHP, modern PHP is a non-starter. There are too many bad examples out there that will make their way into modern code if you let them.

Re:PHP in 2019 by francislavoie on Wednesday May 15, 2019 @02:31PM (#19922311)
https://www.exakat.io/

https://github.com/phpstan/phpstan

https://github.com/phan/phan

Lots of great static analyzers to run in CI and during development to catch all kinds of issues.

Also, https://github.com/FriendsOfPhp/PHP-CS-Fixer to clean up code syntax (configurable rules, has good presets).

Re:PHP in 2019 by zaphar on Wednesday May 15, 2019 @07:47AM (#19918444)
Yeah, I've been burned too badly by PHP. There are languages I haven't done in years that I would go back to if there was a compelling need to.

PHP is not that language. Far to many sleepless late nights trying to clean up some security hole. PHP is like that abusive Ex that everyone says has changed. It may be true, in which case, good for PHP

But I won't be putting myself in that position again.

Re:PHP in 2019 by proyb on Wednesday May 15, 2019 @08:48AM (#19918835)
I've been burned by some language that create a poor developer experience with long compilation time and garbage collection.

Maybe V language (vlang.io) could pique your curiosity.

Re:PHP in 2019 by GrumpyNl on Wednesday May 15, 2019 @07:55AM (#19918500)
You can be burned by every program language if you dont know the in and outs. It all boils down to, pick the right language for the job and more important, know the language you choose.
Re:PHP in 2019 by cljs-js-eval on Wednesday May 15, 2019 @08:35AM (#19918750)
Seems like to know PHP, though, you need to know all the history that the author has picked up by following the PHP space since forever. Which mysql functions are appropriate, etc. If knowing the language means "being a working programmer in 2010 so that you could gain a working knowledge of the old APIs and some context for the new ones" I'm out. Keep PHP, I'll move to a different language where knowing historical baggage isn't a prerequisite.
Re:PHP in 2019 by mateuszf on Wednesday May 15, 2019 @08:35AM (#19918756)
There are languages which have great design from the start though (like Clojure).

PHP, javascript are not them.

Probably that's the reason why Clojure tends to be in top of the "developer happiness" polls.

Re:PHP in 2019 by cutler on Saturday May 18, 2019 @06:05AM (#19946612)
.... and the bottom of "jobs available".
Re:PHP in 2019 by sethammons on Wednesday May 15, 2019 @08:38AM (#19918767)
Languages have foot guns. Most however don't default to being loaded and already pointed at your foot.
Re:PHP in 2019 by zaphar on Wednesday May 15, 2019 @10:49AM (#19919916)
I did know PHP. I was actually pretty good at and wrote non-trival software in it. Even then the relationship was pretty abusive. Even when I was writing bug free code the author of a library I was using wasn't or a co-worker wasn't.

It may in fact be that PHP has improved to the point that the relationship isn't abusive anymore. But I'll never go back to find out. PHP and me were done years ago.

Re:PHP in 2019 by capitol_ on Wednesday May 15, 2019 @11:34AM (#19920434)
Saying that all programming languages are equally good is about as true as saying that all sorting algorithms are equally fast.
Re:PHP in 2019 by GrumpyNl on Wednesday May 15, 2019 @02:58PM (#19922565)
That i didnt say.
Re:PHP in 2019 by k_bx on Wednesday May 15, 2019 @08:42AM (#19918793)
> Server are cheaper and vastly more powerful now than in PHP's infancy

Slightly off-topic, but I think that nowdays it's actually less of an argument than when PHP started becoming popular. The thing is, back in the days, statically typed languages were just bad and unproductive. Today, they are way better, and the fact that I can run my service on $3/month server with 900M of RAM and not think about the price tag at all is actually quite a decent argument to stay away from dynamic languages (but not the main one, tbh).

Re:PHP in 2019 by mywittyname on Wednesday May 15, 2019 @09:25AM (#19919134)
With more companies moving to virtualized hosts, I bet performance becomes a real consideration. With most services I've seen, you buy server capacity in doubling increments. So either your application fits into 2 vcores @ 2.2GB with 8GB or RAM, or you step up to 4 vcores and 16GB, with costs also doubling.
Re:PHP in 2019 by k_bx on Wednesday May 15, 2019 @09:30AM (#19919190)
Good point! Let's not forget that, unlike the old days, it's kind of a standard to require redundancy and load-balancing from day 1, so not fitting machine's RAM hurts even more.
Re:PHP in 2019 by onlyrealcuzzo on Wednesday May 15, 2019 @10:43AM (#19919858)
It's gotta be the easiest stateless system to get started with, right? It's decidedly not a BAD language anymore. It probably has some of the best tooling for said system as well. And it has a GIGANTIC community.

That's worth a lot to most people, I think?

Re:PHP in 2019 by dangerface on Wednesday May 15, 2019 @09:23AM (#19919119)
Your comment reads as "I like ruby therefor php is dumb"

> Is performance that much of a big deal for most people? Yes obviously. Performance is important no matter the language.

> the counter-intuitive behaviour of '==' You should learn the languages type system instead of assuming it works how you think. Again this is true of every language.

> I assume that these obsolete functions and operators still linger for backward compatibility? If so how do you avoid them? The built in linter gives you a warning that its obsolete.

The inconsistent naming and arguments. Dumb defaults and thousands of functions in a global namespace is the real problem and there is no solution to it. Oh and calling functions is unacceptably slow, that they can and need to fix the rest of this is just I like my language better.

Re:PHP in 2019 by simias on Wednesday May 15, 2019 @10:01AM (#19919437)
I haven't used Ruby in about a decade and I was never a fan. I used it as an example of a technology that managed to become popular despite abysmal performance. I think that's proof that in many situations, especially for web development, performance is a very secondary concern.

> You should learn the languages type system instead of assuming it works how you think. Again this is true of every language.

A good language should have good ergonomics. Criticism that `123 == "123foo"` is not reasonable cannot be brushed away by claiming that users should RTFM (although arguably in this case it's less an issue with == than "123foo" being implicitly cast into an integer).

Maybe this has been fixed and is no longer relevant though (I'm citing the Fractal of Bad Design page).

Re:PHP in 2019 by baybal2 on Wednesday May 15, 2019 @07:48AM (#19918448)
What ended PHP were not the worst parts of its design, but upstream's unwillingness to simply change the language for better.

See, as a commercial enterprise (begware as a business) all kinds of "foundations" and sponsorship pools surrounding the language already accumulated a big enough pool of clients who were happy enough with PHP as it was in 4.0 era. They had no intensive to progress. Especially if their business depended on "fixing brokenness"

Open source and sponsorship does not always mix well. Just as with front-end frameworks/libraries that live off sponsorships, eventually it leads to people prioritising pleasing sponsors, and working on pushing their software over improving the software itself.

The current allergy in JS world about genuinely required breaking changes is all about that as well. Any times a talk of genuine "JS 2.0" starts to entertain minds of powerful players in the JS world, there will be tons of people with commercial interest coming and extinguishing the conversation with "no, we absolutely can not ever break anything, ever, even if it is already broken"

Breaking changes in JS world do occur, but most of them being near accidental, security related, or being done as part of actual sabotage like intentional breaking of synchronous AJAX requests after they were shipped.

My logic is, if breaking changes are still unavoidable in JS, why not to do them in a controlled manner, rather than through sneaky sabotage ops like one above?

Re:PHP in 2019 by qaq on Wednesday May 15, 2019 @08:11AM (#19918598)
I think ended is pretty strong word for a language that powers a huge portion of the web. Yes the lang. has issues and yet WordPress, Magento etc. are used an order of magnitude more than alternatives written in other languages.
Re:PHP in 2019 by proyb on Wednesday May 15, 2019 @09:01AM (#19918943)
Behind the language, the early day of shared web hosting make it affordable.
Re:PHP in 2019 by wvenable on Wednesday May 15, 2019 @10:00AM (#19919427)
> but upstream's unwillingness to simply change the language for better.

Wow that could not be more wrong. PHP definitely changes things to make the language better, especially breaking changes. PHP5 changed objects from value types to reference types -- you don't get a bigger change than that.

But they don't just change things willy-nilly -- they do try to maintain backwards compatibility as much as is reasonable otherwise it wouldn't still be PHP.

Re:PHP in 2019 by return1 on Wednesday May 15, 2019 @07:38AM (#19918383)
> Is performance that much of a big deal for most people?

For most people outside VC-funded startups, yes it is. It is also an environmental concern, imagine if 80% of the web was running on ruby.

Re:PHP in 2019 by cntainer on Wednesday May 15, 2019 @08:23AM (#19918676)
Well if 80% of the web was running on ruby there wouldn't be any difference.

Most people don't understand that 99% of performance issues are not caused by language performance but by bad architecture and bad developers.

Always choose the best tool for the job, you rarely get to that scale and quality of software design that only the raw language performance is left to be optimized :)

Re:PHP in 2019 by smolder on Wednesday May 15, 2019 @09:35AM (#19919232)
There absolutely would be a difference. IME, people take this "performance is not a major concern when choosing a stack" thing a little too far and apply it too broadly, often without ever having benchmarked anything. When I can handle 300+ requests per second in one implementation and only 50 in another on the same hardware, that's going to be a big difference in costs that matters for everyone except fledgling businesses. I've seen 5-10x differences in performance between languages with none of it being attributable to anything the programmer did being suboptimal --just the language/standard libraries/runtime.
Re:PHP in 2019 by cntainer on Wednesday May 15, 2019 @10:02AM (#19919455)
I agree with your costs argument, but my point is you can rarely blame the language. If we bring the frameworks in the discussion it gets even more complicated.

If you build a Rails or Laravel app in the same way you would build a Java app, the Rails/Laravel app will be dead slow. And I've seen that happen. But if you know what you're doing you with Rails/Laravel it will be a long time before you say: we should rewrite this in Go/Rust/Erlang.

The main criteria for me when choosing a tool for the job is: how well does the team know the tool? can they use it at full potential?

I've been involved in java project with 20k monthly cloud costs. Most of the workload is handled in the background by consumers that pull messages from RabbitMQ. I'm pretty sure I could rebuild that with any language while actually reducing the costs because the bottleneck is not the code but the architecture. Would it matter if I would rewrite it in Java instead pf Python or Ruby, in terms of performance, yes, if we need to consider other things, like speed of development, etc it gets complicated again. :)

Re:PHP in 2019 by cutler on Saturday May 18, 2019 @06:15AM (#19946642)
5x-10x differences only exist between statically compiled and dynamically compiled languages. The differences in performance between dynamic languages is marginal. As for Ruby it's now slightly faster than Python for most things except C-based numerics.
Re:PHP in 2019 by smolder on Wednesday May 29, 2019 @09:25AM (#20039847)
When you start mixing in things like random number generators, different methods of string manipulation, different data structures and so on, there can be pretty dramatic differences in performance within each category. (static or dynamic) Every language has building blocks that come with it that are far from equal.
Re:PHP in 2019 by return1 on Wednesday May 15, 2019 @08:32AM (#19918734)
Tbh most of it is wordpress, and that is not terribly inefficient.
Re:PHP in 2019 by cntainer on Wednesday May 15, 2019 @09:09AM (#19919000)
I haven't touched wordpress in 8 years, but with old codebases you always inherit a lot of bad design decisions that always have an impact on general performance.

Maybe the wordpress guys have done a great job in rewriting the internals and cleaning things up in the last years, I wouldn't know, I don't follow their progress.

Re:PHP in 2019 by justaaron on Wednesday May 15, 2019 @07:49AM (#19918457)
Re:PHP in 2019 by bin0 on Wednesday May 15, 2019 @08:57AM (#19918916)
Your parent comment has a point about performance; I don't see why he is downvoted. Crystal is cool, but it is still immature in terms of ecosystem, the language could change, limited library support, and most importantly, not many great engineers. Particularly not outside of the valley.

Performance is a concern for many people, and this is somewhat overlooked because of the number of people here who work for companies where scaling is the primary concern. I think this is what he meant by people outside of VC-backed startups. I know of multiple companies that have had outrageous cloud-hosting bills and have had to hire fancy consultants to fix it.

Re:PHP in 2019 by justaaron on Wednesday May 15, 2019 @10:20AM (#19919616)
I simply meant that Crystal lang features ultra high performance, and yet shares much of Rubys syntactical elegance. Much is built into the standard library and I have to ask what your experience with Crystal has been like so far? I find pretty much everything I need, and the easy FFI with C takes care of most of the rest (see the Mongo.cr wrapper for the C mongo driver, for example...)
Re:PHP in 2019 by bin0 on Wednesday May 15, 2019 @05:13PM (#19923822)
I agree with that assessment. My experience has been reading a good bit into it. I considered learning it a few months ago, but wanted to focus on things that people were currently hiring for. Maybe at some point I will learn more, but I am a bit too broke right now to spend that much time on something that doesn't pay. I don't say that to be disparaging, it goes back to my point about it being immature and not having many engineers or companies using it.
Re:PHP in 2019 by justaaron on Wednesday May 15, 2019 @07:50AM (#19918463)
despite it's pre 1.0 status it's arguably more production ready than php ever was/will-be etc.
Re:PHP in 2019 by qaq on Wednesday May 15, 2019 @08:13AM (#19918611)
I bet you rely on things written in PHP way more than you realize.
Re:PHP in 2019 by golfer on Wednesday May 15, 2019 @09:13AM (#19919028)
Exactly. See: Wikipedia, Facebook, WordPress, etc. People talk crap about PHP but it is a workhorse of the web.
Re:PHP in 2019 by justaaron on Wednesday May 15, 2019 @10:25AM (#19919678)
indeed. this is largely legacy, but good luck changing that. I can't say that i miss it much, but then I don't work for either of these 2 entities. I'm familiar with what you are speaking about, so I don't think the lack of respect stems from a general ignorance of what you are referring to. It's rather people who have interacted with PHP in the past and didn't enjoy the experience.
Re:PHP in 2019 by golfer on Wednesday May 15, 2019 @01:21PM (#19921645)
That's a fair point.
Re:PHP in 2019 by justaaron on Wednesday May 15, 2019 @10:23AM (#19919648)
I'm familiar with the usage stats on wordpress, lol. I can't say that this is a good thing, but if it suits your needs, have at it.

I see no reason to start any greenfield project in 2019 in PHP unless you literally only know or ever want to learn PHP. I could be wrong in terms of the entire language and it's ecosystem could have changed in the 18-20 years since I deliberated interacted with it last... We have a lot of things since mod php, so there's many other options, most of which don't involve PHP, so I suppose true fans will build their web apps in forth, I dunno...

Re:PHP in 2019 by toredash on Thursday May 16, 2019 @11:47AM (#19930053)
My main beef with PHP is performance at scale. Doing 100.000+ req/s, the memory footprint for PHP is ... annoying.