News for hackers. Stuff that matters.
Re:PHP in 2023 by koonsolo on Tuesday January 17, 2023 @07:15AM (#34411586)
> Your comparing to React which is not a language or in the same domain is confusing and makes me doubt your credibility.

They both render HTML and do it in a very different way.

Re:PHP in 2023 by dubcanada on Tuesday January 17, 2023 @07:21AM (#34411625)
That's such a strange statement, you can compare PHP and React because they both can return a HTML string? Even though one is built entirely within another language, and it isn't is not a "language". More of a toolkit. Same as say Symfony html framework is.
Re:PHP in 2023 by archerx on Tuesday January 17, 2023 @07:49AM (#34411812)
This is why I stopped posting on the internet people will twist and turn stuff for reasons beyond me. It’s like pulling teeth.
Re:PHP in 2023 by koonsolo on Tuesday January 17, 2023 @10:23AM (#34413480)
A "React vs PHP" Google search turns up tons of articles and forum questions with that exact same comparison.

So either it's logical to compare the two, or the internet is just full of idiots like me and the parent poster :D.

Re:PHP in 2023 by shkkmo on Tuesday January 17, 2023 @10:56AM (#34414046)
Many of those questions have answers that point out you are comparing two very different things. Some of them are explicitly comparing Laravel and React, which makes a bit more sense. The rest seem to be AI generated trash.

The easiest way to explain it is that you could reasonably use react within a PHP project.

I wouldn't use the term "idiot" but rather "ignorant". A good article that answers the PHP vs React question would be mostly explaining the differences in the function and usage of both tools.

Re:PHP in 2023 by koonsolo on Tuesday January 17, 2023 @12:45PM (#34415758)
For reference, I'm working with both React and PHP. And yes, for example WordPress uses React components. I'm a 42 year old software architect. But hey, maybe I've been ignorant all this time.

React vs PHP is a decision you can make, because... the intention of both is to output HTML.

edit:

> The easiest way to explain it is that you could reasonably use react within a PHP project.

I can use C within a Python project. Does that mean I can't compare the two? One is compiled while the other is interpreted, so maybe you can't compare those?

Re:PHP in 2023 by shkkmo on Tuesday January 17, 2023 @01:25PM (#34416439)
> React vs PHP is a decision you can make, because... the intention of both is to output HTML.

Often PHP is used when no HTML rendering happens at all (Apis, scheduled jobs etc.)

> I can use C within a Python project. Does that mean I can't compare the two? One is compiled while the other is interpreted, so maybe you can't compare those?

Those are at least both programming languages. Several major python libraries are written in C (or other compiled language) so a pure python project is probably fairly rare. Someone asking for "Python vs C" is probably more in need of an explanation of what the broad categories mean and tend to be used for than a point by point breakdown of specific language features and ergonomics.

In this specific instance, the complaint was that PHP, a server side language, doesn't offer client side rendering built in. This a point that should be brought up comparing JavaScript to PHP, not React.

Re:PHP in 2023 by koonsolo on Tuesday January 17, 2023 @02:58PM (#34417899)
> Often PHP is used when no HTML rendering happens at all (Apis, scheduled jobs etc.)

When comparing to React those things are irrelevant.

> the complaint was that PHP, a server side language, doesn't offer client side rendering built in.

So am I allowed to compare server side rendering to client side rendering? Or are those 2 different things and I'm ignorant if I try to compare them?

Re:PHP in 2023 by shkkmo on Tuesday January 17, 2023 @10:49PM (#34423251)
If you complain your tesla doesn't float very well, then you might be a little ignorant of what cars are used for (and that you probably should have used a ferry.)
Re:PHP in 2023 by koonsolo on Wednesday January 18, 2023 @01:33AM (#34423998)
React can be used both on the server and client side. That is a benefit over something that can be only used on the server side.

React can even be both on server and client using 1 codebase (see Next.js). But it seems the PHP police here on HN does not allow me to compare that solution to a solution in PHP.

Re:PHP in 2023 by koonsolo on Tuesday January 17, 2023 @09:43AM (#34412912)
It's funny how we both think of each others statement how strange it is.

For me, not being able to compare the two is like saying: You cannot compare a horse with a car as a means of transportation because a car is not an animal.

For me, I don't care one is a programming language and the other is a framework. For me they are both ways to generate HTML. PHP was/is mainly intended to generate HTML. It started as "Personal Home Page" and now is "Hypertext Preprocessor".

Re:PHP in 2023 by NerdiOrg on Tuesday January 17, 2023 @07:19AM (#34411613)
Yes, but that doesn't make it a programming language. A lot of things can render HTML. I am pretty fluent in Javascript, HTML, CSS, jQuery, React, Nodejs, Nextjs, PHP, Python, and a beginner in Java and a few others. React is not a programming language.
Re:PHP in 2023 by zeptonix on Tuesday January 17, 2023 @07:23AM (#34411634)
Right, that's why it was React.*script. Regex.