by kingofthehill98 · 2y ago · 0 comments
Of course this is not what we see at production-grade software, but I really enjoy the fact that the language was designed with the HTTP protocol in mind. It's really unique in this sense.
When I did learn about HTTP, it was very easy, since I already knew it without knowing I knew it, so maybe that's in favor of your point, but there's much to be said for the actual understanding that I didn't have at first. When I started interviewing people for PHP entry-level jobs, asking about HTTP was one of the ways I gauged how well applicants understood their work at a conceptual level.
It also took learning other languages to understand how PHP is so unique in how tied to HTTP it is (rebuilding its entire universe every request).
(these learnings happened when moving beyond the PHP-based CMS style of development - agency style work on my case - to make more custom software).
The fact that I can't tell if this comment is sarcasm or snark or serious says a lot.
PHP mixed with HTML was one of the "bad ideas" that hurt PHP. It was a bad practice that got out of hand.
Now why no one bats an eye at node/react doing this very thing and calling it JSX is beyond me but...
Hey don't drag Node into this, you aren't forced to do any of that.
React to me feels like SPA developers discovering the idea of PHP and thinking they invented it. This shouldn't be surprising, since React came from Facebook, and Facebook historically is a PHP shop.
Mixing your business logic and presentation is a bad idea, but it's very attractive when you don't have the informative scars
You might say, doesn't Facebook have the scars to avoid designing React? Well, when you have a hammer, everything looks like a nail.
PS: I would suspect the down voting is just the "LOL", otherwise it's a fair comment.
This is accurate, and I never thought of it that way.
> PS: I would suspect the down voting is just the "LOL", otherwise it's a fair comment.
I did laugh out loud because I did not know WHAT to make of the comment. As someone who buttered my bread on PHP when everyone hated it, it was a sign of how times have changed!
It works great, it's fast and you don't have to learn a new templating language or dialect every 2-3 years. Or try to figure out how to do trivial things like loops in loops.
I don't quite get the use of templating engines in PHP because PHP is a templating engine itself.
[1] It's so much worse than this... You can use some horrible hacks like undefining a well-known function that each template implements, but this would only work one level deep without also adding a mechanism for "calling" a template, and at that point you are making a template system on top of PHP.
1. It's a loaded foot gun. PHP was notorious for 1000 line files with HTML and SQL all mixed together. (I speak from personal experiences on this)
2. Templating languages are "portable" (In theory). Have a mixed env of PHP and Java... there were templating languages that would work for both teams, it took a step out of scalability.... XML and XSLT were the promise land on this one, but we fucked all that up. Portability is a big deal. We're still slinging CSV files for a good reason.
Do you write safe templates in PHP ?
In PHP, “HTML" is string concatenation; in React, “HTML" is an HTML-flavoured bit of syntax sugar over HTML-generating functions (and you are still welcome to call the functions yourself, if you want your HTML-generation code to avoid looking like HTML). Aside from looking kind-of similar if you squint, I’d say the differences and pros and cons are fairly significant (For example the IMO worst thing about the PHP approach, the ease of shooting yourself in the foot with XSS holes, is a non-issue in JSX).
I use it exactly for rapid dev of stupid ideas. I’m not sure if I’d use it in a production environment because it is quite slow.
Indeed.
It is obviously good to be able to automate generating web pages based on say the state of a database. As this gives you up-to-date pages without someone having to manually build them.
And if that - automatically build web-pages from a database - is your goal and your current state of the art is static pages, then creating a language you can interject into your static pages, to build the page dynamically is a no brainer.
So what, JSPs are just the same. In the end what matters is the speed to Get Things Done, and there's utterly nothing competing with PHP, closely followed by Tomcat+JSP as you can use the insane amount of interfaces with just about everything that the Java world has.
PHP receives its share of criticism, and HTML lives on relatively unscathed.
So if mixing PHP/HTML is a problem, you'd probably throw out the PHP and keep the HTML.
Also, isn't this use case PHP's origin? A dev wanted some programmable HTML?
Because it's not "this very thing". HTML around PHP is output directly to stdout. JSX is just syntax for literals.
If you think of PHP as prototype-only, mixing tags and HTML is very convenient, like it is with the other thousand templating tools. And obviously it's more a problem of XSS through badly sanitized inputs more than the mix in itself, blah blah blah
It's PHP in production a bad practice that got out of hand.
Turns out I wasn't missing much. I've mentally pegged it as an example of "the pendulum swings" - thin client vs thick client, centre vs edge, tight coupling vs loose coupling, etc.
React is popular for the same reason as PHP. I can only hope the industry corrects for this soon, because I challenge you to find a startup building raw PHP in 2024, yet nearly all of them build with React.