News for hackers. Stuff that matters.
Re:I still love PHP and JavaScript by tiffanyh on Tuesday August 02, 2022 @07:22PM (#32325590)
PHP has so many hidden benefits:

- it's stateless by design (much easier to scale)

- it was "serverless" before Serverless

- surprisingly performant

- no "unknown unknowns". it's so tried-and-true, there's no surprises

- deployment is so simple, just drop a file on a web server. No middleware needed.

- No long compile times because there is no compiling needed.

EDIT: why the downvotes? If you don't agree, just reply so we can have a healthy dialogue.

EDIT2: I also think there is something unique about PHP documentation. It has plenty of real life examples, and the ability for users to leave comments allows you to hear directly from others "gotchas" that people have experienced. I feel like PHP documentation is very undervalued.

Re:I still love PHP and JavaScript by paxys on Tuesday August 02, 2022 @07:58PM (#32325905)
> - no "unknown unknowns". it's so tried-and-true, there's no surprises

This part is laughable. People who have been programming PHP for 20 years (several of them at my company) still routinely discover hidden bugs, quirks or general behavior that is totally unintuitive and nowhere found in the documentation.

Re:I still love PHP and JavaScript by user3939382 on Tuesday August 02, 2022 @08:49PM (#32326322)
I’ve been using PHP since 2003 and it’s my full time job and this doesn’t ring true. Very, very rarely is a gotcha not in the docs comment section.
Re:I still love PHP and JavaScript by jasonm23 on Wednesday August 03, 2022 @05:07AM (#32329360)
> in the docs comment section.

A classic boiled frog statement.

__It's not undocumented, someone posted a comment about that bug...__

I will quietly place my face in my hands and weep to the memory of php coding I did 20 years ago.

Seems the same nonsensical masochism is still going strong.

Re:I still love PHP and JavaScript by saurik on Wednesday August 03, 2022 @05:31AM (#32329502)
I mean, I am by no means an expert in PHP, and in fact most of my knowledge of it comes from hating on it (or having been thrust into the unfortunate position of being the system administrator for a popular MediaWiki instance), but even in my limited experience with it from a couple lifetimes ago I know that most of the documentation for PHP is crowdsourced in the documentation comments section. That might be depressing, but that isn't what that comment was defending: it does feel likely to be true that there aren't many "unknown unknowns" waiting for you in PHP.
Re:I still love PHP and JavaScript by troyvit on Wednesday August 03, 2022 @09:56AM (#32331702)
To me the comments section is one thing that sets PHP apart from other languages. Need to learn a new function? Go read about it on php.net, then skim the comments for edge cases.

Need to do something new in Node? Sift through a bunch of search engine spam, read a few dissenting answers on stackoverflow that refer to a previous version, eventually find a library that does what you want, written by skullM4ster2004, plug one's nose and install it.

Re:I still love PHP and JavaScript by ehnto on Wednesday August 03, 2022 @09:43AM (#32331560)
This is a very common trope, someone who hasn't touched PHP in decades who still thinks they know anything about the language and ecosystem now.
Re:I still love PHP and JavaScript by sergiosgc on Wednesday August 03, 2022 @06:37AM (#32329916)
> I will quietly place my face in my hands and weep to the memory of php coding I did 20 years ago.

You should revisit the language. PHP7 was a huge leap forward. It's a different language now.

Re:I still love PHP and JavaScript by bearmode on Thursday August 04, 2022 @04:45AM (#32340650)
PHP has changed a lot. You should give it a try and stop thinking of it as the same language with the same flaws it had two decades ago.
Re:I still love PHP and JavaScript by daef on Wednesday August 03, 2022 @05:33AM (#32329519)
When I had to code in php I've written a css-rule for my browser to hide the user contributions to the docs, since they where often misleading if not plainly wrong.

I remember no discernible border between 'official docs stop here' and 'user contributed opinions start here'.

Re:I still love PHP and JavaScript by momentary on Wednesday August 03, 2022 @09:21AM (#32331339)
I can't attest to how it used to be, but now at least they are in a section labeled "User Contributed Notes". The notes can be voted up or down, so hopefully the dross sinks to the bottom.

I do agree with the sentiment though that these unofficial notes should be taken with a grain of salt. In my experience, they have been more help than hindrance.

Re:I still love PHP and JavaScript by artificialLimbs on Wednesday August 03, 2022 @09:20AM (#32331335)
Maybe that's how it was, but it has a clearly defined header that says "User Contributed Notes" now, with up/down vote counts on each comment.
Re:I still love PHP and JavaScript by __del__ on Tuesday August 02, 2022 @09:29PM (#32326588)
i always found those comment sections to be so odd — fifteen year old comments about a common pitfall and the information never makes it up to the official documentation?

i suppose it's fitting for a web-centric language to crowd source its docs on a website, but does any other mainstream language do this?

Re:I still love PHP and JavaScript by oneeyedpigeon on Wednesday August 03, 2022 @04:31AM (#32329098)
Meanwhile, I find the PHP docs far more readable/accessible than almost any other language. Compared with the official Python or (shudder) Java docs, and they're far superior, IMO.
Re:I still love PHP and JavaScript by saurik on Wednesday August 03, 2022 @05:38AM (#32329554)
If it makes you feel any better, at least the comments are next to the documentation? Really big projects that people rely on every day -- things like Rust's Cargo or Google's Flutter -- are riddled with bugs and limitations, requiring frustrating boilerplate workarounds to make basic things work correctly, and they generally only have mention of the problems in the comments on the billion 5-10 year old open issues in their task tracker.
Re:I still love PHP and JavaScript by cnity on Wednesday August 03, 2022 @04:56AM (#32329283)
Clojure crowdsources "examples" (to good effect, IMO). For example: https://clojuredocs.org/clojure.core/assoc-in
Re:I still love PHP and JavaScript by mxschumacher on Wednesday August 03, 2022 @02:03AM (#32328154)
The php docs are themselves a public GitHub repo, so it's a bit sad if insightful comments don't affect change in the docs
Re:I still love PHP and JavaScript by CSSer on Tuesday August 02, 2022 @11:38PM (#32327389)
That’s just it. I have to code with the PHP docs open like some kind of arcane recipe book.
Re:I still love PHP and JavaScript by user3939382 on Wednesday August 03, 2022 @03:16AM (#32328604)
Maybe it’s the frequency that you use the language? I go maybe 5-10k loc between needing to lookup anything in the docs at all, and 5-10x that where the issue I need guidance on isn’t in the formal doc.

Much more frequently I’m looking up something related to the tools and libraries I’m using.

The only surprising thing I’ve learned about PHP at the language level in the last 6-10 months is that you can call array_filter() without a callback to cull nulls.

Re:I still love PHP and JavaScript by CSSer on Wednesday August 03, 2022 @10:47AM (#32332488)
It could be, but I also never felt like I really got to the point you're talking about in 2 years or so of moderate usage. I've been productive in it, and it's not like I'm hung up on control flow or something. I don't hate the language either. I still have to use it from time to time, but it just doesn't seem like it makes sense for a lot of green field work due to this.

It's mostly things like parameter order for certain built-ins that aren't intuitive and/or finding built-ins I've never used or heard of because there are so many obscure ones (there are nearly six thousand) that keep me coming back. For example, how do you disable errors in a DOMDocument? It ought to be as easy as DOMDocument->setAttribute("errors", "false"), but no it's a separate function call to libxml_use_internal_errors(true). There are like five other similar function calls for this too. PHP has abstraction leaks and little inconsistencies like this everywhere.

Granted, languages with small standard libraries, like JavaScript, by contrast get an easy cop out to blame the community of various package maintainers here. But at least in that case someone can always just write a better library.

Re:I still love PHP and JavaScript by sjamaan on Wednesday August 03, 2022 @04:55AM (#32329276)
Does that only cull nulls, or also zeroes, falses and empty strings?
Re:I still love PHP and JavaScript by sergiosgc on Wednesday August 03, 2022 @06:39AM (#32329924)
Anything "falsy" -- any item that, when cast to boolean results in false. So, also zeroes, falses and empty strings.
Re:I still love PHP and JavaScript by sjamaan on Thursday August 04, 2022 @07:31AM (#32341574)
That was my point - OP said it "culls nulls", and the pitfall is that kind of thinking - if you think of it as removing nulls and you're not mindful, you might be deleting things from the list you don't want to be deleting.
Re:I still love PHP and JavaScript by ehnto on Wednesday August 03, 2022 @09:48AM (#32331625)
Do you really though, or are you being a bit hyperbolic? It's really not that complicated or arbitrary. If you find yourself hitting idiosyncrasies so often you've got the docs open you might just be doing it wrong. There's also some learning to do for any language, no language is so intuitive that you know it without any effort or learning.

All the above said, do enough real work in any language and you'll find cases where the idioms of the language don't map to your work.

Re:I still love PHP and JavaScript by CSSer on Wednesday August 03, 2022 @01:50PM (#32334843)
PHP isn’t consistent with itself and has abstraction leaks for things that it shouldn’t. PHP does not bring me joy.

Of course I’m speaking succintly above. It’s not that bad, but it’s not that much better either. I’m not going to stockholm myself into using a language just because it’s “mature” if I don’t have to. I may have that relationship with JavaScript but at least in that case resistance is somewhat futile and there are practical benefits to be had.

Re:I still love PHP and JavaScript by lucideer on Wednesday August 03, 2022 @08:55AM (#32331055)
I don't know any language that this statement isn't true about unless either:

(a) you're a true, deep expert who uses the language all day every day

(b) the docs are so poor it's not even worth having them open

Re:I still love PHP and JavaScript by CSSer on Wednesday August 03, 2022 @01:41PM (#32334724)
Go might be a contender save for a couple weird features. JS might be with a few ground rules and/or enough tooling.

I’m also willing to grant implicitly that there are tradeoffs here. Languages with small standard libraries usually have big community libraries and vice/versa.

Re:I still love PHP and JavaScript by lucideer on Wednesday August 03, 2022 @03:58PM (#32336087)
JS isn't directly comparable due to the very delineated nature of ECMA -vs- DOM/NodeJS APIs - ECMA is pretty easy to internalise but you'd be hard pressed to get by without MDN DOM or NodeJS core API docs open (unless as you say you're abstracting them with community libs as you say).

I've only used Go sparingly - I heavily relied on docs, but yeah it may have a shallow learning curve. It's certainly much saner than Python (which seems to be the other language used in my "space" for e.g. ad hoc ops tooling, etc.)

Re:I still love PHP and JavaScript by dncornholio on Wednesday August 03, 2022 @05:32AM (#32329516)
Get a better IDE. Visiting docs for checking return values should be a thing in the past.
Re:I still love PHP and JavaScript by larve on Wednesday August 03, 2022 @09:54AM (#32331677)
My approach (very similar than when I write C or raw JS) is to use a few "cleanup" APIs or libs that hide the nasty stuff (string handling / array iteration / SQL building), because I know I don't want to deal with all the footguns. There were rarely is a performance argument that would need me to do otherwise.
Re:I still love PHP and JavaScript by bearmode on Thursday August 04, 2022 @04:46AM (#32340663)
I use PHP daily at work, haven't had to check the docs for quite a while
Re:I still love PHP and JavaScript by pkrumins on Tuesday August 02, 2022 @08:51PM (#32326341)
Exactly. You get it 100%. Come work for me!
Re:I still love PHP and JavaScript by gregvab on Wednesday August 03, 2022 @12:29AM (#32327668)
just gonna leave this comment here to reply to the person whose blog I've followed years before Browserling was created.
Re:I still love PHP and JavaScript by pkrumins on Wednesday August 03, 2022 @12:41AM (#32327728)
Why, thank you!
Re:I still love PHP and JavaScript by merek on Tuesday August 02, 2022 @08:39PM (#32326252)
In general, how could one know that something has no unknown unknowns? By definition, one wouldn't know.
Re:I still love PHP and JavaScript by miffy900 on Tuesday August 02, 2022 @08:47PM (#32326310)
That's what makes the statement "no 'unknown unknowns'" a bit ridiculous though. How can you possibly assert that there are absolutely NO 'unknown unknowns'? You can never rule them out, and at best can only suspect there's a possibility either way, that they do or do not exist. You can never actually know with certainty.
Re:I still love PHP and JavaScript by sergiosgc on Wednesday August 03, 2022 @06:40AM (#32329939)
You can have a statistic approach, and that's what the OP is referring to. If you find out about an unknown unknown frequently, they are out there. If you go years without hitting one, they are (probably) absent.
Re:I still love PHP and JavaScript by e-clinton on Tuesday August 02, 2022 @09:26PM (#32326567)
Schrödinger’s Cat?
Re:I still love PHP and JavaScript by HPsquared on Wednesday August 03, 2022 @08:54AM (#32331051)
I suppose the programming equivalent is something that randomly results in a line being printed to the console.
Re:I still love PHP and JavaScript by jasonm23 on Wednesday August 03, 2022 @05:10AM (#32329383)
Schrödinger's PHP.
Re:I still love PHP and JavaScript by ainiriand on Wednesday August 03, 2022 @02:59AM (#32328502)
Being a PHP programmer for 14 years never found an example of that.
Re:I still love PHP and JavaScript by mekster on Tuesday August 02, 2022 @10:28PM (#32326945)
Any examples?
Re:I still love PHP and JavaScript by jrm4 on Tuesday August 02, 2022 @08:59PM (#32326392)
But genuine question -- what other languages are as simultaneously as useful AND predictable?
Re:I still love PHP and JavaScript by Hasu on Wednesday August 03, 2022 @01:53AM (#32328109)
Ruby, Python, C#, Java, and JavaScript are all are more predictable and just as useful. Go, Elixir, Clojure, and probably others are more predictable while being less "useful" only in the sense that they may have less convenient deployments or less mature web libraries.
Re:I still love PHP and JavaScript by tisc on Wednesday August 03, 2022 @04:07AM (#32328930)
I've used Python, C#, Java, JavaScript and PHP, and in my experience Python is the most unpredictable of these languages. Just to name a few: - mutable default arguments - late binding closures - typings that are purely documentation instead of being enforced

Labeling these things as "gotchas" doesn't make them predictable imo.

Re:I still love PHP and JavaScript by zelphirkalt on Wednesday August 03, 2022 @05:42AM (#32329581)
Python less predictable than PHP? In what world? In PHP standard library functions silently take a null instead of a string, even though they are string handling functions, hiding that mistake for the user of the language, until a later point in time, when the context has been lost and one needs to do silly debugging, until one finds the place where the null first was handled, while it should have raised an error. Such is the silly character of PHP standard library. Many functions also have multiple return types, which makes it difficult to simply use the result of one as input to another.

If predictability means to predict, that standard library will behave nonsensically, then yes, PHP has the one high predictability.

Re:I still love PHP and JavaScript by samuellevy on Wednesday August 03, 2022 @08:43AM (#32330931)
> silently take a null instead of a string

Oh, so you _haven't_ used any of the recent versions of PHP, then. You're just talking shit with no actual recent experience. Gotcha. Well, thanks for your input.

Re:I still love PHP and JavaScript by zelphirkalt on Wednesday August 03, 2022 @01:58PM (#32334932)
Look what I got here for you:

    docker run -it php:8.0 bash
    # php -a
    Interactive shell

    substr("abcdef", 3);
    // no result
-- Ah right, PHP does things differently than other almost every other language that has a REPL and I have to echo a value, which was just returned, even on the REPL ...

    php > echo substr("", 3);
-- Silently hiding the error. Idiocy.

    php > echo substr(null, 3);
-- Silently hiding the error. Idiocy.

    php > echo substr("abcdef", 3);
    def
Who is shit talking now? Are you suggesting, that all this is normal and OK? Nothing is fixed. It's still badly designed and probably will remain shitty like that, until PHP programmers finally realize, that this needs to be properly fixed.

EDIT: Of course the docs also do not mention this to happen at all and tell you, that the first argument must be a string. So I guess that means, that in PHP terms, null is a string. Great for type safety!

Re:I still love PHP and JavaScript by tored on Wednesday August 03, 2022 @09:52AM (#32331651)
Re:I still love PHP and JavaScript by mxschumacher on Wednesday August 03, 2022 @02:06AM (#32328167)
Go is more difficult to deploy than php? php.ini files and php extension installations to get to production is what I remember
Re:I still love PHP and JavaScript by Hasu on Wednesday August 03, 2022 @08:52AM (#32331019)
No, I was thinking 'less mature web libraries' for Go. It's hard to talk about groups of languages in broad strokes when there are various tradeoffs and each language has its own strengths and weaknesses, and I painted two possible weaknesses broadly across several languages that don't strictly apply to all of them.
Re:I still love PHP and JavaScript by n3storm on Wednesday August 03, 2022 @05:02AM (#32329328)
I am starting to find PHP bearable as soon as they are starting to follow Python language and precepts (like libs for humans, code readability instead of shorthands,...)
Re:I still love PHP and JavaScript by lmm on Tuesday August 02, 2022 @11:03PM (#32327164)
Python covers many of the same use cases and is much more consistent/predictable. TCL if you want to go back a bit further.
Re:I still love PHP and JavaScript by oneeyedpigeon on Wednesday August 03, 2022 @04:33AM (#32329111)
I've never experienced the same kind of out-of-the-box problems with PHP as I have Python. I seem to suffer constantly from python/python3, pip inconsistencies and stuff just breaking constantly.
Re:I still love PHP and JavaScript by lmm on Wednesday August 03, 2022 @07:56AM (#32330510)
Python build/package management tooling is a joke, but Python the language is very consistent and usable.
Re:I still love PHP and JavaScript by jrm4 on Wednesday August 03, 2022 @10:17AM (#32331995)
Ooh, now that's a good question.

Which is more important really? I genuinely don't know the answer to this.

Re:I still love PHP and JavaScript by lmm on Wednesday August 03, 2022 @07:37PM (#32337691)
I don't think it's an either/or; more like both language and tooling can eat into your annoyance budget and you look for the combination that has the lowest overall cost.
Re:I still love PHP and JavaScript by fpoling on Wednesday August 03, 2022 @12:41AM (#32327724)
With Python one never knows when a particular feature code depends on will be removed. With PHP code written 15 years ago still works.
Re:I still love PHP and JavaScript by Hasu on Wednesday August 03, 2022 @01:43AM (#32328045)
> With PHP code written 15 years ago still works.

If you never upgrade, sure. PHP 7 and each minor version in it have deprecated and removed plenty of stuff that was legal in 5.6. PHP 8 is on track to do more of the same. I think the backwards incompatible changes are pretty much all good for the language, but claiming backwards compatibility in PHP is completely wrong.

If you aren't on PHP 8, you aren't supported, and if you're on anything earlier than 7.4, you aren't getting security releases. And the new versions released yearly all have breaking changes, and get three years of security support. It's not 2015 anymore.

Re:I still love PHP and JavaScript by winstonewert on Wednesday August 03, 2022 @12:46AM (#32327756)
What features have been removed from Python?
Re:I still love PHP and JavaScript by eyegor on Wednesday August 03, 2022 @01:07AM (#32327867)
Besides the obvious 2 to 3 transition, cpython has obsoleted or renamed stdlib modules several times between 3.x versions. For example, the collections.abc change causes several common Linux bits to break if you change the system default to 3.8.
Re:I still love PHP and JavaScript by SketchySeaBeast on Wednesday August 03, 2022 @09:35AM (#32331487)
Which is a double edged sword. How many ways can one escape a string, and for how many of them will you find a stack overflow comment from a decade ago saying are the secure option to use?
Re:I still love PHP and JavaScript by jfabre on Tuesday August 02, 2022 @09:27PM (#32326577)
ruby...
Re:I still love PHP and JavaScript by ehnto on Wednesday August 03, 2022 @09:42AM (#32331546)
To which most developers say, oh well, because they'll never encounter them.
Re:I still love PHP and JavaScript by Kiro on Wednesday August 03, 2022 @04:10AM (#32328954)
Like what? Come on, if it's that common you must have at least one example.
Re:I still love PHP and JavaScript by pkrumins on Tuesday August 02, 2022 @08:51PM (#32326337)
It literally doesn’t matter. You fix the bug, deploy, and move on on.
Re:I still love PHP and JavaScript by johnisgood on Friday August 05, 2022 @05:36PM (#32362250)
Perhaps those people are stuck with PHP 5.
Re:I still love PHP and JavaScript by tambourine_man on Tuesday August 02, 2022 @10:47PM (#32327056)
For example?
Re:I still love PHP and JavaScript by mattacular on Wednesday August 03, 2022 @06:58AM (#32330062)
What are you referring to?
Re:I still love PHP and JavaScript by cutler on Wednesday August 03, 2022 @08:03AM (#32330568)
Examples?
Re:I still love PHP and JavaScript by labrador on Tuesday August 02, 2022 @10:03PM (#32326789)
> I feel like PHP documentation is very undervalued

PHP is documentation done right because of the comments, essentially "Stack Overflow" for PHP before stackoverflow.com was a thing.

I've found an example of documentation done wrong recently with Microsoft .NET 6.0. Apparently, Microsoft has decided that code samples are no longer important

Re:I still love PHP and JavaScript by wiennat on Wednesday August 03, 2022 @03:40AM (#32328740)
What's happen to MS these days? I remember the documents during .NET 2.x days were very good, well-organized and useful.
Re:I still love PHP and JavaScript by psalminen on Tuesday August 02, 2022 @10:30PM (#32326957)
I've been migrating to Azure and their SDK documentation is next to nonexistent. The codebase is also uncommented and inconsistent. It's just been a dumpster fire.
Re:I still love PHP and JavaScript by kyriakos on Wednesday August 03, 2022 @12:30AM (#32327669)
Microsofts documentation is horrible. They churn out api after api and never document it correctly.
Re:I still love PHP and JavaScript by zelphirkalt on Wednesday August 03, 2022 @05:53AM (#32329657)
> PHP is documentation done right because of the comments, essentially "Stack Overflow" for PHP before stackoverflow.com was a thing.

It's funny really, for a programming language to rely on comments made by random people, instead of having those aspects covered in the documentation itself. Shows a bit of lack of care. It seems half-assed as many things in the ecosystem seem. What happens, if they ever lose that database of comments? The whole world scratches their heads wondering how to use standard library functions? Ridiculous. I hope they have good backups.

> I've found an example of documentation done wrong recently with Microsoft .NET 6.0. Apparently, Microsoft has decided that code samples are no longer important

And for as long as important documentation resides in comments in PHP docs, the same can happen to PHP docs. Lets say they push out PHP 9 and some things change. Someone thinks "Ah those comments are not actually true any longer. Lets get rid of them." Bam, massive resource lost, because the knowledge has not been integrated into the documentation.

Re:I still love PHP and JavaScript by labrador on Wednesday August 03, 2022 @05:35PM (#32336900)
Here's a sample of a user generated comment on array_map

Assuming they backup the website, how's it going to get lost?

https://www.php.net/manual/en/function.array-map.php#113886

Re:I still love PHP and JavaScript by djxfade on Wednesday August 03, 2022 @03:55AM (#32328845)
This can go both ways. I have seen some very dangerous code examples in the comment section of the PHP docs.
Re:I still love PHP and JavaScript by labrador on Wednesday August 03, 2022 @05:30PM (#32336854)
Usually followed by a comment that says don't do what the last comment said
Re:I still love PHP and JavaScript by miffy900 on Tuesday August 02, 2022 @08:40PM (#32326269)
> - no "unknown unknowns". it's so tried-and-true, there's no surprises

I've always been a fan of PHP too; it was my first programming language that I used to build a shipping application, but saying there are 'no unknown unknowns' in a language as quirky and old as PHP is akin to denying the sky is blue.

PHP 4 + 5 had so many weird quirks, and they lasted a long time because PHP 7 took so long to ship (note there was no PHP 6). When 7 hit, they followed it up with many minor releases to try deprecating/removing/correcting some of those quirks, which itself introduced more unknowns when refactoring legacy code. Suddenly the quirks you were used to for so long were now gone or behaving differently (or more sensibly at least), but this required even more refactoring to account for.

When a language is always changing or evolving you can never know in advance with certainty how new features or changes will change how existing code will work.

Re:I still love PHP and JavaScript by djbusby on Tuesday August 02, 2022 @10:56PM (#32327126)
All the languages are changing: eg JS, Go stuff we did a few years ago don't work now. It's a not a situation unique to PHP.
Re:I still love PHP and JavaScript by skrebbel on Wednesday August 03, 2022 @01:29AM (#32327971)
JS is famously backward compatible, what stuff are you referring to?
Re:I still love PHP and JavaScript by pkrumins on Tuesday August 02, 2022 @08:52PM (#32326351)
I strictly use PHP5 with no updates as everything is well known and code I wrote in 2000 will work for decades. If it ain’t broke, don’t upgrade it!
Re:I still love PHP and JavaScript by BFLpL0QNek on Tuesday August 02, 2022 @09:29PM (#32326591)
> it's stateless by design (much easier to scale)

I noticed being stateless made it difficult to scale for any complex app. It’s been 7-10 years since I used it but Drupal used 60-128MB+ plus per request. As it was stateless it had to do a full bootstrap for every request coming in, set up a new database connection, module discovery etc, all which was heavy to do for every request. Most people scaled Drupal by putting Varnish in front preventing the origin from being hit so not really scaling Drupal as such, varnish is taking off some load where it can.

Drupal is probably the extreme though. If you have a simple app with a few scripts, light use of a DB it’s not to bad. I’ve heard it’s come on a lot in the past 10 years and Laravel. I certainly had less issues using PHP than I do with JavaScript.

Re:I still love PHP and JavaScript by larve on Tuesday August 02, 2022 @09:38PM (#32326644)
Yes, nothing comes for free. opcache, object cache + db pooling is something I always turn on.

Then, for app performance:

My approach is to usually design the app / refactor the app so static content can be fully cached. In ecommerce sites this can make an absolutely impressive difference. Then, leverage opcache and object cache and further separate cacheable path from dynamic path in dynamic SSR queries. Always drive using APM performance metrics as a guide. No need to optimize the DELETE /user endpoint called twice a week.

Then, identify the heavy hitters in the dynamic DB queries, and basically write those in hand rolled SQL. It usually boils down to 4 or 5 queries doing 99% of the work (GET /posts, GET /categories, GET /products, etc...). I do this fairly late in the game, but think about it very hard up front. I like to use some kind of ORM for everything writing to the DB, and sql builders / pure SQL for reading.

The split between cacheable / non-cacheable can be subtle depending on the application, and might require some non-obvious structures in the codebase.

For real tricky performance issues (not something I had to do in PHP projects), I will either ducttape some AWS infrastructure or handroll a microservice in C++ or golang. This is something I had to do for realtime / transient loads.

Re:I still love PHP and JavaScript by jamesfinlayson on Wednesday August 03, 2022 @12:11AM (#32327585)
Yes a properly tuned opcache (not hard - I think there are only a handful of settings) really helps.
Re:I still love PHP and JavaScript by mikeytown2 on Tuesday August 02, 2022 @09:49PM (#32326703)
Drupal misused the database. For Drupal 7 I made the apdqc module for async prefetch MySQL. no deadlocks makes it easy to scale, load balance more Apache servers in front. DB size was 100gb; well into millions of rows of nodes; all logged in users. Site I made this for has been up for years; Fix the database layer and Drupal 7 will scale like crazy.
Re:I still love PHP and JavaScript by lmm on Tuesday August 02, 2022 @11:31PM (#32327344)
> I noticed being stateless made it difficult to scale for any complex app. It’s been 7-10 years since I used it but Drupal used 60-128MB+ plus per request. As it was stateless it had to do a full bootstrap for every request coming in, set up a new database connection, module discovery etc, all which was heavy to do for every request.

It doesn't make scaling hard, it makes scaling very easy because you can just horizontally scale out as many instances as you need. The constant factor is pretty awful, but that's the tradeoff you make for statelessness.

Re:I still love PHP and JavaScript by BFLpL0QNek on Tuesday August 02, 2022 @11:52PM (#32327463)
Ok, it makes scaling technically easy with horizontal scaling for the web tier, ignoring the DB.

In practice it makes scaling hard for financial reasons if you require 128MB+ per request. A 32GB server will struggle with more than 256 concurrent requests at 128MB+ per request. A 32GB server is an extremely large server for such low request numbers.

If you can bring the memory usage down stateless works well. I use a bit of rust on aws lambda with the lowest memory settings so pay fractions of a cent and can handle more traffic than I ever need. I do set up persistent connection pools for the life of the lambda and only bootstrap once to bring down latency per-request but treat it as an ephemeral horizontal scaled service.

Re:I still love PHP and JavaScript by lmm on Tuesday August 02, 2022 @11:57PM (#32327504)
The problem there isn't scaling - it scales perfectly - the problem is low performance.
Re:I still love PHP and JavaScript by WatchDog on Tuesday August 02, 2022 @11:32PM (#32327354)
It might be much less efficient per request than other popular languages, but it's stateless design, does at least prevent developers from using local memory caches, which can prevent a number of problems from cropping up when scaling horizontally.

With that said, I think the stateless nature of php is talked up too much.

While not enforced by the nature of the language like php, writing stateless apps in other languages comes quite naturally.

Scaling difficulties are almost always to do with the database solution rather than the app, and overcoming those problems has little to do with the choice of language.

Re:I still love PHP and JavaScript by larve on Wednesday August 03, 2022 @09:20AM (#32331327)
It always depends on the situation, but I do value the stateless approach "by default" of PHP because it makes shoddy code / legacy code that has grown through generations of uninterested developers much easier to deal with.

I of course value at least partial "stateless" (functional core / hexagonal architecture, event driven architecture) in any language, because they reduce complexity so much.

Re:I still love PHP and JavaScript by conradfr on Wednesday August 03, 2022 @04:39AM (#32329154)
That's not that true anymore with https://www.php.net/manual/fr/opcache.preloading.php (and PHP-FPM).
Re:I still love PHP and JavaScript by stef25 on Wednesday August 03, 2022 @09:50AM (#32331637)
With both Drupal and Laravel it's very easy to overload the database. It's shocking when you start using some tool that gives you insights in to this and it tells you you're running 6000+ queries every time your homepage loads.

In Laravel it's not too hard to avoid this problem but a lot of noobs don't get the lazy / eager loading thing and then you end up like this.

Drupal seems to add hundreds of queries for every module you add.

Re:I still love PHP and JavaScript by larve on Wednesday August 03, 2022 @09:58AM (#32331736)
I feel this is more a "classic" ORM problem. Wordpress is absolutely egregious here as well. I wrote up my strategy in another post, but I usually develop using the ORM (often, ORM for writing, SQL builder + ORM for querying, because I hate ORM filter/join abstractions).

I do think very hard up front what the product will require in terms of: - static content - dynamic content that is cacheable and which keys can be used to cache it

Static content can use ORM as much as it wants, cloudfront will take care of it. dynamic content that is rarely hit doesn't really need much help either if there are no UX latency requirements. dynamic content that is hit very often (usually only a couple of endpoints) can be rewritten into manual SQL.

If you think about it, most page hits with dynamic content can be rendered basically by the DB + templating engine, and no other logic should be involved.

Re:I still love PHP and JavaScript by dbbk on Wednesday August 03, 2022 @07:06AM (#32330118)
That might be mainly a Drupal problem, I use Laravel and it can do some significant caching of all the bootstrap stuff for production. Plus as mentioned PHP itself is pretty strong now in terms of opcache and such.
Re:I still love PHP and JavaScript by dmitryminkovsky on Tuesday August 02, 2022 @09:34PM (#32326619)
Had same experience, had same thoughts. I bet I could make my way around the Drupal 7 bootstrap even these days, I looked at it so much... and so often thought... all this... every request?
Re:I still love PHP and JavaScript by dbbk on Wednesday August 03, 2022 @07:03AM (#32330090)
I agree. I started learning PHP in 2006, and though obviously it's advanced enormously since then, I did wonder if I should switch to more 'modern' options. In particular I tried to switch to Node a few times. But I just found myself feeling like I was missing out on benefits from PHP and not really gaining anything new (particularly, like you say, stateless requests just makes logical sense).

I do think people who react so viscerally negative to it in 2022 are only doing so from an old preconception and not judging it for what it is today. I build seriously large and complex applications and never once have I felt that I was fighting PHP or it was holding me back. I don't really get the hate.

Re:I still love PHP and JavaScript by bearmode on Thursday August 04, 2022 @05:06AM (#32340760)
Modern PHP with a framework like Laravel is honestly a joy to work with.
Re:I still love PHP and JavaScript by brightball on Tuesday August 02, 2022 @08:50PM (#32326332)
First 10 years of my career were heavy PHP. I’m solidly into Ruby and Elixir now, but I completely agree with you on the perks of PHP. People love to hate on it.

https://www.brightball.com/articles/no-such-thing-as-real-pr...

(Old article with a lot of dead links now, just FYI).

Re:I still love PHP and JavaScript by brightball on Wednesday August 03, 2022 @10:31AM (#32332225)
Reposting that made me realize I needed to fix my old URL redirect logic, so I did and the dead links work now.
Re:I still love PHP and JavaScript by wonderwonder on Tuesday August 02, 2022 @08:30PM (#32326184)
Its so easy to just get things done in php, even if its in an ugly way that you would never show to another developer. I built a saas for a fortune 1000 company after not programming for 5 years and never having done web development that ran several processes for them and they used it for a decade. It was the ugliest code in existence but it was so easy to just update and after it was up it just ran, forever. Deploying changes was just dragging over a file in Filezilla. Been thinking of building something new and considering learning node but PHP is right there. When I had to migrate to a new server I just copy - pasted the folders and away it went.
Re:I still love PHP and JavaScript by zelphirkalt on Wednesday August 03, 2022 @06:42AM (#32329953)
> Deploying changes was just dragging over a file in Filezilla. Been thinking of building something new and considering learning node but PHP is right there. When I had to migrate to a new server I just copy - pasted the folders and away it went.

These days most organizations will not tolerate just copying files over. There will be a process for testing the code and then stuff will probably be put in a container, to be even easier to run on another server.

At that point the advantage of just sftp-ing files over disappears. It is no longer deemed safe enough to do so. Usually it is not the end of the world, if your website is down for a minute, but it does tarnish the public image of reliability, so organizations are not willing to put up with developers making a typo somewhere bringing down their website or causing at least an annoying error on the website.

Instead of copying files over to another server, you would typically do some docker pull or other container engine pull some image or what have you. Then you would run that previously tested thing on the server.

Re:I still love PHP and JavaScript by larve on Wednesday August 03, 2022 @09:44AM (#32331577)
I think the point is that you can do both. Sometimes being able to yeet a PHP file to some PHP/wordpress hoster and get a project done in an afternoon is exactly what is needed, because even spending 2 or 3 days to set up a proper CI and deployment environment would be too much friction.

There is a whole range of projects like that out in the wild, once you leave the realms of startups and big tech.

It's about as easy to do "proper" deployment using bundles / containers / CICD / kubernetes / gitops with PHP as with any other stack. It's also possible to click a wordpress domain for $10/month and upload 2 php files and start making revenue.

For a small business that is starting up, choosing between $10k of freelance work to get a nice github actions workflow on GKE + a monthly retainer of $2k for "maintenance" vs a one time $1k of freelance work to get a wordpress where you can configure the plugins and theme yourself is a no brainer. Many of those small business then grow much larger and reach a point where in hindsight you can say "should have gone with docker containers". But the original decision was not just perfectly valid, but probably the only reasonable one.

Re:I still love PHP and JavaScript by wonderwonder on Wednesday August 03, 2022 @01:02PM (#32334262)
Not talking about organizations, talking about a little group of people or a startup building something fast to get some cash flow or a poc. Php is there when you just need to get something done and live. I built my SaaS in 4 months with php, probably did 40 total hours of updates over the life of the application and it was used for a decade performing some relatively complex process management.
Re:I still love PHP and JavaScript by cutler on Wednesday August 03, 2022 @08:48AM (#32330984)
Not to meniton Kubernetes, AWS and Terraform. I don't think you really get PHP.
Re:I still love PHP and JavaScript by ChrisMarshallNY on Wednesday August 03, 2022 @08:41AM (#32330906)
DISCLAIMER: I am not actually a "backend" developer (although I have written some pretty big backends).

I am not a JS fan. This is not because I have anything against the language; it's just that I have no real need for it, and have treated it as a "necessary evil," in my frontend work, so I don't believe that I have much of a platform to lob spitballs at it.

PHP, on the other hand, is a language that I have used for over 20 years. I think it was 3 or 4, when I started. If I do backend work, these days, I'll be doing so, in PHP.

I always like looking at the "fishtank graph"[0]. That sort of puts things in perspective.

[0] https://w3techs.com/technologies/history_overview/programmin...

Re:I still love PHP and JavaScript by felipellrocha on Tuesday August 02, 2022 @07:36PM (#32325700)
Because there is no way this is true:

> - no "unknown unknowns". it's so tired and true, there's no surprises

Re:I still love PHP and JavaScript by rsch on Tuesday August 02, 2022 @10:53PM (#32327105)
Ah I remember the experience of just dropping files on a server from a long time ago.

I had one web host where magic_quotes_gpc was enabled. Good luck figuring out what the hell is going on with all these extra quotes in your variables.

And I kept looking up how to do prepared SQL statements in PHP, finding the mysqli functions, and then eventually figuring out that mysqli wasn’t available on your average web host with PHP back then.

(Yes it was that long ago. I also think a lot of the hate comes from that era)

I remember the documentation as well, with usually all the gotchas in the comments. Which is great, but there were a lot of gotchas. like, A LOT.

Re:I still love PHP and JavaScript by candiodari on Tuesday August 02, 2022 @07:25PM (#32325608)
I really like the serverless aspect. I still think nothing has the deployment story that PHP applications have. Just upload some source and your website is up.
Re:I still love PHP and JavaScript by themodelplumber on Tuesday August 02, 2022 @07:42PM (#32325764)
Pixar should make a film called "Deployment Story" in which PHP is basically Woody (maybe it's even just the PHP stuffed elephant?), and Woody ends up in the box on the street, and then Woody's dev pal doesn't realize what they've really lost until some reflection is done. I'd watch that.
Re:I still love PHP and JavaScript by thomaslangston on Tuesday August 02, 2022 @08:12PM (#32326030)
This reads better when reflection is used in both meanings.
Re:I still love PHP and JavaScript by koolba on Tuesday August 02, 2022 @09:31PM (#32326599)
There has to be a Debian angle to this plot as well.
Re:I still love PHP and JavaScript by mekster on Tuesday August 02, 2022 @11:06PM (#32327183)
Interestingly, that has been the case for 25 years or so now but none except perl was able to do that?
Re:I still love PHP and JavaScript by dogleash on Wednesday August 03, 2022 @10:16AM (#32331993)
Perl's not unique in that way. Any language can talk cgi. That's literally the purpose of cgi. Perl was just the popular scripting language of the day.

If you're using something other than cgi to get your httpd to talk to your webapp, your answer lies in understanding the architectural decisions of that tool.

Re:I still love PHP and JavaScript by ed25519FUUU on Tuesday August 02, 2022 @08:15PM (#32326055)
Do PHP applications really require no system packages for any use-cases?
Re:I still love PHP and JavaScript by lmm on Tuesday August 02, 2022 @11:33PM (#32327358)
PHP is pretty batteries-included, sometimes to a fault (it comes with things like 3 different MySQL drivers in the standard library). I'm sure there are cases where you'd want to install a C extension that depended on some system library, but I can't actually think of any right now.
Re:I still love PHP and JavaScript by asddubs on Wednesday August 03, 2022 @08:54AM (#32331044)
imagick for imagemagick is a common one. but yeah, you can go really far with just relying on php standard features
Re:I still love PHP and JavaScript by paulryanrogers on Tuesday August 02, 2022 @08:54PM (#32326366)
What do you mean by system packages? There are PHP packages now and Composer. Though core and its bundled extensions are quite rich. So 3P packages aren't strictly necessary.
Re:I still love PHP and JavaScript by quickthrower2 on Tuesday August 02, 2022 @07:46PM (#32325819)
It is also JSX before JSX was invented too :-)
Re:I still love PHP and JavaScript by jimbokun on Tuesday August 02, 2022 @09:40PM (#32326660)
I’ve always wondered why the more respectable dynamic languages, like Ruby and Python, don’t have a web framework with the PHP deployment model of “just upload this file to the server and refresh your browser to see changes.”
Re:I still love PHP and JavaScript by makeitdouble on Wednesday August 03, 2022 @06:03AM (#32329711)
I don't know for big instances of Laravel, for every deployment pipelines of Symphony I've seen were far from "Drop that file on the server. The end."

In the most primitive ways, you would at least do cache warming, which usually means "building" the app instance in a separate folder and swapping the active directory served by the web server. That's basically what a basic Capistrano deploy would do.

Nowadays I'd expect most shops to be using containers for PHP too, and that means building your container like any other language.

What I'm saying is, the days where PHP deployment was simple have been long gone, for at least a decade in my experience.

Re:I still love PHP and JavaScript by stevekemp on Wednesday August 03, 2022 @01:14AM (#32327896)
Ruby did have such a thing, via mod_passenger, and other options were available for different scripting/programming languages.

Back in the day PHP got big because most of the larger shared-hosting sites provided mod_php out of the box, along with MySQL.

If you wanted to run CGI scripts you were probably capable of doing that, whether in Perl or something else, but most of the other options came later or were unusual.

I know when I tried to setup a few sites a long long time in the past I had to get a VPS of my own, with root, to configure Apache appropriately. None of the shared hosting sites would have run the kind mods I wanted to have.

Re:I still love PHP and JavaScript by Blackthorn on Tuesday August 02, 2022 @11:51PM (#32327457)
They do. It's just that everyone seems to have collectively decided that cgi shouldn't be used anymore.
Re:I still love PHP and JavaScript by jeroenhd on Wednesday August 03, 2022 @03:56AM (#32328859)
CGI has become "serverless" and it's hyped up to no end. The more things change, the more they stay the same.
Re:I still love PHP and JavaScript by larve on Wednesday August 03, 2022 @09:27AM (#32331414)
Thanks for the comment!

I think the "the more things change, the more they stay the same" is a great thing, and something to very much be aware of and study. The move back and forth from backend state to frontend state to slim apps to fat apps has been going on since the 60ies, and is driven by ultimately hardware and networking costs.

The underlying patterns are all fairly well understood, which means that knowing both approaches and being aware that things are going to slosh back and forth heavily simplify long term design.

I haven't written these thoughts out, but in many ways the codebase (as in, how your files are organized) is largely independent of how your code is actually deployed and where it runs. If you are aware that some business logic might one day run in the frontend on the client device, and 4 years later might make more sense ot run in a lambda, that's something you can architect for.

Serverless / stateless is ultimately "functional programming". If you write your code as a side-effect free function, leveraging technologies like WASM, you can keep the same code, and deploy it frontend or backend or both or as a lambda or as a single node worker, and the code itself won't change. These are the things that next.js and vercel and edge computation leverage, but it is true in every codebase (embedded, desktop applications, etc...).

Re:I still love PHP and JavaScript by NateEag on Wednesday August 03, 2022 @10:36AM (#32332307)
With the crucial difference that "serverless" is proprietary and uses different APIs, so you can't just go to whatever hosting company you want.
Re:I still love PHP and JavaScript by jeroenhd on Wednesday August 03, 2022 @11:51AM (#32333352)
Of course, vendor lock-in is a feature because once developers leave a company, someone else with the necessary proprietary knowledge needs to replace you. Spread proprietary cloud stuff like the plague and you'll always be employable somewhere!
Re:I still love PHP and JavaScript by hestefisk on Wednesday August 03, 2022 @08:45AM (#32330948)
use CGI; use strict;
Re:I still love PHP and JavaScript by cutler on Wednesday August 03, 2022 @08:59AM (#32331102)
It's often misunderstood that a lot of the much-vaunted cheap hosting providers offer PHP only as a CGI. You would typically pay extra for mod_php.
Re:I still love PHP and JavaScript by ptx on Wednesday August 03, 2022 @02:56AM (#32328478)
Python and Ruby have more startup overhead than Perl and PHP, so usually you don't want to pay that cost for every request.

Edit: Not sure why this is controversial. Here is a "hello world" benchmark I just ran on my machine, in units of hello worlds per second: Perl – 1020 runs/second; Python – 78 runs/second; Ruby – 30 runs/second.

Re:I still love PHP and JavaScript by leshenka on Wednesday August 03, 2022 @03:29AM (#32328674)
Can we have the "soft reload" model like how Django works in development mode?

Drop a file on a server, it notices filesystem change, reloads an app (or spawns a second copy of app, waits for it to initialize, kills original app and switches over to a new one)?

Re:I still love PHP and JavaScript by ptx on Wednesday August 03, 2022 @04:43AM (#32329191)
Gunicorn has an option for this[1] so you could enable it on your production server, although I don't think that's recommended.

One problem with this approach is what happens when you're updating multiple files. If the server restarts immediately on the first change, you end up loading a mix of old and new files, which probably won't work properly. But if you delay the restart to wait for all the files, how long do you wait? If the delay is too long it's confusing and annoying (did the server restart yet?) and if it's too short you get mixed versions as before.

So it's better to explicitly signal when it's time to restart. You can still have automatic restarts in the development environment.

[1] https://docs.gunicorn.org/en/stable/settings.html#reload

Re:I still love PHP and JavaScript by mejutoco on Wednesday August 03, 2022 @05:43AM (#32329588)
Assuming you get a new "event" every time a file in the watched folder changes, you could restart the count.

Ex. First even triggers a 5 seconds wait. If before those 5 seconds have passed there is another trigger (say after 1 second) another 5 seconds wait starts, for a total of 6 seconds in this example.

Re:I still love PHP and JavaScript by larve on Wednesday August 03, 2022 @09:48AM (#32331624)
I really like the vercel and co approach to the dev cycle. It's as easy as (if not easier) PHP and you get a huge boost of monitoring / infra tools for a minor cost. I think we are seeing a lot of the "yeet and get shit done" approach with vercel and netlify that we used to with PHP.
Re:I still love PHP and JavaScript by Izkata on Tuesday August 02, 2022 @11:24PM (#32327301)
Python has had cgi forever: https://docs.python.org/3/library/cgi.html
Re:I still love PHP and JavaScript by bigtunacan on Tuesday August 02, 2022 @10:33PM (#32326975)
I would say security by default is a good reason to not have this. I've been burned too many times on PHP projects because someone miss-configured an httpd conf file.
Re:I still love PHP and JavaScript by kyriakos on Wednesday August 03, 2022 @12:31AM (#32327676)
From all the potential web security issues someone can have that one is probably the easiest and most likely you will get right.
Re:I still love PHP and JavaScript by bigtunacan on Wednesday August 03, 2022 @12:45AM (#32327751)
The whole reason for the principle, "Secure by default" is because someone is going to fuck up.
Re:I still love PHP and JavaScript by cutler on Wednesday August 03, 2022 @08:55AM (#32331054)
Shared Nothing Architecture.
Re:I still love PHP and JavaScript by jader201 on Tuesday August 02, 2022 @09:17PM (#32326515)
> why the downvotes? If you don't agree, just reply so we can have a healthy dialogue.

I think downvote = disagree is expected. If someone thinks your comment is not making valid points, downvoting is a way to bury it below other comments.

So that, naturally, the comments that the community most agrees with (in addition to adding quality content) bubbles to the top.

https://news.ycombinator.com/item?id=658691

Re:I still love PHP and JavaScript by oxff on Wednesday August 03, 2022 @01:14AM (#32327894)
PHP documentation is one of the worst things I've ever seen. That people subject themselves to abuse such as "reading it" is comical to me. Enjoy scrolling down 15 years of comments to get the quick rundown.
Re:I still love PHP and JavaScript by conradfr on Wednesday August 03, 2022 @04:44AM (#32329200)
The documentation is good because it usually shows examples for all parameters types, something I miss regularly in the Elixir docs for example.

I agree that the comments should be removed or at least hidden by default as they're usually not relevant anymore.

Re:I still love PHP and JavaScript by Tainnor on Wednesday August 03, 2022 @07:18AM (#32330194)
> - No long compile times because there is no compiling needed.

I respect that some people accept dynamic typing as a better tradeoff for various reasons (I've worked with Ruby for many years before I discovered my love for type systems), but to me that statement reads similar to:

"No long CI builds because we skip all the tests."

:)

Re:I still love PHP and JavaScript by artificialLimbs on Wednesday August 03, 2022 @10:03AM (#32331798)
Re:I still love PHP and JavaScript by Tainnor on Wednesday August 03, 2022 @02:38PM (#32335312)
That's runtime type checking, which is a completely different thing and doesn't fit the analogy. Runtime type checking helps you fail fast, which hopefully prevents undefined behaviour and data corruption, and can help with fault localisation (some hardcore type theorists would even argue that runtime types aren't really "types" per se, but more like tags).

Compile-time type checking is a soundness proof of your program, which is an entirely different thing.

Re:I still love PHP and JavaScript by cm2187 on Wednesday August 03, 2022 @09:48AM (#32331622)
The issue I have with php, having started building websites in the early 2000s with it, is that it is a language that doesn’t push you to write better code and progress. I am much more of a fan of static langages where the IDE guides you a lot more, gives you live feedback so that being curious is cheap, you don’t have to dive into some documentation to know what the other methods, parameters and overloads are, you can refactor code safely and effortlessly.

So I am sure some professionals write brillant code in php, particularly in large organisations, but my guess is that the median code base quality out there is probably pretty lousy. Anything below the 80th percentile probably too.

Also it’s for websites only.

Re:I still love PHP and JavaScript by larve on Wednesday August 03, 2022 @09:52AM (#32331658)
I think PHPStorm has been very helpful as an IDE for over a decade.

One of the things I do like about PHP is that while most legacy codebases out there are lousy (even when good developers are involved), and often lousy for totally legitimate reasons, PHP with its "don't even try to do clever" approach makes many things easier.

Of course, I only dealt with so many legacy applications. My worst experiences have always been with python legacy code because there were strata of conflicting "better code" approaches piled on top of each other.

Once you start abstracting into patterns, and you don't have the experience needed to get a sense of good architecture, it's easy to make a real tangled mess.

Re:I still love PHP and JavaScript by coding123 on Tuesday August 02, 2022 @11:47PM (#32327435)
I won't downvote you, I think it's kinda crappy when people just do that without explaining. Also an opinion isn't something we shouldn't downvote, we should downvote poor responses.

In any case, I definitely agree with all those pros. What I dislike about PHP is that as you start growing a codebase, especially with includes, your attack surface just grows and grows and grows. In other frameworks where a stack is involved attack surface generally grows as well, but since any PHP script has access to the request, it's much much worse.

Re:I still love PHP and JavaScript by ChrisMarshallNY on Wednesday August 03, 2022 @09:56AM (#32331712)
> I also think there is something unique about PHP documentation. It has plenty of real life examples, and the ability for users to leave comments allows you to hear directly from others "gotchas" that people have experienced. I feel like PHP documentation is very undervalued.

I think it's the best documentation out there, and that part of the reason it's easy to document, is because the language uses a standard library, and functions, as opposed to the structure of the language, itself, to provide most of the utility. Functions are easy to document.

They do a good job of "cleaning out the cruft," as well, so that there isn't much in the way of "no longer applies" stuff.

Part of it, too, is that the language probably supports stuff all the way back to 4. They tend not to deprecate, and accrete, instead (not always a good thing). That means that examples and discussions maintain relevance, even years later.

One of the biggest issues that people tend to have with PHP, is that it allows you to write bad code.

I came from a C++ shop (another language that people love to hate). If you think you can write bad code in PHP, C++ says "Hold my beer."

I am a big believer in Discipline. With Discipline, we can write excellent, maintainable, code in any language. I have written stuff in Assembly, FORTRAN, Pascal, PL/1, Perl, Bash, BASIC, C, C++, ObjC, and Swift, that is quite well-structured, maintainable, and well-documented.

Re:I still love PHP and JavaScript by onion2k on Wednesday August 03, 2022 @03:22AM (#32328631)
- it's stateless by design (much easier to scale)

That's sort of true, but the default state mechanism (session files) doesn't scale well, or even work across load balancers that don't maintain server affinity for each client. Scaling a PHP app isn't hard, but it can be non-trivial if you've written the code without considering scaling. Other serverside scripting languages (Python, Ruby with Rails) nudge you in the right direction in ways that PHP doesn't.

Re:I still love PHP and JavaScript by heurisko on Wednesday August 03, 2022 @05:59AM (#32329689)
It's trivial to configure PHP to store sessions in redis.
Re:I still love PHP and JavaScript by Glyptodon on Tuesday August 02, 2022 @07:55PM (#32325883)
Did they get rid of the giant config file with all the interpreter options that can seem like they shouldn't exist?

(I do like modern PHP well enough.)

Re:I still love PHP and JavaScript by paulryanrogers on Tuesday August 02, 2022 @08:52PM (#32326349)
PHP.ini is alive and well. Some foot guns have been deprecated
Re:I still love PHP and JavaScript by anony999 on Wednesday August 03, 2022 @05:59AM (#32329687)
Have you tried a more "modern" language recently? By trying I mean using it for more than 6-10 months. I've been one of the PHP "supporters" until I've found Go and Rust. PHP was really nice to get into programming and make a spaghetti website but the language itself and the ecosystem always felt like a hacking project.

The killer feature of PHP has always been the hosting ecosystem. A simple FTP upload would do the job without knowing much about the hosting infrastructure. Recently we've got that kind of "serveless" experience for other languages as well but the deploying is proprietary and the providers are very few. I'm aware only of Google Cloud Run.

As for JavaScript even its inventor said it's time to move on. It's time for a new language and a new DOM interface. Maybe we can fix the "language" issue with WASM but we are still left with the DOM.

Re:I still love PHP and JavaScript by cutler on Wednesday August 03, 2022 @08:54AM (#32331042)
> PHP was really nice to get into programming and make a spaghetti website

Facebook manages quite well with PHP. Maybe it's your fault you didn't learn how to use modern PHP practices which have been well-documented for over a decade now.

Re:I still love PHP and JavaScript by anony999 on Wednesday August 03, 2022 @11:18AM (#32332922)
>> Facebook manages quite well with PHP.

I didn't say you can't make it work. You can build great stuff using just bash scripts. I'm pretty sure you can have success with any programming language. That doesn't mean it's the "best" way to do it.

>> Maybe it's your fault you didn't learn how to use modern PHP practices which have been well-documented for over a decade now

I doubt it's my fault. I'm not "special". I think PHP is prone to bugs and bad practices both due language design and bad documentation.

Re:I still love PHP and JavaScript by johnisgood on Friday August 05, 2022 @05:53PM (#32362402)
> I doubt it's my fault. I'm not "special". I think PHP is prone to bugs and bad practices both due language design and bad documentation.

Not in 2022. I avoided PHP for a long time. I got back to it and found that the Internet and books are full of best practices and I have not had an issue with documentation either. Would you please give me an example of how PHP is more prone to bugs vs. other languages in this area? I have found it to be really difficult to write buggy and insecure code. For example if you have not heard of PDO and you do not prepare, bindValue/bindParam, and then execute, that is your fault (make use of filter_input() as well!). It is advised literally everywhere today. Regardless, my return to PHP was pleasantly surprising. I finished my project pretty quickly and I have not used any frameworks. Security vulnerabilities? Perhaps, but so far so good. We will see. I tried my best and I have done my research. Every time I mention that it is written in PHP, people frown because they are stuck at PHP 5 or so. That said, subpar defaults in php.ini is still a thing though.

Re:I still love PHP and JavaScript by ptx on Sunday August 07, 2022 @02:31PM (#32378562)
Do you have any book recommendations for someone who knows web development but is new to (modern) PHP?
Re:I still love PHP and JavaScript by artificialLimbs on Wednesday August 03, 2022 @10:07AM (#32331862)
>>well-documented

Sources?

Re:I still love PHP and JavaScript by cutler on Wednesday August 03, 2022 @10:49AM (#32332528)
Re:I still love PHP and JavaScript by rr888 on Wednesday August 03, 2022 @08:07AM (#32330597)
> JavaScript even its inventor said it's time to move on.

I hadn't seen that quote, do you have a link?

Re:I still love PHP and JavaScript by Volt on Wednesday August 03, 2022 @06:28PM (#32337288)
Probably meant JSON instead of JavaScript

https://evrone.com/douglas-crockford-interview

Re:I still love PHP and JavaScript by anony999 on Friday August 05, 2022 @09:27AM (#32355811)
I stand corrected.It was Crockford not Eich.
Re:I still love PHP and JavaScript by soheil on Tuesday August 02, 2022 @08:17PM (#32326073)
> EDIT: why the downvotes?

The anti-PHP cult is strong here on HN. List 5 benefits of React and watch your upvotes skyrocket.

Re:I still love PHP and JavaScript by snapetom on Tuesday August 02, 2022 @11:01PM (#32327155)
It's more like redditors creeping in. The "downvote is not a disagree button" of reddiquette went out the window a looong time ago. People are fast to hit that button and the attitude is seeping in here, harming discourse.
Re:I still love PHP and JavaScript by zeroonetwothree on Tuesday August 02, 2022 @10:14PM (#32326853)
It's cool to hate on popular things.

https://headstuff.org/topical/love-hate-popular/

Re:I still love PHP and JavaScript by throwaway_4ever on Tuesday August 02, 2022 @09:07PM (#32326445)
React gets an equivalent amount of disdain as PHP. Like 60% negative, 40% positive. (lots of preferences for server-side templating, htmx, Vue, Svelte, and Phoenix LiveView)
Re:I still love PHP and JavaScript by fsdghrth3 on Wednesday August 03, 2022 @02:22AM (#32328274)
React is great. Vue is wannabe angular (not sure what version though was it 2, 3 or 4 now?) svelte is too busy shipping bugs to fix any and I don't even know what the others are.
Re:I still love PHP and JavaScript by ronsor on Tuesday August 02, 2022 @09:10PM (#32326459)
I agree with you on the anti-PHP cult, but it's become fairly "cool" to criticize React now (and JavaScript stuff in general).
Re:I still love PHP and JavaScript by mekster on Tuesday August 02, 2022 @10:32PM (#32326968)
Criticizing is so easy, especially on the internet. If they're that good, why won't they propose a workaround or work with the language developer and provide some feedback?
Re:I still love PHP and JavaScript by mekster on Tuesday August 02, 2022 @10:29PM (#32326952)
Elitists can't like what the general mass likes. There's a reason the general mass likes but they think they can do better, but let's see how they do so in real life.
Re:I still love PHP and JavaScript by sidlls on Tuesday August 02, 2022 @08:21PM (#32326120)
What cult? PHP is technically, objectively inferior to almost every other web technology (which is impressive, actually, given how terrible most web technology actually is) in almost every use case one can think of. That doesn't mean it's bad or that nobody should ever use it, or that it isn't a superior solution in some cases. But in basically any non-trivial use case, it's a poor choice.
Re:I still love PHP and JavaScript by larve on Tuesday August 02, 2022 @08:44PM (#32326294)
Thanks for commenting!

I always have a hard time understanding what exactly is meant with comments like these. We can all agree that PHP has a wildly uneven standard library, had its fair share of security-relevant footguns, tends to have unexperienced developers. That's not extremely different from python and node.js, for example.

The language significantly cleaned up its act, it has had classes, traits, closures, introspection, namespaces, packages for well over 10 years now, a robust third party library ecosystem and many successful projects to build upon (wordpress, drupal, woocommerce, phpbb, etc...). This makes it a pretty good choice for many applications.

The stateless model and the resulting "no crazy stuff" approach makes it a much more reasonable choice for web development than say, python+django or ruby+rails to me. There's nothing I loathe more than trying to find which duck-typing, method-injecting package is causing a slow-burn memory leak in production.

I also don't understand where the "most web technology is terrible" stance comes from. I find the quality of software engineering and the care put into developer UX and productivity in the web world quite inspiring. It has been a forcing function on all programmer tooling since the cambrian explosion in the earlier 2010s.

Re:I still love PHP and JavaScript by hattmall on Tuesday August 02, 2022 @08:30PM (#32326177)
That's not really true at all. PHP is like a Swiss army knife. It's not the very best at any one speciality. It is much better at many things than pretty much anything else though. You can use the Swiss army knife to put in screws, but a screwdriver is much better, but it's terrible at cutting zip ties.
Re:I still love PHP and JavaScript by akudha on Tuesday August 02, 2022 @10:09PM (#32326824)
Suppose you had a old car. You know its limitations, you've used it for many, many years. You know its problems, its quirks and warts. You also know the workarounds for its quirks. In all, it is good enough for most of your needs. It rarely surprises you. It is average looking, but it just runs and is easier to maintain.

Then comes the shiny new car - it has way too many gadgets and gizmos, you don't know how most of them work. Heck, you don't even know what half these gadgets are for. You don't know when or how it will break. But most importantly, you don't know how to fix something when it breaks, because there is too much magic going on. High maintenance, constant stress.

The first case is PHP. People can dunk on it all day, every day. But it is good enough for most projects. And with tools like Laravel, Composer etc, PHP is constantly improving too.

The latter? I dunno, there are lots of candidates for it I suppose.

Re:I still love PHP and JavaScript by lmm on Tuesday August 02, 2022 @11:36PM (#32327372)
PHP has never been simple or understandable though.
Re:I still love PHP and JavaScript by timack on Tuesday August 02, 2022 @08:54PM (#32326361)
Not sure about "no surprises" - just saw this on Twitter yesterday: https://twitter.com/LupinityLabs/status/1554217944179249153
Re:I still love PHP and JavaScript by zeroonetwothree on Tuesday August 02, 2022 @10:13PM (#32326843)
This is hardly specific to PHP. You should never compare IEEE floats using equality.
Re:I still love PHP and JavaScript by IshKebab on Wednesday August 03, 2022 @08:36AM (#32330863)
It is absolutely the fault of PHP. You absolutely can compare IEEE floats using equality. Often it isn't what you want but this totally should work.

In this case PHP is unexpectedly rounding floats for display.

    ~ python3
    Python 3.9.13 (main, May 24 2022, 21:28:44)
    [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> b = 46333.48000000001
    >>> b
    46333.48000000001
    ~ php -a
    Interactive shell

    php > $b = 46333.48000000001;
    php > echo $b;
    46333.48
Re:I still love PHP and JavaScript by unethical_ban on Wednesday August 03, 2022 @12:55AM (#32327806)
Isn't it the fault of the interpreter that it shows a rounded value without being promoted to?
Re:I still love PHP and JavaScript by nyanpasu64 on Tuesday August 02, 2022 @09:00PM (#32326401)
Apparently exact minimal float-to-string conversion is more recent than I thought, and many languages used to print more (Python?) or less (PHP) decimal digits than necessary to uniquely identify the bit pattern. Python correctly prints 46000.80 + 553.04 as 46553.840000000004, but I don't know if it ever prints more digits than needed. One recent algorithm for printing floats exactly is https://github.com/ulfjack/ryu, though I'm unaware what's the state-of-the-art (https://github.com/jk-jeon/dragonbox claims to be a benchmark and the best algorithm).
Re:I still love PHP and JavaScript by conradfr on Wednesday August 03, 2022 @04:51AM (#32329239)
Not exactly true: https://onlinephp.io/c/38d42

According to the Twitter thread:

> First value was retrieved from a db, second was calculated, which has introduced rounding errors.

Re:I still love PHP and JavaScript by RedShift1 on Wednesday August 03, 2022 @02:35AM (#32328346)
This just in: Developer discovers quirks of floating point numbers, declares outrage.
Re:I still love PHP and JavaScript by wpearse on Wednesday August 03, 2022 @02:52AM (#32328457)
I did a 100-level paper at University that explained floating point arithmetic and how to solve for equality. Without being snarky, how do developers miss this sort of stuff?
Re:I still love PHP and JavaScript by GrumpyNl on Wednesday August 03, 2022 @09:33AM (#32331470)
Not every developer need floats for the backend of a website.
Re:I still love PHP and JavaScript by omnimus on Wednesday August 03, 2022 @02:57AM (#32328488)
Yet when you go through the thread exactly same issue - float rounding happens in many other languages.

There are better examples of PHP being bad.

Re:I still love PHP and JavaScript by redml on Wednesday August 03, 2022 @01:19AM (#32327919)
I mean, its PHP - I'm not surprised ;)
Re:I still love PHP and JavaScript by KronisLV on Wednesday August 03, 2022 @04:38AM (#32329150)
> EDIT2: I also think there is something unique about PHP documentation. It has plenty of real life examples, and the ability for users to leave comments allows you to hear directly from others "gotchas" that people have experienced. I feel like PHP documentation is very undervalued.

This is perhaps one of the better things about it! It feels like lots of different languages and frameworks would benefit from comments at the bottom of the page, from the community, explaining various common use cases and gotchas.

Somehow it feels like docs being on GitHub with people being able to contribute to them there somehow can have higher friction, versus a forum-like system.

Re:I still love PHP and JavaScript by baryphonic on Wednesday August 03, 2022 @12:38AM (#32327710)
> PHP has so many hidden benefits:

> - it's stateless by design (much easier to scale)

I'll grant you this one. Though PHP in practice goes to great lengths to add state back in for performance reasons (e.g. memcached, or for a while APC).

And Haskell is stateless, too, yet not a frequent choice for web work.

> - it was "serverless" before Serverless

This is retconning. It was never trivial to set up a LAMP stack, especially at scale. I can't tell you how many times I've seen the PHP "too many open database connections" error because someone just treated their Wordpress blog as "serverless" and it went to the top of HN.

> - surprisingly performant

I can't speak about the latest stuff, but PHP5 in ~2014-15 was abominably slow. There were certain "benchmarks" which indicated it was fast, but on closer inspection, these were simply calls where PHP provided thin wrappers around C calls.

I had to once take an Excel file, parse it and then present certain fields to the user for the DB to be updated. This was possible in PHP, but it took excruciatingly long (like 8 minutes - in fact, sometimes Apache would just drop the connection), and third party library support was just awful. I implemented the same task in Python, and not only was the code much simpler and and easier to write, but the task took a second or two each time.

> - no "unknown unknowns". it's so tried-and-true, there's no surprises

The standard library is a toxic sludge of surprises. Nothing is consistent. "Will this function treat an array like a list or a dict? Who knows?"

Maybe this is better now, but the last time I dabbled in PHP, I spent a while trying to get a workable debugger set up and gave up. Stepping through code is apparently impossible, and every now and then you hit some fatal error that immediately crashes your code.

> - deployment is so simple, just drop a file on a web server. No middleware needed.

What does this mean?

First, PHP has middleware (e.g. memcached, Apache/Nginx).

Second, the complexity of deploying a Python, Node, Rust, Go or Ruby application is not the "middleware." The complexity is ensuring that the update is correct, the update is applied consistently, can be rolled back, doesn't cause downtime, etc. I could also do updates by running webpack dev server in prod and dropping files in there for deployment. As easy as PHP, yet a terrible idea.

> - No long compile times because there is no compiling needed.

This is odd to say the least. PHP's biggest weakness IMO is that each thread must entirely parse and interpret its executing program on every single call. That is a ton of wasted work, and there are literally sections in the PHP docs about tools to circumvent this problem.[0] And the solutions involve caching, which mean we give up (1) the "stateless" benefit and (2) the "just drop in a file" benefit, or else we need to add a bunch of cache coherence logic. It would be so much easier if someone could compile the PHP code to a bytecode format and drop _that_ in, which could just start executing on an interpreter ASAP.

Ultimately, I think the list is getting downvoted because it deviates so much from developers' experience with PHP. PHP started out as a sub-Turing templating tool that had a Perlish language bolted on, which then mutated to look a lot like Java. Eevee's classic blog rant[1] calls it a "fractal of bad design," but the reality is PHP has no design: it's just a kludge of duct tape and bolts.

Also, maybe this is totally incorrect now with PHP6--er PHP7 and PHP8. But my experience with PHP4 and PHP5 was so horrific that I will not be working with it again. I've yet to find a PHP use case that is not better solved with a combination of a static site generator and something like AWS Lambdas or Cloudflare Workers.

[0] https://www.php.net/manual/en/book.opcache.php

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

Re:I still love PHP and JavaScript by larve on Wednesday August 03, 2022 @10:24AM (#32332093)
Thanks for the comment!

As a counterpoint, I used PHP5 when writing https://www.goldeneaglecoin.com/ and it was always < 50 ms on my endpoints, running on some crusty hosted celeron at the time. Adding caching and opcache doesn't invalidate the stateless approach.

Programming is about adding abstractions on top of underlying computational substrates. Ultimately our CPUs don't care if we run haskell or PHP, they just run machine instructions. I never found it too complicated to use useful abstractions in PHP.

I usually prefer inheriting a subperforming cache-free PHP site, because devising a consistent cache strategy is usually not too hard (cache static content + opcodes on deploy, determine which invalidation keys you need for the subset of dynamic content that does the bulk of the load / has latency requirement, don't cache the rest). If I have a big collection of lose php files, that's reasonably easy to do. If i have a tangled web of middlewares and ORM'd business logic, it's much harder, and I usually have to unfold it to "lose leaves".

Re:I still love PHP and JavaScript by baryphonic on Wednesday August 03, 2022 @03:55PM (#32336054)
Great comment! You clearly are well-versed in the ecosystem much more than when my PHP5 self gave up. If I needed a PHP dev for a project, I'd hire you.

> Adding caching and opcache doesn't invalidate the stateless approach.

> Programming is about adding abstractions on top of underlying computational substrates. Ultimately our CPUs don't care if we run haskell or PHP, they just run machine instructions. I never found it too complicated to use useful abstractions in PHP.

I'll push back a little on these. TL;DR: it's a trade-off.

My point with Haskell is that the entire language itself is stateless, so if per-request statelessness ("shared nothing") in PHP is a virtue, then certainly total statelessness ("purity") in Haskell is even more of a virtue. The problem is that, despite having similar performance to PHP, Haskell is hard to write.

This is illustrated with caches: if a PHP program had a line something like `if ($cache.retrieve('foo') != null) { echo "Success!<br />"; } else { echo "it's broken"; }`, then now global state matters again.

Haskell doesn't allow code of this form, but forces you to think harder about how to make it work using e.g. monads, and this can be frustrating. But if you can get Haskell to work, you can get caching nearly for free.

Re:I still love PHP and JavaScript by larve on Wednesday August 03, 2022 @07:49PM (#32337757)
for sure. but it's not "hard" (of course abstraction is hard to learn and see, but not to implement, I hope you understand my meaning here. I apologize for the lack of clarity) to build something like (very rough sketch):

  function get_all_products() {
     return cached(function () { return Sql::Select(PRODUCT_TABLE); }, Cache::GetSessionCacheKey());
  }

  render_template(Page::GetTemplate(), 
     [ "products" => get_all_products(), 
       "user" => get_user_data()
     ]);
or as I did for https://goldeneaglecoin.com/ , I would internally route "HTTP" calls, so the javascript and PHP would look identical:

  /* 
   * @url: /products
   * @cache: session(1h)
   */
  function get_products() {
     return Sql::Select(PRODUCT_TABLE);
  } 

  render_template(HTTP::GET("/templates/products"), HTTP::GET("/products");
while the javascript looks like:

  GET("/products").then((products) => render_template("/templates/products", products))
The caching is declarative, and the code is "stateless." This is fast enough that caching the render is pretty much not necessary, despite running on a t2.medium, and easily sustains > 100 rps. In the happy path, it reads a single value in the object cache. Only an initial hit will cause a render (using a bytecode compiled optimized template), and only the first XHR will cause an actual lookup in the server side cache (if necessary) because the browser then does the rest.

I wrote this code 12 years ago, and porting to react doesn't require any change on the server side. We just put RTK-Query in front and let it do all the rest.

Re:I still love PHP and JavaScript by dbbk on Wednesday August 03, 2022 @07:08AM (#32330129)
PHP5 to 8 is night and day in terms of performance just on its own, they're not really comparable.
Re:I still love PHP and JavaScript by enobrev on Wednesday August 03, 2022 @10:11AM (#32331920)
> I can't speak about the latest stuff, but PHP5 in ~2014-15 was...

I don't understand the purpose of your post.

Do you judge all languages according to your experience from 8 years ago?

Do you go on python boards telling everyone how much you hate working with python 2.7?

Maybe spend your afternoon on rust threads to complain about it not being available to the public yet?

Do you need to like a language for 8 entire years before letting anyone know about it, or just some time within the past 8 years?

Re:I still love PHP and JavaScript by baryphonic on Wednesday August 03, 2022 @03:22PM (#32335751)
> I don't understand the purpose of your post.

GGP was wondering why there were downvotes rather than comments detailing disagreements.

I decided to write down the reasons why I personally would not touch PHP again rather than give a downvote.

Maybe PHP8 or PHP7 or whatever it is (I know they skipped 6?) is awesome, but I've moved on.

Also, FWIW, a few of my objections are certainly still relevant based on the claims in GGP's post and some cursory review of the documentation, particularly around caching & in particular op caching.

> Do you judge all languages according to your experience from 8 years ago?

No, only ones that left mental-emotional scar tissue.

> Do you go on python boards telling everyone how much you hate working with python 2.7?

Python 2.7 was highly pleasant. I wouldn't use it now, but it didn't abuse me. :)

> Maybe spend your afternoon on rust threads to complain about it not being available to the public yet?

GGP: <X> is awesome for these reasons!

GGP: HEY! Why are people downvoting rather than commenting?

GP (me): Here's why your reasons don't persuade me based on my admittedly outdated experience

P: Why are you so critical?

> Do you need to like a language for 8 entire years before letting anyone know about it, or just some time within the past 8 years?

Non sequitur. But the answer is no.

Perhaps it might be more productive if someone commented which of my claims are obsolete rather than ad hominem them. I know that those relating to compilation, deployment & statelessness are still valid, given GGP's comments and my cursory examination of the PHP docs, plus experience with other platforms.

Maybe modern PHP has truly excellent performance. Maybe using a breakpoint debugger has been solved now. Maybe design is better, e.g. the standard lib has functions that can work with arrays as lists and arrays as dicts without being surprising (e.g., `filter()` used to preserve all indexes, since it treated arrays as dicts from numbers to values; often, you needed to use fold/reduce or a loop to re-number after a filter).

Re:I still love PHP and JavaScript by heurisko on Wednesday August 03, 2022 @08:28AM (#32330782)
> That is a ton of wasted work, and there are literally sections in the PHP docs about tools to circumvent this problem.[0]

Install opcache, done. No need for hyperbole.

Re:I still love PHP and JavaScript by baryphonic on Wednesday August 03, 2022 @03:23PM (#32335764)
Good to know it's that easy.

Do you ever run into race conditions? And how does it handle cache coherency?

Re:I still love PHP and JavaScript by heurisko on Friday August 05, 2022 @10:48AM (#32356911)
Opcache is integrated into PHP since 5.5. It's been stable for around two decades.

https://www.npopov.com/2021/10/13/How-opcache-works.html

Re:I still love PHP and JavaScript by cztomsik on Wednesday August 03, 2022 @10:46AM (#32332481)
then take my upvote, I agree 100%, I'm saying exactly this to many people and they just roll their eyes (to be fair I don't use PHP anymore but I certainly don't share the despect which others have)

fun thing I also wanted to add a point about documentation but you did it yourself, life is fun sometimes :)

Re:I still love PHP and JavaScript by gbuk2013 on Wednesday August 03, 2022 @05:15AM (#32329416)
Back in the day when I wrote PHP code it was not pleasant to work with UTF-8 - is it better now?
Re:I still love PHP and JavaScript by sfmike on Wednesday August 03, 2022 @01:51AM (#32328096)
agreed reminds me of nomadlist and the sort of php philosophy of I wanted some function so with 1 php flat file I made a sort of website with app like behavior. If anything is this not programming to the masses? PHP PHP! :p
Re:I still love PHP and JavaScript by ksec on Wednesday August 03, 2022 @09:08AM (#32331203)
I only wish PHP has a cousin with modern syntax.
Re:I still love PHP and JavaScript by pkrumins on Tuesday August 02, 2022 @08:49PM (#32326326)
Amen. You get it 100%. Come work for me!
Re:I still love PHP and JavaScript by zelphirkalt on Wednesday August 03, 2022 @06:19AM (#32329801)
> - it's stateless by design (much easier to scale)

"By design" PHP encourages very very stateful procedural programming. It is one of the languages, where making things not mutate state seems like a mostly unused strategy. The amount of beginner code people find online and that mindset of "if it works it works shrug" continues to keep bad code alive.

The thing that might be referred to here by "stateless" is that a PHP "application" runs the code from top to bottom, as if all was one long script. This primitive handling has its own issues of course, but I will admit, that sometimes it is useful, that you can change the code and do not need to restart PHP or anything, because you will get the new script executed when the next request comes in.

> - it was "serverless" before Serverless

Where "serverless" is just a buzzword. PHP runs on a server just like many other languages. You will need a machine acting as a server, you will need PHP installed, you will need some webserver, usually something like Apache or NGINX with fpm or some other shenanigan. Nothing really special there.

> - surprisingly performant

Which in part, I would claim, is due to its reckless way of handling types, introducing hidden bugs. The type system is quite underdeveloped and cannot give many guarantees. No generics, no general object type, which everything inherits from, but only an object type, which not every other object inherits from. Then that "mixed" type, which just makes things even more fuzzy in a signature of a procedure and encourages bad design again.

Of course, if you throw all safety overboard, then you can get a bit more speed. Not really impressive.

> - no "unknown unknowns". it's so tried-and-true, there's no surprises

I just recently looked at defining constants in PHP. But I could not see in the docs, what the scope of a constant is. Simply not to be found. I just had to try it and hope. This is often the case with PHP and its half-baked docs.

> - deployment is so simple, just drop a file on a web server. No middleware needed.

But the webserver is the middleware you need. Like mentioned above, some Apache you need to configure, or some NGINX, or some other server. Maybe you have only ever deployed on managed infrastructure and never done the actual full deployment? Always enjoyed other people setting things up for you? I guess this is true for most of the people claiming, that PHP deployment is simpler than in other languages.

> - No long compile times because there is no compiling needed.

That again comes at the cost of safety. PHP types if you declare them in the code are not checked at compile time, but only when the code runs, making them merely annotations to read for another person.

In the PHP world we have learned not much from the past decades of programming language design. It is understandable. Lots of people have build tons of almost breaking things on top of PHP's design flaws and would start a riot, if things ever changed. For the sake of backwards compatibility PHP will remain in its swamp of bad design choices.

Sure, people can try to build on top of that, abstracting from it all through more modern web frameworks, plastering over all of the flaws. Sooner or later though, you will need to use some actual PHP code in there somewhere and the bad design will rear its head again.

Re:I still love PHP and JavaScript by techsin101 on Tuesday August 02, 2022 @09:40PM (#32326652)
- 9 ways to do same thing in PHP api

- worst way to do templating

- weird mental model of putting all logic and templating in one file

Re:I still love PHP and JavaScript by Octoth0rpe on Tuesday August 02, 2022 @09:43PM (#32326673)
> weird mental model of putting all logic and templating in one file

That's up to you though. You're welcome to put all your logic in one file and your templating in some other file.

Re:I still love PHP and JavaScript by techsin101 on Tuesday August 02, 2022 @10:25PM (#32326921)
I guess but that brings to next point, varying approaches to this problem in the wild, and since all are valid, codebases seem to have all of them.
Re:I still love PHP and JavaScript by ipaddr on Tuesday August 02, 2022 @10:11PM (#32326836)
Like a react component?
Re:I still love PHP and JavaScript by techsin101 on Tuesday August 02, 2022 @10:24PM (#32326908)
i dont like react but even in react there is clear distinction, I've found tons of logic within templates of php like from <?php to ?>.. anything at anytime could cause anything. Kinda gives me global variable vibes
Re:I still love PHP and JavaScript by bigtunacan on Tuesday August 02, 2022 @10:35PM (#32326998)
That's an issue of design. You can't really blame the language for bad programming practices
Re:I still love PHP and JavaScript by lmm on Tuesday August 02, 2022 @11:34PM (#32327364)
You absolutely can and should. The language is responsible for the programming practices it promotes.
Re:I still love PHP and JavaScript by bigtunacan on Tuesday August 02, 2022 @11:52PM (#32327467)
This is just so far from the truth. I can just as easily push tons of logic down into templates in erb/jsp/jinja etc... at some point it boils down to the programmer's level of expertise, but also to the programmers' opinions as there are still a lot of varying opinions on what exactly are best practices.
Re:I still love PHP and JavaScript by lmm on Wednesday August 03, 2022 @12:03AM (#32327534)
> I can just as easily push tons of logic down into templates in erb/jsp/jinja etc...

Not just as easy if they don't allow you to insert arbitrary code at arbitrary points as PHP does.

Personally my preferred approach is Wicket where you can't have any logic in your markup at all, all of your logic lives in code and the only thing you can put in the template is IDs for where the code can insert child components or plain text. (OK, it's not quite that strict, but it gets pretty close in practice).

> at some point it boils down to the programmer's level of expertise, but also to the programmers' opinions as there are still a lot of varying opinions on what exactly are best practices.

That's neither here nor there; "programmer's level of expertise" is just abdicating responsibility, when in fact a programmer at the same level of expertise might produce much better code in one language than another.

Re:I still love PHP and JavaScript by bigtunacan on Wednesday August 03, 2022 @12:42AM (#32327737)
You seem to think that you refuted my argument, but instead you reinforced it.

By using Wicket you are making a choice to opt in to a template system that encourages best practices. This is the same reason people in the PHP ecosystem opt in to Twig/Blade/Mustache, or how people on Ruby opt out of ERB for Slim or Haml.

Re:I still love PHP and JavaScript by lmm on Wednesday August 03, 2022 @01:01AM (#32327833)
How many of them, and how well does the ecosystem support them in doing so? It's theoretically possible to write good code in any language, sure, but in practice the language (not just the formal syntax, but the tooling, ecosystem and community, the whole culture of the language) has a lot of influence on whether people write good or bad code in it.
Re:I still love PHP and JavaScript by bigtunacan on Wednesday August 03, 2022 @03:43AM (#32328762)
Laravel is the top choice for PHP frameworks these days which auto opts you into Blade. And just from my my own personal experience (so not necessarily a great sampling) every non-legacy PHP codebase I've been involved with on various teams had adopted other template engines with Twig being most common.

Also, to be frank, it's a real shame that people look down their noses at PHP so much just because of the sheer amount there is that can be learned about the practical application of design patterns from spending some time in the Laravel code base.

Re:I still love PHP and JavaScript by ipaddr on Wednesday August 03, 2022 @01:02PM (#32334258)
Smarty was prime to takeover the templating space in 2004 what happened?

PHP has had solutions from the beginning or at least early times.

PHP lacked that cult figurehead and was always community based. Most new languages are corporate sourced (open source by corporations).

Re:I still love PHP and JavaScript by bigtunacan on Thursday August 04, 2022 @11:46AM (#32344453)
Smarty is still around and well supported, but Twig is the top choice these days. Symfony is the 2nd most used "framework" these days, Twig is part of Symfony; then on top of that Symfony is really just a set of components (that work hard to adhere to current PSRs) so even projects that aren't Symfony projects will usually incorporate Symfony components as best of breed. Even Laravel relies on Symfony components.
Re:I still love PHP and JavaScript by countvonbalzac on Tuesday August 02, 2022 @08:07PM (#32325989)
Is Hack better than PHP?
Re:I still love PHP and JavaScript by francislavoie on Tuesday August 02, 2022 @10:34PM (#32326984)
Hack does have a lot of great features (some of which have already been ported to PHP, others are kinda impossible for technical reasons), but at this point, it's diverged so hard from PHP that they're separate languages.

If you choose Hack, you lose the entire PHP ecosystem (composer) that could back you up and save you time. The only ones really using it are Facebook/Meta, so it would be a mistake to choose it for a new project, IMO. It doesn't really have a future.

Re:I still love PHP and JavaScript by jrsj on Wednesday August 03, 2022 @12:24AM (#32327654)
I know Slack was using it at one point as well but I have no idea if they still are. That seemed to be as far as it got outside of Facebook though.
Re:I still love PHP and JavaScript by nkozyra on Tuesday August 02, 2022 @08:40PM (#32326266)
In 2022? Probably not. When it came out? Absolutely.
Re:I still love PHP and JavaScript by jamesfinlayson on Wednesday August 03, 2022 @12:17AM (#32327619)
Yeah there were a few years there where PHP frameworks were also adding Hack support... and then Hack started to diverge too much from PHP and now I don't think many (any?) PHP frameworks still support hack.
Re:I still love PHP and JavaScript by zeroonetwothree on Tuesday August 02, 2022 @10:15PM (#32326856)
Only if you are Facebook. Err I mean Meta.