Live data from Hacker News

I still love PHP and JavaScript

the.scapegoat.dev

51–60 of 402 posts

Re: I still love PHP and JavaScript

#51
PHP was my main language from 2000 to 2011. I liked PHP 4 very much. "Pass by value" was the default, so it accidentally introduced me to the Functional paradigm, even though it didn't have the memory management to allow for real functional programming. (It did not internally share memory between old and new versions of an object.)

I dislike the direction that PHP has taken since the introduction of PHP 5. For the last 18 years or so, the language has been trying to become something like Java, but without the speed benefits we might get from it being compiled, and without the strictness benefits we might get from being strictly typed. Nowadays it has most of the heavy rituals of Java, but without any of the benefits.

The single greatest thing about PHP, circa 2000, was the abstraction it calls an "array" which combines what other languages would call a vector (or a list) and a hashmap (or dict in Python). That array construct was very flexible and allowed me to get away with a great deal. Later on I discovered the "seq" abstraction in Clojure, which is even more incredible, and has the added benefit of being done correctly, in an academic sense.

After 2011, I increasingly relied on Clojure, for any task where dynamic programming was reasonable. Clojure puts me on the JVM and allows me to drop into something like Java, and strict typing, in the rare cases where that seems necessary.

PHP in 2000 was extremely lightweight but nowadays it demonstrates of envy of heavier object oriented languages, but again, it still lacks the speed benefits of being compiled or the correctness checks offered by strict typing.

The article lists these benefits of PHP:

* speed

* ease of deployment

I don't think anyone would pick PHP purely on the basis of speed, again, there are many languages that are faster.

In terms of easy of deployment, any deployment of PHP (or Python, or Ruby) tends to mean deploying tens of thousands of files. By contrast, when I work in Clojure, I typically uberjar the code, and then I only have to deploy one file, which makes deployment ridiculously easy.

Re: I still love PHP and JavaScript

#52
In 2022 there is no reason to prefer these dynamically typed languages over statically typed ones for production code. When languages like PHP, Ruby, JS blew up the knock against statically typed languages was the verbosity of the resulting code, slow development cycle and general cruft, these languages solved a real problem at that time. That is no longer true today- TypeScript, Go, C# code feels as fluid as a dynamic language and even Java has come a long way with type-inference that Java no longer feels as unwieldy as it used to.

I legitimately can't imagine willingly not using a statically typed language for anything that matters that's gonna have more than just me working on it.

Re: I still love PHP and JavaScript

#53
post #47
post #44

Earlier quoted context omitted.

> EDIT: why the downvotes? The anti-PHP cult is strong here on HN. List 5 benefits of React and watch your upvotes skyrocket.

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.

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

#54
post #4

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…

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

#57

Your definition of "legacy code" seems to be the exact opposite of what it is generally understood by the term (in the Michael Feathers sense).

thanks for reading! I use legacy code as in "code that was written yesterday or earlier", or in a less jokey fashion as "code that noone really feels ownership for", usually a codebase that shows the sign of many developers, repeated cycles of outside pressure. What I mean by "product performing well" is that the legacy codebase is still alive for a reason: it is doing its job and the job has value. Otherwise it can just be cut and deleted (a very pleasant refactoring technique, I must admit).
Post reply on HN