Live data from Hacker News

I still love PHP and JavaScript

the.scapegoat.dev

361–370 of 402 posts

Re: I still love PHP and JavaScript

#361
post #189

Earlier quoted context omitted.

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.

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 amo…

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

#362

Earlier quoted context omitted.

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. Deployi…

> 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…

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

#363
post #162

Earlier quoted context omitted.

That’s just it. I have to code with the PHP docs open like some kind of arcane recipe book.

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

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

#364
post #332
post #162

Earlier quoted context omitted.

That’s just it. I have to code with the PHP docs open like some kind of arcane recipe book.

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 case…

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

#365

Earlier quoted context omitted.

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. Su…

> 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.

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

#366

Earlier quoted context omitted.

> - 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." :)

https://www.php.net/manual/en/language.types.declarations.ph...

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

#367

> They are used by people who get shit done. pretty much says it all. let me finish building this shitty app by deadline, while you guys continue argue about which static type checking system is better.

And then run off for the next job after a year or two and leave the rest of the dev team with your badly written code, so that they have to clean up the mess behind you?

Run of to the next job?

Honestly, that sounds much more like a dev who is always chasing the new shiny, rather than a dev competent in a boring, stable old tech like php

Re: I still love PHP and JavaScript

#368
post #59

You know what I like is jquery

I assume this is meant in snark, but jquery was such a breath of fresh air when it came out. I have been doing some SPA stuff with raw DOM, later on mootools and yahoo ui around 2003-2004, and that was really the wild west.

Oh no, I'm totally serious, I love jquery to this day, and yeah it was incredible when it came out

Re: I still love PHP and JavaScript

#369

Earlier quoted context omitted.

> 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, es…

> 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…

> 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: 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

#370

Earlier quoted context omitted.

> 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, es…

> 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.

Good to know it's that easy.

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

Post reply on HN