Live data from Hacker News

I still love PHP and JavaScript

the.scapegoat.dev

381–390 of 402 posts

Re: I still love PHP and JavaScript

#381

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.

How come? I found it fine, and it was a high traffic application. It had some overhead but it wasn't enough to make us not use it.

Re: I still love PHP and JavaScript

#382
post #349
post #295

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

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

#383
post #350

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

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

#385

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

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

#386
post #162

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

I use PHP daily at work, haven't had to check the docs for quite a while

Re: I still love PHP and JavaScript

#387
post #288
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…

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…

Modern PHP with a framework like Laravel is honestly a joy to work with.

Re: I still love PHP and JavaScript

#388

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

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

#389
post #361

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

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

#390

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

I agree. But no developer starts writing unshoddy code right away.

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.

Post reply on HN