can someone convince me why #php is good actually
@taco Are you actually asking or just trolling?
@Crell a little bit of both, but mostly genuine. i keep seeing frameworks like laravel pop up in web development and we use it at work in some of our microservices so i'm interested in knowing why it's attractive as a language/how performant it is compared to something like rails
@taco In it's niche (server side web), PHP has an incredibly robust ecosystem, the strongest type system of any interpreted language, the best or second best package manager (competing with Cargo), and is either the fastest or second fastest interpreted language depending on what you're testing. (JS is the competition there.) It scales horizontally better than any other architecture. And its "it just works" factor is second only to Go. It's also very easy to learn.
@Crell appreciate the explanation! definitely make sense why i see it so much, then.
@taco There is a ton of outdated information about PHP out there. Many of the criticisms of PHP were fixed a decade or two ago, but haters love to hate on PHP for funsies.
Modern PHP is overall a very pleasant language to live in, especially if you're using a good framework. (Obviously bad code is bad in any language, and plentiful.)
@Crell @taco For what it’s worth, Etsy’s backend still runs on PHP, and we’re fairly up to date. It’s not as bad as a lot of people seem to say it is.
My personal biggest gripe is the lack of a language syntax for expressing/enforcing async behavior. Something can become “blocking” (network, database, whatever) unpredictably and cause significant performance problems.
JS has promises, async/await, etc, where you can explicitly encode/enforce/understand that.
@sangster @Crell @taco I'm not completely sure if I understood you but as far as I know even this is in the past now with fibers. https://www.php.net/manual/en/language.fibers.php
@doomhammerchen @Crell @taco well, it’s better than nothing, but I’m honestly not sure how I would go about actually using that in our codebase. I guess I’ll ask some smarter PHP people than myself. It still seems like the do/while waits for the fiber to resolve would be necessary and still lead to surprise “blocking” steps without rewriting our whole stack on top of fibers.
@sangster @Crell @taco I share your opinion. Using fibers directly is a little bit messy. I for my part always used the libraries amPHP (https://amphp.org/) or reactPHP (https://reactphp.org/). The later gives you a very JavaScript-like experience. In any case: no surprise blocking
@doomhammerchen @Crell @taco oh nice! Our architecture is way too bespoke for introducing something like that, but I’ll go read up for my own edification :)
@sangster @doomhammerchen @taco Fibers were never intended for normal people to use directly. They were added for the express purpose of enabling Revolt to exist. What normal people should be using is Amp, by design.
@Crell @doomhammerchen @taco ah, good to know. Well, I’ll bug Rasmus about it when I’m back from vacation and see if he’s been thinking about how to integrate it into our systems.
@taco The downside is that because it's so easy for new devs to use, there's millions of lines of... Really bad PHP out there, often in mission critical systems. The 2 biggest app/frameworks, WordPress and Laravel, are canonical examples of what not to do. (There are better options.)
Lots of 3rd party tutorials are very out of date and bad. If you stick to the official/main channels you should be fine.
Were it up to me, the only server side langs I'd consider are PHP, Go, and Rust.
@Crell I’d argue that Wordpress and Laravel, both being wildly successful and both being, let’s be honest, significant reasons for PHPs continued popularity, are hardly canonical examples of what not to do. I’d argue they’re canonical examples of what PHP is best in class at - providing a fast way to answer a web-based need and just as importantly, convert that time savings into money.
@Crell @taco @danrot #Haskell has always been interpreted. (Before 1984 or so people didn't think it was even possible to compile a lazy language, until the LazyML compiler was published.) Hugs is a pure interpreter for Haskell (sadly no longer maintained), but even GHC comes with an interpreter for ad-hoc scripting (ghci, runghc, and ghc -e ...
).
@matzipan @Crell @taco but the startup time of PHP is more than enviable. I'm currently using it under k8s and I can scale up to dozens of pods in a matter of seconds (using a not-lightweight framework like Symfony), while other projects take minutes to go up (I oversee a Nest.JS one, for example, which takes at least 120s to boot).
@alessandrolai @Crell @taco could be. But hard to draw any equivalence without knowing what each does.
@matzipan @Crell @taco in my example, both are queue consumers, but I've seen the same when providing HTTP APIs, you just have to add 5-8 seconds to both for healtchecks to pass. I also heard of pretty worse situations like Java, where you need upwards of 5 minutes to launch a pod, which requires 5-10 times the amount of memory for a single replica...