Earlier quoted context omitted.
> They're built using a decent framework (Yii 1.x) Agreed - I've used Yii in the past and it was just great.
Just dont use the active record.
I still love PHP and JavaScript
381–390 of 402 posts
Re: I still love PHP and JavaScript
#382Earlier quoted context omitted.
Python build/package management tooling is a joke, but Python the language is very consistent and usable.
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
#383Earlier quoted context omitted.
Thanks for the comment! As a counterpoint, I used PHP5 when writing https://www.goldeneaglecoin.com/ and it was always 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-fr…
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 foun…
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
#384But speed is inversely proportional to the linecount.
At some point it is better to use a compiled language like Go.
Re: I still love PHP and JavaScript
#385Earlier quoted context omitted.
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.
> 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
#386Earlier quoted context omitted.
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.
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
#387PHP 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…
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 r…
Re: I still love PHP and JavaScript
#388Earlier quoted context omitted.
Does that only cull nulls, or also zeroes, falses and empty strings?
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
#389Earlier quoted context omitted.
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
#390Earlier quoted context omitted.
Not every Wordpress developer is an amateur. Often times, as a programmer, it's easier for me to change my environment, language, or learn their stack to be helpful to them than it is for the company to switch their stack because of my unwavering views on "right" languages.
True fact, but in my experience there is some really shoddy wordpress code in the wild.
There's a lot of really great developers that got their feet wet with dev work because Wordpress is immediately accessible and helpful. They just needed a playground to write shoddy code before they matured and perfected their craft.
In my opinion, I'd rather people write shoddy code and improve it than wait until they've ready enough books to write perfect code, but never actually start.
Doing something subpar now is often better than waiting till it's perfect and not doing it at all.